Last active
December 29, 2015 22:09
-
-
Save tenpercent/7734291 to your computer and use it in GitHub Desktop.
type traits example
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 <iostream> | |
using std::cout; | |
using std::endl; | |
template<typename T> | |
struct TypeTraits { | |
static bool const IsPTR = false; | |
}; | |
template<typename T> | |
struct TypeTraits<T*> { | |
static bool const IsPTR = true; | |
}; | |
int main() { | |
cout << TypeTraits<int>::IsPTR << endl; | |
cout << TypeTraits<int*>::IsPTR << endl; | |
cout << TypeTraits<char>::IsPTR << endl; | |
cout << TypeTraits<char**>::IsPTR << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment