Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2008-04-07 13:11:11


"Peter Dimov" <pdimov_at_[hidden]> writes:

> Anthony Williams:
>> "Peter Dimov" <pdimov_at_[hidden]> writes:
>>
>>> Eric Niebler:
>>>
>>>> Can you write what the identity function object would look like in
>>>> C++0x?
>>>
>>> struct identity
>>> {
>>> template<class A> A operator()( A && a ) const
>>> {
>>> return std::forward<A>( a );
>>> }
>>> };
>>>
>>> I guess.
>>
>> No. That will convert lvalues to rvalues.
>
> Try it.

I have, and it doesn't work. Besides, you can see in the signature: it returns
"A" by value.

You either need the overloads, or you need a trait class to correctly
determine whether to return A or A&.

Anthony

-- 
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

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