Example 5: Definition of the has_value_type used for detecting whether a class has a value_type member type.
typedef struct { char ar[1]; } one_t; typedef struct { char ar[2]; } two_t; template <typename T> one_t has_value_type_function(...); template <typename T> two_t has_value_type_function(typename T::value_type const volatile *); template <typename T> struct has_value_type { enum { value = sizeof(has_value_type_function<T>(0)) == sizeof(two_t) }; }; template<> struct has_value_type<void> { enum { value = 0 }; };