Boost logo

Boost :

Subject: Re: [boost] [move] auto-generated operator=
From: David Abrahams (dave_at_[hidden])
Date: 2009-11-16 21:35:42


on Mon Nov 16 2009, Ion Gaztañaga <igaztanaga-AT-gmail.com> wrote:

> David Abrahams escribió:
>> On Nov 16, 2009, at 7:46 AM, David Abrahams wrote:
> m with requiring move-enablers to supply a swap.
>>
>> In fact, I don't even think we need to do that. This seems to work pretty well:
>>
>> #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\
>> public:\
>> TYPE& operator=(TYPE t)\
>> { return this->operator=(static_cast< ::boost::rv<TYPE>&>(t)); } \
>> //
>
> Interesting. This works for some types but it has performance impact in types
> like vector because they can't reuse previous allocated resource
> (e.g. capacity).

Yeah, but I think it might be worth the cost. Otherwise you end up with
a world where movable types in libraries are poison because, e.g., they
are incompatible with std containers.

-- 
Dave Abrahams           Meet me at BoostCon: http://www.boostcon.com
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