
Eric Niebler wrote:
I've noticed something odd about the specification of tr1::result_of. In result_of<F()>::type, if F is a class type that doesn't have a nested result_type typedef, the result is "void". This is only true for F(); that is, when there are no arguments.
This special case is needed in situations such as: template<class F> struct X { F f_; result_of<F()>::type operator()() { return f_; } template<class A1> result_of<F(A1)>::type operator()(A1& a1) { return f_(a1); } // ... }; where X can be instantiated with non-nullary function objects, or with types that aren't function objects at all, as in: X<int> x; The above instantiates the declaration of X::operator()(), which attempts to instantiate result_of<int()>, which would fail without the kludge. There's no such problem with the A1 overload since, as a template, it's not instantiated unless used. With variadic templates a special case is no longer necessary and I believe that the C++0x result_of no longer has one.