[PATCH] fix std::variant::swap for trivially-move-assignable types

Jonathan Wakely jwakely@redhat.com
Tue Aug 7 14:29:00 GMT 2018


On 07/08/18 15:24 +0100, Jonathan Wakely wrote:
>This patch fixes the bug, but is it correct?
>
>IIUC the _M_destructive_move effects don't depend on whether move
>assignment is trivial, so should be defined the same way in both
>specializations. It also looks like we can use it in the non-trivial
>move assignment.
>
>Should we define _M_destructive_move on _Move_ctor_base instead of
>_Move_assign_base, so the duplication could be avoided?

Or maybe into _Move_ctor_base as in the attached patch. That allows it
to be used in _Copy_assign_base, and means we can omit the try-catch
block when the move construction is trivial.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 2914 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180807/31483065/attachment.bin>


More information about the Gcc-patches mailing list