
Eric Niebler: ...
make_plus is trickier. It must be optimal and safe. When passed lvalues, it should return a new node that holds the children by reference. When passed rvalues, it should return a new node that hold the children by value.
== Problem ==
Here's the thing ... I have no idea how to implement make_plus as a TR1 function object.
I think that you are right; you can't implement make_plus as a C++03 function object. result_of is a red herring. The missing part is &&, not decltype (which result_of is supposed to approximate). You can do this:
struct make_plus { template<typename Sig> struct impl;
template<typename This, typename Left, typename Right> struct impl< This(Left, Right) > { // Left and Right are allowed to be reference types typedef plus<Left, Right>::type result_type;
result_type operator()( typename add_const_ref<Left>::type left ,typename add_const_ref<Right>::type right ) const { return result_type(left, right); } }; };
but it's not a function object.