std::nullopt_t
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Utilities library
Type support (basic types, RTTI)
Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
Coroutine support (C++20)
Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Relational operators (deprecated in C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
(C++20)
Swap and type operations
Common vocabulary types
std::optional
(C++26)
(C++26)
(C++23)
(C++23)
(C++23)
nullopt_t
Defined in header
<optional>
struct nullopt_t;
(since C++17)
std::nullopt_t
is an empty class type used to indicate that an std::optional does not contain a value.
std::nullopt_t
is a non-aggregate LiteralType that has no default constructor, no initializer-list constructor, but does have a constexpr
constructor that takes an implementation-defined literal type.
[edit] Notes
The constraints on nullopt_t
's constructors exist 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 explicit nullopt_t(int) {} };