
On 7/12/07, Peter Dimov <pdimov@pdimov.com> wrote:
Stjepan Rajko wrote:
So, if I have, say, a function object with operator()(int &), I should specify result<F(int &)>, (but maybe if I have operator()(const int &), or operator()(int), I can specify result<F(int)>?)
If you have operator()( int& ), you need result<F(int&)>. If you have operator()( int ), you need both result<F(int)> and result<F(int&)> because your operator() can take either an lvalue or an rvalue.
In this simple case you can just provide result_type, of course.
You are allowed to provide result<F(int)> in addition to result<F(int&)> even in the first case; failing invalid queries is not required.
What this means in practice is that in 99% of the cases you just need to strip the reference from the argument types when providing result or a result_of specialization. Only odd function objects such as
struct F { int operator()( int& ); void operator()( long ); };
need special handling.
Thank you for the detailed explanation! It is much clearer now. Stjepan