Namespaces
Variants

Experimental library header <experimental/optional>

From cppreference.net
Standard library headers
Experimental library headers
Execution P2300
<experimental/execution>
Filesystem TS
<experimental/filesystem>
Parallelism TS (v1, v2)
experimental/algorithm
experimental/execution_policy
experimental/exception_list
experimental/numeric
<experimental/simd>
experimental/task_block
Library Fundamentals TS (v1, v2, v3)
experimental/algorithm
<experimental/any>
experimental/array
experimental/chrono
experimental/deque
experimental/forward_list
<experimental/functional>
experimental/future
experimental/iterator
experimental/list
experimental/map
experimental/memory
<experimental/memory_resource>
experimental/numeric
<experimental/optional>
experimental/propagate_const
experimental/random
experimental/ratio
experimental/regex
experimental/scope
experimental/set
experimental/source_location
experimental/string
<experimental/string_view>
experimental/system_error
experimental/tuple
experimental/type_traits
experimental/unordered_map
experimental/unordered_set
experimental/utility
experimental/vector

Concurrency TS
experimental/atomic
experimental/barrier
experimental/future
experimental/latch
Ranges TS
Coroutines TS
experimental/coroutine
Networking TS
experimental/buffer
experimental/executor
experimental/internet
experimental/io_context
<experimental/net>
experimental/netfwd
experimental/socket
experimental/timer
Reflection TS
<experimental/reflect>

此头文件是 Library Fundamentals TS 的组成部分( v1 v2 )。

目录

名称 描述
(library fundamentals TS)
可能持有或未持有对象的包装器
(类模板)
(library fundamentals TS)
指示对不包含值的 optional 进行受检访问时引发的异常
(类)
(library fundamentals TS)
用于 optional 类型原位构造的消歧标签类型
(类)
特化 std::hash 算法
(类模板特化)
(library fundamentals TS)
未初始化状态 optional 类型的指示符
(类)

函数

比较操作
比较 optional 对象
(函数模板)
特化算法
特化 std::swap 算法
(函数)
创建 optional 对象
(函数模板)
哈希支持

概要

namespace std {
  namespace experimental {
  inline namespace fundamentals_v1 {
    // 5.4,对象类型的 optional
    template <class T> class optional;
    // 5.5,就地构造
    struct in_place_t{};
    constexpr in_place_t in_place{};
    // 5.6,未 engaged 状态指示器
    struct nullopt_t{见下文};
    constexpr nullopt_t nullopt(未指定);
    // 5.7,类 bad_optional_access
    class bad_optional_access;
    // 5.8,关系运算符
    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>&);
    // 5.9,与 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;
    // 5.10,与 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!=