If *this
contains an expected value, returns an reference to the contained value. Returns nothing if T
is (possibly cv-qualified) void.
Otherwise, throws an exception of type std::bad_expected_access<std::decay_t<E>>
that contains a copy of error()
.
std::is_copy_constructible_v<E>
or std::is_constructible_v<E, decltype(std::move(error()))>
is false
, the program is ill-formed.(none).
*this
.std::bad_expected_access(std::as_const(error()))
if *this
contains an unexpected value.std::bad_expected_access(std::move(error()))
if *this
contains an unexpected value.
(C++23) | returns the expected value if present, another value otherwise (public member function) |
(C++23) | accesses the expected value (public member function) |
(C++23) | returns the unexpected value (public member function) |
(C++23) | exception indicating checked access to an expected that contains an unexpected value (class template) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/utility/expected/value