Files
2025-10-25 03:02:53 +03:00

2.5 KiB

[optional.ref.observe]

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;

1

#

Hardened preconditions: has_value() is true.

2

#

Returns: val.

🔗

constexpr T& operator*() const noexcept;

3

#

Hardened preconditions: has_value() is true.

4

#

Returns: *val.

🔗

constexpr explicit operator bool() const noexcept;

5

#

Returns: val != nullptr.

🔗

constexpr bool has_value() const noexcept;

6

#

Returns: val != nullptr.

🔗

constexpr T& value() const;

7

#

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;

8

#

Let X be remove_cv_t.

9

#

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

10

#

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