Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-07-12 16:02:03

Stjepan Rajko wrote:

> [comes to a screeching halt from changing code]

Yep. :-)

> I'm still not entirely on very sure footing when it comes to rvalues
> and lvalues, so can I bother you with a practical clarification?
> 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.

Boost list run by bdawes at, gregod at, cpdaniel at, john at