Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-04-05 17:17:46


Eric Niebler:
...

> Like a good citizen, I've written make_foo's function call operator to
> recognize reference_wrapped and non-const-ref arguments as representing
> lvalues and all others as rvalues.

Const-ref arguments are lvalues. I'm not sure why do you need the
reference_wrapper support.

> The strictly correct thing to do would be to wrap lvalues in
> reference_wrappers before passing them to F. If I don't, make_foo will
> do the wrong thing.

I don't see why. Lvalues are lvalues. Wrapping them in a reference_wrapper
won't make them any more lvaluish. I'm probably missing something.

> struct blarg
> {
> template<typename This, typename Arg>
> struct result< This( Arg ) >
> {
> // OK, if Arg is a reference, then it's an lvalue!
> };
>
> template<typename Arg>
> typename result< make_foo( ??? ) >::type
> operator()( Arg const & arg )
> {
> // whoops, I don't know here if arg is an lvalue or rvalue
> }
> };

Write the return statement. Is it

    return make_foo()( arg );

?

If so, the ??? part is "Arg const&", because that's what 'arg' is.


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