[optional.ref.observe] (original) (raw)

22 General utilities library [utilities]

22.5 Optional objects [optional]

22.5.4 Partial specialization of optional for reference types [optional.optional.ref]

22.5.4.6 Observers [optional.ref.observe]

constexpr T* operator->() const noexcept;

Hardened preconditions: has_value() is true.

constexpr T& operator*() const noexcept;

Hardened preconditions: has_value() is true.

constexpr explicit operator bool() const noexcept;

constexpr bool has_value() const noexcept;

constexpr T& value() const;

Effects: Equivalent to:return has_value() ? *val : throw bad_optional_access();

template<class U = remove_cv_t<T>> constexpr remove_cv_t<T> value_or(U&& u) const;

Mandates: is_constructible_v<X, T&> && is_convertible_v<U, X> is true.

Effects: Equivalent to:return has_value() ? *val : static_cast<X>(std::forward<U>(u));