Skip to content

Instantly share code, notes, and snippets.

@dirvine
Created January 24, 2013 08:49
Show Gist options
  • Save dirvine/4618839 to your computer and use it in GitHub Desktop.
Save dirvine/4618839 to your computer and use it in GitHub Desktop.
Concept checker
// sfinae test for has ThisFunc() method
template <typename T>
class has_this_func {
typedef char one[1];
typedef char two[2];
template <typename U> static one test(decltype(&U::ThisFunc()); // could also be *U::Routing() for pointer to ThisFunc
// the above gets masked out as sfinae will choose two
template <typename U) static two test(...);
public:
static bool const value = sizeof(test<T>(0)) == sizeof(one);
// use has_this_func<T>::value as the test
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment