Adapting Interface-Incomplete Types at Compile Time
By Matthew Wilson, December 01, 2005
When an adapter template makes demands that a potential underlying type cannot fulfill, Interred Interface Adaptation can expand the number of adaptable types.
December, 2005: Adapting Interface-Incomplete Types At Compile Time
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 };
};