Skip to content

Commit ff1b9f3

Browse files
committed
In which I learn about expected-error@.*
1 parent 5d99930 commit ff1b9f3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

libcxx/include/__expected/expected.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ class expected : private __expected_base<_Tp, _Err> {
845845
}
846846

847847
_LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& value() const&& {
848-
static_assert(bool(is_copy_constructible_v<_Err> && is_constructible_v<_Err, decltype(std::move(error()))>),
848+
static_assert(is_copy_constructible_v<_Err> && is_constructible_v<_Err, decltype(std::move(error()))>,
849849
"error_type has to be both copy constructible and constructible from decltype(std::move(error()))");
850850
if (!this->__has_val()) {
851851
std::__throw_bad_expected_access<_Err>(std::move(error()));
@@ -854,7 +854,7 @@ class expected : private __expected_base<_Tp, _Err> {
854854
}
855855

856856
_LIBCPP_HIDE_FROM_ABI constexpr _Tp&& value() && {
857-
static_assert(bool(is_copy_constructible_v<_Err> && is_constructible_v<_Err, decltype(std::move(error()))>),
857+
static_assert(is_copy_constructible_v<_Err> && is_constructible_v<_Err, decltype(std::move(error()))>,
858858
"error_type has to be both copy constructible and constructible from decltype(std::move(error()))");
859859
if (!this->__has_val()) {
860860
std::__throw_bad_expected_access<_Err>(std::move(error()));

libcxx/test/libcxx/utilities/expected/expected.expected/value.observers.verify.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ void test() {
9595
std::expected<int, CopyConstructibleButNotMoveConstructible> e;
9696
[[maybe_unused]] auto val = std::move(e).value();
9797
// expected-error-re@*:* {{static assertion failed {{.*}}error_type has to be both copy constructible and constructible from decltype(std::move(error()))}}
98+
// The following diagnostic is emmitted in expected.h:
99+
// expected-error@*:* {{call to deleted constructor of 'CopyConstructibleButNotMoveConstructible'}}
98100
}
99101
}
100102

@@ -118,6 +120,8 @@ void test() {
118120
const std::expected<int, CopyConstructibleButNotMoveConstructible> e;
119121
[[maybe_unused]] auto val = std::move(e).value();
120122
// expected-error-re@*:* {{static assertion failed {{.*}}error_type has to be both copy constructible and constructible from decltype(std::move(error()))}}
123+
// The following diagnostic is emmitted in expected.h:
124+
// expected-error@*:* {{call to deleted constructor of 'CopyConstructibleButNotMoveConstructible'}}
121125
}
122126
}
123127
// These diagnostics happen when we try to construct bad_expected_access from the non copy-constructible error type.

0 commit comments

Comments
 (0)