Let\'s say I have some templated class depending on type T
. T
could be almost anything: int
, int*
, pair
You want to determine whether it is a non-union class. There is no way known to me to do that (and boost hasn't found a way either). If you can live with union cases false positives, you can use a is_class
.
template<typename> struct void_ { typedef void type; };
template<typename T, typename = void>
struct is_class { static bool const value = false; };
template<typename T>
struct is_class<T, typename void_<int T::*>::type> {
static bool const value = true;
};
Boost has an is_union that uses compiler-specific builtins though, which will help you here. is_class
(which boost also provides) combined with is_union
will solve your problem.