Skip to content

Instantly share code, notes, and snippets.

@jiripospisil
Created October 13, 2013 20:35
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 jiripospisil/6967151 to your computer and use it in GitHub Desktop.
Save jiripospisil/6967151 to your computer and use it in GitHub Desktop.
#include <iostream>
template<typename T>
struct type_trait
{
template<typename U>
struct pointer_trait
{
enum { result = false };
};
template<typename U>
struct pointer_trait<U*>
{
enum { result = true };
};
enum { is_pointer = pointer_trait<T>::result };
};
int main(int argc, const char** argv)
{
std::cout << type_trait<int *>::is_pointer << std::endl;
std::cout << type_trait<int>::is_pointer << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment