Created
October 13, 2013 20:35
-
-
Save jiripospisil/6967151 to your computer and use it in GitHub Desktop.
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> | |
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