https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83981

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #8)
> I don't think your patch is correct. The whole point of the "move if
> noexcept" utilities is that they handle this correctly. If the type is
> nothrow movable, then move. Otherwise if it is copyable, then copy.
> Otherwise move (even though that might throw).

This is why the "Remarks:" paragraph talks about "a non-CopyInsertable T". If
copying  wasn't allowed here then whether it's CopyInsertable would make no
difference, and the exception safety guarantee could just say "If an exception
is thrown other than by the move constructor of T, there are no effects."

(This of course assumes that the constructor used by
allocator_traits::construct is the move constructor, but that's a separate
defect).

Perhaps Daniel can comment, since he wrote the resolution of lwg 2033.

Daniel, if the intent was that vector::resize(size_type) must only move, even
if that can throw, why is the exception-safety guarantee worded in terms of a
non-CopyInsertable condition? Was the intention really to forbid
implementations from giving the strong exception-safety guarantee (by copying)
if possible?

Reply via email to