std::expected<T,E>::value
From cppreference.com
constexpr T& value() &; |
(1) | (since C++23) |
constexpr const T& value() const&; |
(2) | (since C++23) |
constexpr T&& value() &&; |
(3) | (since C++23) |
constexpr const T&& value() const&&; |
(4) | (since C++23) |
1,2) If *this contains an expected value, returns the expected value (by copy), or nothing if
T
is (possibly cv-qualified) void. Otherwise, throws std::bad_expected_access containing the unexpected value contained in *this.
If std::is_copy_constructible_v<E> is false, the program is ill-formed.
3,4) If *this contains an expected value, returns the expected value (by moving), or nothing if
T
is (possibly cv-qualified) void. Otherwise, throws std::bad_expected_access containing the unexpected value contained in *this.
If std::is_copy_constructible_v<E> or std::is_constructible_v<E, decltype(std::move(error()))> is false, the program is ill-formed.
Contents |
[edit] Parameters
(none)
[edit] Return value
1-4) The expected value contained in *this.
[edit] Exceptions
3,4) Throws std::bad_expected_access(std::move(error())) if *this contain an unexpected value.
[edit] Example
This section is incomplete Reason: no example |
[edit] See also
(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) |