Created
July 9, 2015 10:20
-
-
Save vprus/282346f73b4d4e9f759e to your computer and use it in GitHub Desktop.
C++11 result_of_t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <iostream> | |
struct S { | |
int operator()(int) { return 1; } | |
}; | |
int normal(int) { return 1;} | |
int main() | |
{ | |
// Using double () here changes type from function to pointer to function. | |
// Apparently result_of_t does not like function type, per http://stackoverflow.com/a/30919688/126517 | |
using N = decltype((normal)); | |
std::result_of_t<S(int)> v1 = 10; | |
std::result_of_t<N(int)> v2 = 10; | |
return v1 + v2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment