Boost logo

Boost :

Subject: Re: [boost] [move][container] Review Request (new versions of Boost.Move and Boost.Container in sandbox and vault)
From: Ilya Bobir (ilya.bobir_at_[hidden])
Date: 2009-08-23 21:29:57

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.

Boost list run by bdawes at, gregod at, cpdaniel at, john at