home | help
std::expected::value_or(3)     C++ Standard Libary    std::expected::value_or(3)

NAME
     std::expected::value_or - std::expected::value_or

Synopsis
	template< class U >				  (1) (since C++23)
	constexpr T value_or( U&& default_value ) const&;
	template< class U >				  (2) (since C++23)
	constexpr T value_or( U&& default_value ) &&;

	Returns  the contained value if *this contains an expected value, other-
     wise returns
	default_value.

	1) Returns bool(*this)	?  **this  :  static_cast<T>(std::forward<U>(de-
     fault_value))
	2) Returns bool(*this) ? std::move(**this) :
	static_cast<T>(std::forward<U>(default_value))

Parameters
	default_value  -  the value to use in case *this does not contain an ex-
     pected value

Type requirements
	-
	T must meet the requirements of CopyConstructible in order to use  over-
     load (1).
	-
	T  must meet the requirements of MoveConstructible in order to use over-
     load (2).
	-
	U&& must be convertible to T

Return value
	The currently contained value if *this contains an  expected  value,  or
     default_value
	otherwise.

Exceptions
	Any exception thrown by the selected constructor of the return value T.

Notes
	If T is (possibly cv-qualified) void, this member is not declared.

Example
	 This section is incomplete
	 Reason: no example

See also
	value returns the expected value
	      (public member function)

Category:
	  * Todo no example

http://cppreference.com 	   2024.06.10	      std::expected::value_or(3)

home | help