Created
April 22, 2012 06:03
-
-
Save iboB/2459893 to your computer and use it in GitHub Desktop.
A way of checking if a class is derived from a template
This file contains hidden or 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
template <typename A, typename B> | |
class myclass | |
{}; | |
template <typename T> | |
struct is_myclass | |
{ | |
struct yes { char c; }; | |
struct no { char c[2]; }; | |
template <typename A, typename B> | |
static yes check(myclass<A, B>*); | |
static no check(...); | |
static const bool value = sizeof(check(static_cast<T*>(nullptr))) == sizeof(yes); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment