|
|
Primary template | ||
constexpr T& value()&; | (1) | (since C++23) |
constexprconst T& value()const&; | (2) | (since C++23) |
constexpr T&& value()&&; | (3) | (since C++23) |
constexprconst T&& value()const&&; | (4) | (since C++23) |
void partial specialization | ||
constexprvoid value()const&; | (5) | (since C++23) |
constexprvoid value()&&; | (6) | (since C++23) |
If*this contains an expected value, returns a reference to the contained value. Returns nothing forvoid partial specialization.
Otherwise, throws an exception of typestd::bad_expected_access<std::decay_t<E>> that contains a copy oferror()
.
Contents |
val
val
)This section is incomplete Reason: no example |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3940 | C++23 | E was not required to be copy/move-constructible for overloads(5,6) | required |
returns the expected value if present, another value otherwise (public member function)[edit] | |
accesses the expected value (public member function)[edit] | |
returns the unexpected value (public member function)[edit] | |
(C++23) | exception indicating checked access to anexpected that contains an unexpected value(class template)[edit] |