22 General utilities library [utilities]
constexpr const T* operator->() const noexcept;
constexpr T* operator->() noexcept;
Preconditions:
has_value() is
true. constexpr const T& operator*() const & noexcept;
constexpr T& operator*() & noexcept;
Preconditions:
has_value() is
true. constexpr T&& operator*() && noexcept;
constexpr const T&& operator*() const && noexcept;
Preconditions:
has_value() is
true. Returns:
std::move(val). constexpr explicit operator bool() const noexcept;
constexpr bool has_value() const noexcept;
constexpr const T& value() const &;
constexpr T& value() &;
Mandates:
is_copy_constructible_v<E> is
true. Returns:
val, if
has_value() is
true. Throws:
bad_expected_access(as_const(error())) if
has_value() is
false. constexpr T&& value() &&;
constexpr const T&& value() const &&;
Mandates:
is_copy_constructible_v<E> is
true and
is_constructible_v<E, decltype(std::
move(error()))> is
true. Returns:
std::move(val), if
has_value() is
true. Throws:
bad_expected_access(std::move(error()))
if
has_value() is
false. constexpr const E& error() const & noexcept;
constexpr E& error() & noexcept;
Preconditions:
has_value() is
false. constexpr E&& error() && noexcept;
constexpr const E&& error() const && noexcept;
Preconditions:
has_value() is
false. Returns:
std::move(unex). template<class U> constexpr T value_or(U&& v) const &;
Mandates:
is_copy_constructible_v<T> is
true and
is_convertible_v<U, T> is
true. Returns:
has_value() ? **this : static_cast<T>(std::forward<U>(v)). template<class U> constexpr T value_or(U&& v) &&;
Mandates:
is_move_constructible_v<T> is
true and
is_convertible_v<U, T> is
true. Returns:
has_value() ? std::move(**this) : static_cast<T>(std::forward<U>(v)). template<class G = E> constexpr E error_or(G&& e) const &;
Mandates:
is_copy_constructible_v<E> is
true and
is_convertible_v<G, E> is
true. Returns:
std::forward<G>(e) if
has_value() is
true,
error() otherwise
. template<class G = E> constexpr E error_or(G&& e) &&;
Mandates:
is_move_constructible_v<E> is
true and
is_convertible_v<G, E> is
true. Returns:
std::forward<G>(e) if
has_value() is
true,
std::move(error()) otherwise
.