命名空间
变体
操作

std::nullopt_t

来自 cppreference.cn
< cpp‎ | utility‎ | optional
 
 
 
 
定义于头文件 <optional>
struct nullopt_t;
(自 C++17 起)

std::nullopt_t 是一个空类类型,用于指示 std::optional 不含值。

std::nullopt_t 是非聚合 LiteralType,它无默认构造函数、无初始化列表构造函数,但的确拥有接受实现定义的字面量类型的 constexpr 构造函数。

[编辑] 注释

nullopt_t 的构造函数的约束存在,以同时支持 op = {};op = nullopt; 作为解离 optional 对象 (disengaging an optional object) 的语法。

此类的可能实现为

struct nullopt_t {
    constexpr explicit nullopt_t(int) {}
};

[编辑] 参见

(C++17)
nullopt_t 类型的对象
(常量) [编辑]