I\'m trying to write code that uses a member typedef of a template argument, but want to supply a default type if the template argument does not have that typedef. A simpli
You can do that by utilizing SFINAE:
template struct has_type {
template static char (&test(typename U::Type const*))[1];
template static char (&test(...))[2];
static const bool value = (sizeof(test(0)) == 1);
};
template::value> struct Get_Type {
typedef DefaultType Type;
};
template struct Get_Type {
typedef typename T::Type Type;
};