Boost logo

Boost :

Subject: Re: [boost] [move][container] Review Request (new versions of Boost.Move and Boost.Container in sandbox and vault)
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-08-24 12:29:09


Frank Mori Hess escribió:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Monday 24 August 2009, Ion Gaztañaga wrote:
>> Thomas Klimpel escribió:
>>> 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.
>> Yes, but that wouldn't be the right thing. When writing move
>> constructors one must first move base classes and then
>> members.
>
> Yes, but the swap swaps both the base members and derived members.

Ooops! Thanks for spotting this.

> Wouldn't it look less suspicious if base_t were constructed the same way as in
> the default vector constructor? In this case moving into the base class
> can't accomplish anything useful even in principle, since whatever it does
> will be blown away by the swap. And if a move constructor were added to
> base_t (detail::vector_alloc_holder doesn't appear to have one) which
> modified its moved-from argument, it wouldn't cause bugs.

Yes, default constructor would be right, the problem is that an
allocator might not have a default constructor. I'll fix this.

Thanks,

Ion


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