Skip to content

Instantly share code, notes, and snippets.

@vprus
Created July 9, 2015 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vprus/282346f73b4d4e9f759e to your computer and use it in GitHub Desktop.
Save vprus/282346f73b4d4e9f759e to your computer and use it in GitHub Desktop.
C++11 result_of_t
#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