Boost logo

Boost :

Subject: Re: [boost] [operators] The future
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-10-04 18:24:36


on Tue Oct 04 2011, Nevin Liber <nevin-AT-eviloverlord.com> wrote:

> On 4 October 2011 16:05, Matt Calabrese <rivorus_at_[hidden]> wrote:
>
>> Type&& operator +( Type&& left, Type const& right )
>> {
>>  left += right;
>>  return std::move( left );
>> }
>
>> Anyway, as was pointed out, this is probably not a good idea for other
>> reasons, such as people expecting to be able to bind the result to a
>> reference and have its life extended (though I suppose you could just
>> rule-out such uses as valid when the base is used).
>
> What happens with:
>
> Type t = TypeFactory();
> auto sum = TypeFactory() + t;

That one's fine; sum is deduced to have a non-reference type.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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