std::nullopt_t
From cppreference.com
| Defined in header
<optional>
|
||
| struct nullopt_t;
|
(since C++17) | |
std::nullopt_t is an empty class type used to indicate optional type with uninitialized state. In particular, std::optional has a constructor with nullopt_t as a single argument, which creates an optional that does not contain a value.
std::nullopt_t must be a LiteralType and cannot have a default constructor.
It must have a constexpr constructor that takes some implementation-defined literal type.
[edit] Notes
nullopt_t is not DefaultConstructible to support both op = {}; and op = nullopt; as the syntax for disengaging an optional object.
A possible implementation of this class is
struct nullopt_t { constexpr nullopt_t(int) {} };
[edit] See also
| (C++17)
|
an object of type nullopt_t (constant) |