Skip to content

Instantly share code, notes, and snippets.

@tenpercent
Last active December 29, 2015 22:09
Show Gist options
  • Save tenpercent/7734291 to your computer and use it in GitHub Desktop.
Save tenpercent/7734291 to your computer and use it in GitHub Desktop.
type traits example
#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