Experimental library header <experimental/optional> - cppreference.com (original) (raw)

This header is part of the Library Fundamentals TS (v1, v2).

Contents

[edit] Classes

Name Description
optional(library fundamentals TS) a wrapper that may or may not hold an object (class template) [edit]
bad_optional_access(library fundamentals TS) exception indicating checked access to an optional that doesn't contain a value (class) [edit]
in_place_t(library fundamentals TS) disambiguation tag type for in-place construction of optional types (class) [edit]
std::hashstd::experimental::optional specializes the std::hash algorithm (class template specialization) [edit]
nullopt_t(library fundamentals TS) indicator of optional type with uninitialized state (class) [edit]

[edit] Functions

Comparison
operator==operator!=operator<operator<=operator>operator>= compares optional objects (function template) [edit]
Specialized algorithms
std::swap(std::experimental::optional) specializes the std::swap algorithm (function) [edit]
make_optional creates an optional object (function template) [edit]
Hash support

[edit] Synopsis

namespace std { namespace experimental { inline namespace fundamentals_v1 {   // 5.4, optional for object types template class optional;   // 5.5, In-place construction struct in_place_t{}; constexpr in_place_t in_place{};   // 5.6, Disengaged state indicator struct nullopt_t{see below}; constexpr nullopt_t nullopt(unspecified);   // 5.7, Class bad_optional_access class bad_optional_access;   // 5.8, Relational operators template constexpr bool operator==(const optional&, const optional&); template constexpr bool operator!=(const optional&, const optional&); template constexpr bool operator<(const optional&, const optional&); template constexpr bool operator>(const optional&, const optional&); template constexpr bool operator<=(const optional&, const optional&); template constexpr bool operator>=(const optional&, const optional&);   // 5.9, Comparison with nullopt template constexpr bool operator==(const optional&, nullopt_t) noexcept; template constexpr bool operator==(nullopt_t, const optional&) noexcept; template constexpr bool operator!=(const optional&, nullopt_t) noexcept; template constexpr bool operator!=(nullopt_t, const optional&) noexcept; template constexpr bool operator<(const optional&, nullopt_t) noexcept; template constexpr bool operator<(nullopt_t, const optional&) noexcept; template constexpr bool operator<=(const optional&, nullopt_t) noexcept; template constexpr bool operator<=(nullopt_t, const optional&) noexcept; template constexpr bool operator>(const optional&, nullopt_t) noexcept; template constexpr bool operator>(nullopt_t, const optional&) noexcept; template constexpr bool operator>=(const optional&, nullopt_t) noexcept; template constexpr bool operator>=(nullopt_t, const optional&) noexcept;   // 5.10, Comparison with T template constexpr bool operator==(const optional&, const T&); template constexpr bool operator==(const T&, const optional&); template constexpr bool operator!=(const optional&, const T&); template constexpr bool operator!=(const T&, const optional&); template constexpr bool operator<(const optional&, const T&); template constexpr bool operator<(const T&, const optional&); template constexpr bool operator<=(const optional&, const T&); template constexpr bool operator<=(const T&, const optional&); template constexpr bool operator>(const optional&, const T&); template constexpr bool operator>(const T&, const optional&); template constexpr bool operator>=(const optional&, const T&); template constexpr bool operator>=(const T&, const optional&);   // 5.11, Specialized algorithms template void swap(optional&, optional&) noexcept(see below); template constexpr optional make_optional(T&&);   } // namespace fundamentals_v1 } // namespace experimental   // 5.12, Hash support template struct hash; template struct hash<experimental::optional>;   } // namespace std