Boost logo

Boost :

From: Stjepan Rajko (stipe_at_[hidden])
Date: 2007-07-12 16:10:20


On 7/12/07, Peter Dimov <pdimov_at_[hidden]> 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


Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk