std::expected<T,E>::value_or
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_or
Primary template
 
 
template< class U = std::remove_cv_t <T> > 
constexpr T value_or( U&& default_value ) const&;
 (1) 
 (since C++23) 
constexpr T value_or( U&& default_value ) const&;
template< class U = std::remove_cv_t <T> > 
constexpr T value_or( U&& default_value ) &&;
 (2) 
 (since C++23) 
constexpr T value_or( U&& default_value ) &&;
Returns the expected value if it exists, otherwise returns default_value.
The void partial specialization does not have these member functions.
1) If std::is_copy_constructible_v <T> or std::is_convertible_v <U, T> is false, the program is ill-formed.
2) If std::is_move_constructible_v <T> or std::is_convertible_v <U, T> is false, the program is ill-formed.
[edit] Parameters
 default_value
 -
 the value to use in case *this does not contain an expected value
[edit] Return value
1) has_value() ? **this : static_cast<T>(std::forward <U>(default_value))
2) has_value() ? std::move(**this) : static_cast<T>(std::forward <U>(default_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 3886 | C++23 | Udoes not have a default template argument | specified |