std::experimental::optional<T>::value_or
From cppreference.com
template< class U > constexpr T value_or( U&& value ) const&; |
(library fundamentals TS) | |
template< class U > T value_or( U&& value ) &&; |
(library fundamentals TS) | |
Returns the contained value if *this is in engaged state, otherwise returns value
.
Contents |
Parameters
value | - | the value to exchange |
Type requirements | ||
-U&& must be convertible to T
|
Return value
The current value if *this is in engaged state, or value
otherwise.
Exceptions
Any exception thrown by the selected constructor of T
.
If an exception is thrown, the exception safety guarantee is as follows:
- If *this was in engaged state, the contents of the contained value depend on the exception safety guarantee of
T
's constructor. - Otherwise, the state of *this does not change. The contents of
value
depend on the exception safety guarantee ofT
's constructor.
See also
returns the contained value (public member function) |