Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- template<class T>
- struct contains_foo_type{
- typedef int true_type;
- typedef char false_type;
- template<class S>
- static true_type f(typename S::foo_type* a);
- template<class S>
- static false_type f(...);
- static const bool value=sizeof(f<T>(0))==sizeof(true_type);
- };
- struct A{};
- struct B{typedef int foo_type;};
- struct C{int foo_type;};
- int main(){
- printf("%d\n",contains_foo_type<A>::value);
- printf("%d\n",contains_foo_type<B>::value);
- printf("%d\n",contains_foo_type<C>::value);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement