
Agoston Bejo wrote:
It seems to me that eval_if doesn't use lazy evaluation either. The error message quite obviously refers to an attempt of the compiler to evaluate the expression on the 'false' branch, whereas the condition (is_arithmetic<int>) is true to my best knowledge.
eval_if uses lazy evaluation to the extent possible: it accepts two nullary metafunctions and invokes one of them depending on how the condition evaluates. Your code computes T::value_type immediately, before either metafunction can be invoked. No library can change the properties of the C++ language. You only need to make a metafunction that gets the value_type and use that with eval_if: template <class T> struct get_value_type { typedef typename T::value_type type; }; template <class T> struct value_type : eval_if<is_arithmetic<T>, identity<T>, get_value_type<T> > {}; HTH, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com