[Development] Question about QCoreApplicationData::*_libpaths

Giuseppe D'Angelo dangelog at gmail.com
Mon Jan 18 20:45:32 CET 2016


On Mon, Jan 18, 2016 at 8:28 PM, Thiago Macieira <thiago.macieira at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160118/2c59b959/attachment.html>


More information about the Development mailing list