[PATCH] fix std::variant::swap for trivially-move-assignable types
Jonathan Wakely
jwakely@redhat.com
Tue Aug 7 19:13:00 GMT 2018
On 07/08/18 17:57 +0300, Ville Voutilainen wrote:
>On 7 August 2018 at 17:29, Jonathan Wakely <jwakely@redhat.com> wrote:
>> 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.
>>
>
>_Move_ctor_base seems fine to me. I plan to revamp our variant to
>bring it up to the changes done before C++17
>was done, to fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85517,
>and I plan to do it shortly.
OK, here's what I've committed after testing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 5109 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20180807/28e9aa63/attachment.bin>
More information about the Libstdc++
mailing list