On Mon, Jan 18, 2016 at 8:28 PM, Thiago Macieira <thiago.macie...@intel.com>
wrote:

>
> Here's what a vector could when resizing do for:
>
> a) regular type
>  allocate new block, copy-construct then destroy each element, free old
> block
>
> b) regular type with move constructor
>  ditto, but move-construct instead
>
> c) regular type with noexcept move constructor
>  ditto, but like Peppe said, it can be done in a mass operation that cannot
> throw. TBH, I don't see how this implementation would differ from b. In
> fact,
> the code would be the same as a and b and I'd rely on the compiler
> optimising
> the rollback code away.
>

I don't think b) can possibly exist if you want a container to offer the
strong guarantee. Once you start moving elements out of the original block,
if a move throws, you end up in a broken state. You can't move the
already-moved elements back into the original block because that may cause
further exceptions. It should be really either a) or c) (i.e. "apply
std::move_if_noexcept").

Cheers,
-- 
Giuseppe D'Angelo
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to