If you literally just want the boolean to be checked: T == A , you can use is_same , available in C ++ 11 as std::is_same , or before that in TR1 as std::tr1::is_same :
const bool T_is_A = std::is_same<T, A>::value;
You can simply write this small class yourself:
template <typename, typename> struct is_same { static const bool value = false;}; template <typename T> struct is_same<T,T> { static const bool value = true;};
Often, although it may be more convenient for you to package your fork code into separate classes or functions that you specialize in A and B , as this will give you a compile-time condition. In contrast, an if (T_is_A) check is only possible at run time.
Kerrek SB
source share