Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- isAbstract<T>::result is 1 if T is abstract, 0 if otherwise.
- */
- template<typename T>
- class isAbstract
- {
- class No { };
- class Yes { No no[3]; };
- template<class U> static No test( U (*)[1] ); // not defined
- template<class U> static Yes test( ... ); // not defined
- public:
- enum { result = sizeof( isAbstract<T>::template test<T>( 0 ) ) == sizeof(Yes) };
- };
- bool twoAbstract = isAbstract<myClass2>::result;
- bool oneAbstract = isAbstract<myClass1>::result;
- error C2784: 'AiLive::isAbstract<T>::No AiLive::isAbstract<T>::test(U (*)[1])' : could not deduce template argument for 'U (*)[1]' from 'myClass2'
- template<class U> static No test( U (*)[1] );
- template<class U> static No test( U (*x)[1] );
- template<class U> static No test( U (*)() );
- template<class U> static No test( U (*x)() );
- template <typename U>
- struct U2 : public U
- {
- U2( U* ) {}
- };
- // Match if I can make a U2
- template <typename U> static No test( U2<U> x );
- // Match if I can make a U2
- template <typename U> static No test( U2<T> x );
- template<typename T>
- class isAbstract
- {
- class No { };
- class Yes { No no[3]; };
- template<class U> static No test( U (*)[1] ); // not defined
- template<class U> static Yes test( ... ); // not defined
- public:
- enum { result = sizeof( test<T>( 0 ) ) == sizeof(Yes) };
- };
- template< typename T, typename U>
- class isAbstract
- {
- class No { };
- class Yes { No no[3]; };
- template<class U> static No test( U (*)[1] ); // not defined
- template<class U> static Yes test( ... ); // not defined
- public:
- enum { result = sizeof( isAbstract<T>::template test<T>( 0 ) ) == sizeof(Yes) };
- };
- bool twoAbstract = isAbstract<myClass2, SomeTypeU>::result;
Add Comment
Please, Sign In to add comment