23 General utilities library [utilities]
constexpr const T* operator->() const;
constexpr T* operator->();
Requires:
*this contains a value.
Remarks:
These functions shall be constexpr functions.
constexpr const T& operator*() const&;
constexpr T& operator*() &;
Requires:
*this contains a value.
Remarks:
These functions shall be constexpr functions.
constexpr T&& operator*() &&;
constexpr const T&& operator*() const&&;
Requires:
*this contains a value.
Effects:
Equivalent to: return std::move(*val);
constexpr explicit operator bool() const noexcept;
Returns:
true if and only if *this contains a value.
Remarks:
This function shall be a constexpr function.
constexpr bool has_value() const noexcept;
Returns: true if and only if *this contains a value.
Remarks: This function shall be a constexpr function.
constexpr const T& value() const&;
constexpr T& value() &;
Effects:
Equivalent to:
return bool(*this) ? *val : throw bad_optional_access();
constexpr T&& value() &&;
constexpr const T&& value() const&&;
Effects:
Equivalent to:
return bool(*this) ? std::move(*val) : throw bad_optional_access();
template <class U> constexpr T value_or(U&& v) const&;
Effects:
Equivalent to:
return bool(*this) ? **this : static_cast<T>(std::forward<U>(v));
Remarks:
If is_copy_constructible_v<T> && is_convertible_v<U&&, T> is false,
the program is ill-formed.
template <class U> constexpr T value_or(U&& v) &&;
Effects:
Equivalent to:
return bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v));
Remarks:
If is_move_constructible_v<T> && is_convertible_v<U&&, T> is false,
the program is ill-formed.