Skip to content

Commit 5bc9e93

Browse files
Implement LWG-4222 expected constructor from a single value missing a constraint (#5602)
1 parent 4525436 commit 5bc9e93

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

stl/inc/expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ public:
306306

307307
template <class _Uty = remove_cv_t<_Ty>>
308308
requires (!is_same_v<remove_cvref_t<_Uty>, in_place_t> && !is_same_v<remove_cvref_t<_Uty>, expected>
309+
&& !is_same_v<remove_cvref_t<_Uty>, unexpect_t>
309310
&& !_Is_specialization_v<remove_cvref_t<_Uty>, unexpected>
310311
&& (!is_same_v<remove_cv_t<_Ty>, bool>
311312
#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10655311

tests/std/tests/P0323R12_expected/test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,6 +2509,21 @@ static_assert(!is_assignable_v<expected<void, move_only>&, ambiguating_expected_
25092509

25102510
static_assert(test_lwg_3886());
25112511

2512+
// Test LWG-4222 "expected constructor from a single value missing a constraint"
2513+
2514+
struct ConstructibleFromEverything {
2515+
explicit ConstructibleFromEverything(auto);
2516+
};
2517+
2518+
struct ConvertibleFromInt {
2519+
ConvertibleFromInt(int);
2520+
};
2521+
2522+
static_assert(!is_constructible_v<expected<ConstructibleFromEverything, ConvertibleFromInt>, unexpect_t&>);
2523+
static_assert(!is_constructible_v<expected<ConstructibleFromEverything, ConvertibleFromInt>, const unexpect_t&>);
2524+
static_assert(!is_constructible_v<expected<ConstructibleFromEverything, ConvertibleFromInt>, unexpect_t>);
2525+
static_assert(!is_constructible_v<expected<ConstructibleFromEverything, ConvertibleFromInt>, const unexpect_t>);
2526+
25122527
int main() {
25132528
test_unexpected::test_all();
25142529
static_assert(test_unexpected::test_all());

0 commit comments

Comments
 (0)