]> git.ipfire.org Git - thirdparty/gcc.git/commit
Implement LWG 2904 for std::variant assignment
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Apr 2019 23:01:12 +0000 (23:01 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Apr 2019 23:01:12 +0000 (23:01 +0000)
commitfd1863e18d0bea5541b5231475ba799b6535faa2
treeb2c536fee70cd0d7fd4b0f936e13cabc730dc05d
parentb09afa7b8f54640bca47256d3541823b398bfb4b
Implement LWG 2904 for std::variant assignment

* include/std/variant (__variant_construct): Use template parameter
type instead of equivalent decltype-specifier.
(_Move_ctor_base<false, Types...>::_Move_ctor_base(_Move_ctor_base&&)):
Replace forward with move.
(_Move_ctor_base<false, Types...>::_M_destructive_move)
(_Move_ctor_base<false, Types...>::_M_destructive_copy)
(_Move_ctor_base<true, Types...>::_M_destructive_move)
(_Move_ctor_base<true, Types...>::_M_destructive_copy): Only set the
index after construction succeeds.
(_Copy_assign_base<false, Types...>::operator=): Remove redundant
if-constexpr checks that are always true. Use __remove_cvref_t instead
of remove_reference so that is_nothrow_move_constructible check
doesn't use a const rvalue parameter. In the potentially-throwing case
construct a temporary and move assign it, as per LWG 2904.
(_Move_assign_base<false, Types...>::operator=): Remove redundant
if-constexpr checks that are always true. Use emplace as per LWG 2904.
(variant::operator=(T&&)): Only use emplace conditionally, otherwise
construct a temporary and move assign from it, as per LWG 2904.
* testsuite/20_util/variant/exception_safety.cc: Check that
assignment operators have strong exception safety guarantee.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270525 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/variant
libstdc++-v3/testsuite/20_util/variant/exception_safety.cc