Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Implemented LWG Issues:
- [x] [LWG-4026](https://wg21.link/lwg4026) Assignment operators of `std::expected` should propagate triviality
- [x] [LWG-3877](https://wg21.link/lwg3877) incorrect constraints on const-qualified monadic overloads for `std::expected`
- [x] [LWG-3886](https://wg21.link/lwg3886) Monad mo' problems
- [x] [LWG-4031](https://wg21.link/lwg4031) `bad_expected_access<void>` member functions should be noexcept

Enhancements:

Expand Down
14 changes: 8 additions & 6 deletions include/zeus/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,16 @@ template<>
class bad_expected_access<void> : public std::exception
{
public:
virtual const char *what() const noexcept override { return "Bad expected access"; }
[[nodiscard]] const char *what() const noexcept override { return "Bad expected access"; }

protected:
bad_expected_access() = default;
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;
// LWG-4031
bad_expected_access() noexcept = 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() override = default;
};

template<class E>
Expand Down
1 change: 1 addition & 0 deletions tests/test_expected/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(SOURCES
noexcept_tests.cpp
equality_tests.cpp
lwg_3886_tests.cpp
lwg_4031_tests.cpp
)

find_package(Catch2 3 REQUIRED)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_expected/lwg_4031_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <catch2/catch_all.hpp>

#include <zeus/expected.hpp>

using namespace zeus;

namespace
{
// Exposing all members for testing
struct test_bad_expected_access : public bad_expected_access<void>
{
using bad_expected_access<void>::bad_expected_access;
};
}

TEST_CASE("bad_expected_access<void> special members are noexcept", "[LWG-4031]")
{
STATIC_REQUIRE(std::is_nothrow_default_constructible_v<test_bad_expected_access>);
STATIC_REQUIRE(std::is_nothrow_copy_constructible_v<test_bad_expected_access>);
STATIC_REQUIRE(std::is_nothrow_move_constructible_v<test_bad_expected_access>);
STATIC_REQUIRE(std::is_nothrow_copy_assignable_v<test_bad_expected_access>);
STATIC_REQUIRE(std::is_nothrow_move_assignable_v<test_bad_expected_access>);
STATIC_REQUIRE(std::is_nothrow_destructible_v<test_bad_expected_access>);
}
Loading