
"Agoston Bejo" <gusz1@freemail.hu> wrote
template<typename T> struct value_type { typedef typename eval_if< is_arithmetic<T>, identity<T>, identity<typename T::value_type> >::type
// ERROR
type; };
In your example T::value_type is unconditionally evaluated, and eval_if will not help you in this particular case. You have to ensure that T::value_type is never mentioned in a template that can be possibly instantiated with a type that doesn't have this typedef (eval_if does this for ::type). You can either switch to using ::type instead of ::value_type, and then eval_if will probably help you, or just try something more basic, for example: template<typename T, typename IsAr> struct value_type_impl; template<typename T> struct value_type_impl<T, mpl::true_> : identity<T> {}; template<typename T> struct value_type_impl<T, mpl::false_> : identity<typename T::value_type> {}; template<typename T> struct value_type : value_type_impl<T, is_arithmetic<T>::type> {}; HTH, Arkadiy