
Eric Niebler wrote:
Correct. However, I can do this:
struct make_plus : function_adaptor<make_plus> { // same as before };
where function_adaptor implements the TR1 function object protocol and makes some guess about const-ref arguments -- probably that they are rvalues. It could even implement the reference_wrapper gunk to treat reference_wrapper<X> arguments as if they were X&.
This is the route Proto is taking. Proto can query a function object F if it uses this protocol and use it if it's available, getting correct lvalue/rvalue handling. If it's not available, it uses result_of, stripping references from argument types first.
I think I got the idea from reading through Egg's documentation. It seems like if this sort of thing doesn't exist there, it probably should. Shunsuke?
In C++03, it is (practically speaking) impossible to overload on "rvalueness". So, Egg doesn't tell underlying objects(called LittleFunction in Egg) whether an argument is an lvalue or rvalue. A LittleFunction always regards arguments as lvalues. It might be possible to offer some protocol for overload on "rvalueness" (e.g. rvalue_wrapper) which will be turned on in C++0x, though. Regards, -- Shunsuke Sogame