I am trying to implement a template class that would be able to tell me if a variable is a class,structure or a basic type.
So far I've come with this:
template< typename T >
class is_class
{
private:
template< typename X >
static char ( &i_class( void(X::*)() ) )[1];
//
template< typename X >
static char ( &i_class( X ) )[2];
public:
static bool const val = sizeof( i_class< T >(0) ) == 1;
};
and ussage:
is_class< int >::val; // false
is_class< some_class_type >::val; // true
The problem is that now I need to write a blank void function in every class that could be used with this code.
Does anyone know a solution to this problem?