]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fixes for std::expected
authorJonathan Wakely <jwakely@redhat.com>
Fri, 16 Dec 2022 16:07:29 +0000 (16:07 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 16 Dec 2022 20:58:09 +0000 (20:58 +0000)
commit59822c39207c9e8be576e9d6c3370bd85ddaf886
tree5f1c1de4a706e68c52b8906bddc82bb43b92abe0
parent64c986b49558a7c356b85bda85195216936c29a3
libstdc++: Fixes for std::expected

This fixes some bugs in the swap functions for std::expected.

It also disables the noexcept-specifiers for equality operators, because
those are problematic when querying whether a std::expected is equality
comparable. The operator==(const expected<T,E>&, const U&) function is
not constrained, so is viable for comparing expected<T,E> with
expected<void,G>, but then we get an error from the noexcept-specifier.

libstdc++-v3/ChangeLog:

* include/std/expected (expected::_M_swap_val_unex): Guard the
correct object.
(expected::swap): Move is_swappable
requirement from static_assert to constraint.
(swap): Likewise.
(operator==): Remove noexcept-specifier.
* testsuite/20_util/expected/swap.cc: Check swapping of
types without non-throwing move constructor. Check constraints
on swap.
* testsuite/20_util/expected/unexpected.cc: Check constraints on
swap.
* testsuite/20_util/expected/equality.cc: New test.
libstdc++-v3/include/std/expected
libstdc++-v3/testsuite/20_util/expected/equality.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/expected/swap.cc
libstdc++-v3/testsuite/20_util/expected/unexpected.cc