std:: nullopt_t
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Observers | ||||
| Iterators | ||||
|
(C++26)
|
||||
|
(C++26)
|
||||
| Monadic operations | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Modifiers | ||||
| Non-member functions | ||||
| Deduction guides | ||||
| Helper classes | ||||
|
nullopt_t
|
||||
| Helper objects | ||||
|
定义于头文件
<optional>
|
||
|
struct
nullopt_t
;
|
(C++17 起) | |
std::nullopt_t
是一个空类类型,用于指示
std::optional
不包含值。
std::nullopt_t
是一种非聚合的
LiteralType
,它没有默认构造函数,没有初始化列表构造函数,但具有一个接受实现定义的字面类型的
constexpr
构造函数。
注释
对
nullopt_t
构造函数的约束旨在同时支持
op
=
{
}
;
和
op
=
nullopt
;
这两种语法来解除可选对象的关联状态。
该类的一种可能实现是
struct nullopt_t { constexpr explicit nullopt_t(int) {} };
参阅
|
(C++17)
|
nullopt_t
类型的对象
(常量) |