diff options
-rw-r--r-- | libcxx/include/__expected/expected.h | 4 | ||||
-rw-r--r-- | libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.copy.pass.cpp | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/libcxx/include/__expected/expected.h b/libcxx/include/__expected/expected.h index 0f994e2..f618b20 100644 --- a/libcxx/include/__expected/expected.h +++ b/libcxx/include/__expected/expected.h @@ -507,7 +507,9 @@ private: _And< is_constructible<_Tp, _UfQual>, is_constructible<_Err, _OtherErrQual>, _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value, - _And< _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>, + _And< + _Not<_And<is_same<_Tp, _Up>, is_same<_Err, _OtherErr>>>, // use the copy constructor instead, see #92676 + _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>, _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>, _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>, _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>, diff --git a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.copy.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.copy.pass.cpp index 581df51..ba98317 100644 --- a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.copy.pass.cpp +++ b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.copy.pass.cpp @@ -62,6 +62,16 @@ static_assert(!std::is_trivially_copy_constructible_v<std::expected<CopyableNonT static_assert(!std::is_trivially_copy_constructible_v<std::expected<int, CopyableNonTrivial>>); static_assert(!std::is_trivially_copy_constructible_v<std::expected<CopyableNonTrivial, CopyableNonTrivial>>); +struct Any { + constexpr Any() = default; + constexpr Any(const Any&) = default; + constexpr Any& operator=(const Any&) = default; + + template <class T> + requires(!std::is_same_v<Any, std::decay_t<T>> && std::is_copy_constructible_v<std::decay_t<T>>) + constexpr Any(T&&) {} +}; + constexpr bool test() { // copy the value non-trivial { @@ -109,6 +119,16 @@ constexpr bool test() { assert(!e2.has_value()); } + { + // TODO(LLVM 20): Remove once we drop support for Clang 17 +#if defined(TEST_CLANG_VER) && TEST_CLANG_VER >= 1800 + // https://github.com/llvm/llvm-project/issues/92676 + std::expected<Any, int> e1; + auto e2 = e1; + assert(e2.has_value()); +#endif + } + return true; } |