std::expected<T,E>::value
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Utilities library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
Relational operators (deprecated in C++20) Integer comparison functions  
 
 
 
 Swap and type operations  Common vocabulary types 
 Type support (basic types, RTTI)
 Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
 Coroutine support (C++20)
 Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
  (C++20)(C++20)(C++20)
  (C++20)(C++20)(C++20)
 General utilities
(C++20)(C++20)(C++20)
  (C++20)(C++20)(C++20)
(C++20)
std::expected 
 
expected::value
Primary template
 
 
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) 
void partial specialization
 
 
constexpr void value() const&;
 (5) 
 (since C++23) 
constexpr void value() &&;
 (6) 
 (since C++23) 
If *this contains an expected value, returns a reference to the contained value. Returns nothing for void partial specialization.
Otherwise, throws an exception of type std::bad_expected_access <std::decay_t <E>> that contains a copy of error().
3,4) If std::is_copy_constructible_v <E> or std::is_constructible_v <E, decltype(std::move(error()))> is false, the program is ill-formed.
[edit] Return value
1,2) 
val 3,4) std::move(
val)[edit] Exceptions
1,2,5) Throws std::bad_expected_access (std::as_const (error())) if *this contains an unexpected value.
[edit] Example
 This section is incomplete
Reason: no example
Reason: no example
[edit] Defect reports
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 | Ewas not required to be copy/move-constructible for overloads (5,6) | required | 
[edit] See also
(C++23)
expected that contains an unexpected value (class template) [edit]