Boost logo

Boost :

Subject: Re: [boost] [move][container] Review Request (new versions of Boost.Move and Boost.Container in sandbox and vault)
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-08-23 22:08:33


Ilya Bobir a écrit :
> Thomas Klimpel wrote:
>> I would say that if an automatic "bad smell" detection tool like
>> Coverity would flag the above code as dangerous, it wouldn't be
>> completely wrong. After mx was used via boost::move(mx), it is not
>> supposed to be used again. So I think it would be better to write
>>
>> vector(BOOST_RV_REF(vector) mx)
>> : base_t(mx)
>> { this->swap(mx); }
>>
>> which is also less confusing for a human reader.
>
> If base(const base_t & rhs) copies rhs into this and if swap(...) swaps
> everything (including base_t part of a verctor) then the base_t part of
> mx will be first copied into this and then swaped back into mx.
>
> I do not think this can cause errors unless there is something special
> about slicing a vector instance, but the copy seems to be redundant.

This depends on what operations moved-from objects support.


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