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 @@ -23,6 +23,7 @@ Implemented LWG Issues:
- [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
- [x] [LWG-4222](https://wg21.link/lwg4222) `expected` constructor from a single value missing a constraint

Enhancements:

Expand Down
3 changes: 2 additions & 1 deletion include/zeus/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ using enable_forward_t = std::enable_if_t<
!std::is_same_v<expected<T, E>, expected_detail::remove_cvref_t<U>> && //
!expected_detail::is_specialization_v<expected_detail::remove_cvref_t<U>, unexpected> && //
(!std::is_same_v<std::remove_cv_t<T>, bool> || // LWG-3836
!expected_detail::is_specialization_v<expected_detail::remove_cvref_t<U>, expected>) //
!expected_detail::is_specialization_v<expected_detail::remove_cvref_t<U>, expected>) && //
!std::is_same_v<expected_detail::remove_cvref_t<U>, unexpect_t> // LWG-4222
>;

template<class T, class E, class U, class G, class UF, class GF>
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 @@ -7,6 +7,7 @@ set(SOURCES
equality_tests.cpp
lwg_3886_tests.cpp
lwg_4031_tests.cpp
lwg_4222_tests.cpp
)

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

#include <zeus/expected.hpp>

using namespace zeus;

namespace
{

struct ConstructibleFromUnexpect
{
ConstructibleFromUnexpect() = default;
explicit ConstructibleFromUnexpect([[maybe_unused]] unexpect_t ut) {}
};

} // namespace

TEST_CASE("expected<T, E>(unexpect) is not ambiguous when T is constructible from unexpect_t", "[LWG-4222]")
{
expected<ConstructibleFromUnexpect, int> e(unexpect);
CHECK_FALSE(e.has_value());
CHECK(e.error() == int {});
}

TEST_CASE("expected<T, E>(unexpect, args) still works when T is constructible from unexpect_t", "[LWG-4222]")
{
expected<ConstructibleFromUnexpect, int> e(unexpect, 42);
CHECK_FALSE(e.has_value());
CHECK(e.error() == 42);
}
Loading