constexpr optional() noexcept;
constexpr optional(nullopt_t) noexcept;
constexpr optional(const optional& rhs);
constexpr optional(optional&& rhs) noexcept(see below);
template<class... Args> constexpr explicit optional(in_place_t, Args&&... args);
template<class U, class... Args>
constexpr explicit optional(in_place_t, initializer_list<U> il, Args&&... args);
template<class U = T> constexpr explicit(see below) optional(U&& v);
template<class U> constexpr explicit(see below) optional(const optional<U>& rhs);
template<class U> constexpr explicit(see below) optional(optional<U>&& rhs);
constexpr ~optional();
constexpr optional<T>& operator=(nullopt_t) noexcept;
constexpr optional<T>& operator=(const optional& rhs);
*this contains a value | *this does not contain a value | |||
rhs contains a value | assigns *rhs to the contained value | direct-non-list-initializes the contained value with *rhs | ||
rhs does not contain a value | destroys the contained value by calling val->T::~T() | no effect |
constexpr optional& operator=(optional&& rhs) noexcept(see below);
*this contains a value | *this does not contain a value | |||
rhs contains a value | assigns std::move(*rhs) to the contained value | direct-non-list-initializes the contained value with std::move(*rhs) | ||
rhs does not contain a value | destroys the contained value by calling val->T::~T() | no effect |
template<class U = T> constexpr optional<T>& operator=(U&& v);
template<class U> constexpr optional<T>& operator=(const optional<U>& rhs);
*this contains a value | *this does not contain a value | |||
rhs contains a value | assigns *rhs to the contained value | direct-non-list-initializes the contained value with *rhs | ||
rhs does not contain a value | destroys the contained value by calling val->T::~T() | no effect |
template<class U> constexpr optional<T>& operator=(optional<U>&& rhs);
*this contains a value | *this does not contain a value | |||
rhs contains a value | assigns std::move(*rhs) to the contained value | direct-non-list-initializes the contained value with std::move(*rhs) | ||
rhs does not contain a value | destroys the contained value by calling val->T::~T() | no effect |
template<class... Args> constexpr T& emplace(Args&&... args);
template<class U, class... Args> constexpr T& emplace(initializer_list<U> il, Args&&... args);
constexpr void swap(optional& rhs) noexcept(see below);
*this contains a value | *this does not contain a value | |||
rhs contains a value | calls swap(*(*this), *rhs) | direct-non-list-initializes the contained value of *this
with std::move(*rhs),
followed by rhs.val->T::~T();
postcondition is that *this contains a value and rhs does not contain a value | ||
rhs does not contain a value | direct-non-list-initializes the contained value of rhs
with std::move(*(*this)),
followed by val->T::~T();
postcondition is that *this does not contain a value and rhs contains a value | no effect |
constexpr const T* operator->() const noexcept;
constexpr T* operator->() noexcept;
constexpr const T& operator*() const & noexcept;
constexpr T& operator*() & noexcept;
constexpr T&& operator*() && noexcept;
constexpr const T&& operator*() const && noexcept;
constexpr explicit operator bool() const noexcept;
constexpr bool has_value() const noexcept;
constexpr const T& value() const &;
constexpr T& value() &;
constexpr T&& value() &&;
constexpr const T&& value() const &&;
template<class U> constexpr T value_or(U&& v) const &;
template<class U> constexpr T value_or(U&& v) &&;
template<class F> constexpr auto and_then(F&& f) &;
template<class F> constexpr auto and_then(F&& f) const &;
template<class F> constexpr auto and_then(F&& f) &&;
template<class F> constexpr auto and_then(F&& f) const &&;
template<class F> constexpr auto transform(F&& f) &;
template<class F> constexpr auto transform(F&& f) const &;
template<class F> constexpr auto transform(F&& f) &&;
template<class F> constexpr auto transform(F&& f) const &&;
template<class F> constexpr optional or_else(F&& f) const &;
template<class F> constexpr optional or_else(F&& f) &&;
struct nullopt_t{see below};
inline constexpr nullopt_t nullopt(unspecified);
const char* what() const noexcept override;
template<class T, class U> constexpr bool operator==(const optional<T>& x, const optional<U>& y);
template<class T, class U> constexpr bool operator!=(const optional<T>& x, const optional<U>& y);
template<class T, class U> constexpr bool operator<(const optional<T>& x, const optional<U>& y);
template<class T, class U> constexpr bool operator>(const optional<T>& x, const optional<U>& y);
template<class T, class U> constexpr bool operator<=(const optional<T>& x, const optional<U>& y);
template<class T, class U> constexpr bool operator>=(const optional<T>& x, const optional<U>& y);
template<class T, three_way_comparable_with<T> U>
constexpr compare_three_way_result_t<T, U>
operator<=>(const optional<T>& x, const optional<U>& y);
template<class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept;
template<class T> constexpr strong_ordering operator<=>(const optional<T>& x, nullopt_t) noexcept;
template<class T, class U> constexpr bool operator==(const optional<T>& x, const U& v);
template<class T, class U> constexpr bool operator==(const T& v, const optional<U>& x);
template<class T, class U> constexpr bool operator!=(const optional<T>& x, const U& v);
template<class T, class U> constexpr bool operator!=(const T& v, const optional<U>& x);
template<class T, class U> constexpr bool operator<(const optional<T>& x, const U& v);
template<class T, class U> constexpr bool operator<(const T& v, const optional<U>& x);
template<class T, class U> constexpr bool operator>(const optional<T>& x, const U& v);
template<class T, class U> constexpr bool operator>(const T& v, const optional<U>& x);
template<class T, class U> constexpr bool operator<=(const optional<T>& x, const U& v);
template<class T, class U> constexpr bool operator<=(const T& v, const optional<U>& x);
template<class T, class U> constexpr bool operator>=(const optional<T>& x, const U& v);
template<class T, class U> constexpr bool operator>=(const T& v, const optional<U>& x);
template<class T, class U>
requires (!is-derived-from-optional<U>) && three_way_comparable_with<T, U>
constexpr compare_three_way_result_t<T, U>
operator<=>(const optional<T>& x, const U& v);
template<class T>
constexpr void swap(optional<T>& x, optional<T>& y) noexcept(noexcept(x.swap(y)));
template<class T> constexpr optional<decay_t<T>> make_optional(T&& v);
template<class T, class...Args>
constexpr optional<T> make_optional(Args&&... args);
template<class T, class U, class... Args>
constexpr optional<T> make_optional(initializer_list<U> il, Args&&... args);
template<class T> struct hash<optional<T>>;