Standard library header <optional>
From cppreference.com
Contents |
[edit] Classes
Name | Description |
(C++17)
|
exception indicating checked access to an optional that doesn't contain a value (class) |
(C++17)
|
disambiguation tag type for in-place construction of optional types (class) |
(C++17)
|
specializes the std::hash algorithm (class template specialization) |
(C++17)
|
indicator of optional type with uninitialized state (class) |
[edit] Functions
Comparison |
|
compares optional objects (function template) |
|
Specialized algorithms |
|
(C++17)
|
specializes the std::swap algorithm (function) |
(C++17)
|
creates an optional object (function template) |
[edit] Synopsis
namespace std { template <class T> class optional; // In-place construction struct in_place_t{}; constexpr in_place_t in_place{}; // No-value state indicator struct nullopt_t{see below}; constexpr nullopt_t nullopt(unspecified); // Class bad_optional_access class bad_optional_access; // Relational operators template <class T> constexpr bool operator==(const optional<T>&, const optional<T>&); template <class T> constexpr bool operator!=(const optional<T>&, const optional<T>&); template <class T> constexpr bool operator<(const optional<T>&, const optional<T>&); template <class T> constexpr bool operator>(const optional<T>&, const optional<T>&); template <class T> constexpr bool operator<=(const optional<T>&, const optional<T>&); template <class T> constexpr bool operator>=(const optional<T>&, const optional<T>&); // Comparison with nullopt template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept; template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept; template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept; template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept; template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept; template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept; template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept; template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept; template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept; template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept; template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept; template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept; // Comparison with T template <class T> constexpr bool operator==(const optional<T>&, const T&); template <class T> constexpr bool operator==(const T&, const optional<T>&); template <class T> constexpr bool operator!=(const optional<T>&, const T&); template <class T> constexpr bool operator!=(const T&, const optional<T>&); template <class T> constexpr bool operator<(const optional<T>&, const T&); template <class T> constexpr bool operator<(const T&, const optional<T>&); template <class T> constexpr bool operator<=(const optional<T>&, const T&); template <class T> constexpr bool operator<=(const T&, const optional<T>&); template <class T> constexpr bool operator>(const optional<T>&, const T&); template <class T> constexpr bool operator>(const T&, const optional<T>&); template <class T> constexpr bool operator>=(const optional<T>&, const T&); template <class T> constexpr bool operator>=(const T&, const optional<T>&); //Specialized algorithms template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below); template <class T> constexpr optional<see below> make_optional(T&&); // Hash support template <class T> struct hash; template <class T> struct hash<experimental::optional<T>>; } // namespace std