result_of
was introduced in Boost, and then included in TR1, and finally in C++0x. Therefore result_of
has an advantage that is backward-compatible (with a suitable library).
decltype
is an entirely new thing in C++0x, does not restrict only to return type of a function, and is a language feature.
Anyway, on gcc 4.5, result_of
is implemented in terms of decltype
:
template<typename _Signature>
class result_of;
template<typename _Functor, typename... _ArgTypes>
struct result_of<_Functor(_ArgTypes...)>
{
typedef
decltype( std::declval<_Functor>()(std::declval<_ArgTypes>()...) )
type;
};