Namespaces
Variants
Actions

std::nullopt_t

From cppreference.com
< cpp‎ | utility‎ | optional
 
C++
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
std::optional
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) {}
};

[edit] See also

(C++17)
an object of type nullopt_t
(constant) [edit]

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant