Boost logo

Ublas :

From: Ian McCulloch (ianmcc_at_[hidden])
Date: 2005-07-11 07:49:20


Michael Stevens wrote:

> Thanks for pointing out the result_of is now (for at least a year) in
> Boost. 'promote_traits' was the state of the art a couple of years back.
> We should definitely change over to result_of in the future.

You should be a bit careful with result_of. It does not utilize SFINAE, so
if you write a forwarding template operator such as

template <typename T, typename U>
typename result_of<plus(T,U)>::type
operator+(T const& x, U const& y)
{
   return plus()(x,y);
}

it will match ALL combinations of T,U but give a compile-time error if
result_of<plus<T,U> > cannot be determined. So the above usage of
result_of turns out to be useless. Result_of does not do any typeof magic
either, it can determine the result_of only for function types (where the
return type is part of the type anyway), and function objects for which a
nested type f::result<X>::type.is defined. So I am not sure that it can
replace the logic of promote_traits anyway.

Cheers,
Ian