libstdc++-v3/ChangeLog:
* include/std/expected (bad_expected_access<void>): Add noexcept
to special member functions, as per LWG 4031.
* testsuite/20_util/expected/bad.cc: Check for nothrow copy and
move members.
{
protected:
bad_expected_access() noexcept { }
- bad_expected_access(const bad_expected_access&) = default;
- bad_expected_access(bad_expected_access&&) = default;
- bad_expected_access& operator=(const bad_expected_access&) = default;
- bad_expected_access& operator=(bad_expected_access&&) = default;
+ bad_expected_access(const bad_expected_access&) noexcept = default;
+ bad_expected_access(bad_expected_access&&) noexcept = default;
+ bad_expected_access& operator=(const bad_expected_access&) noexcept = default;
+ bad_expected_access& operator=(bad_expected_access&&) noexcept = default;
~bad_expected_access() = default;
public:
{
std::bad_expected_access(E{});
}
+
+void
+test_lwg4031()
+{
+ struct test_type : std::bad_expected_access<void> { };
+
+ static_assert( std::is_nothrow_default_constructible_v<test_type> );
+ // LWG 4031. bad_expected_access<void> member functions should be noexcept
+ static_assert( std::is_nothrow_copy_constructible_v<test_type> );
+ static_assert( std::is_nothrow_move_constructible_v<test_type> );
+ static_assert( std::is_nothrow_copy_assignable_v<test_type> );
+ static_assert( std::is_nothrow_move_assignable_v<test_type> );
+}