C++ Language/Type/Variant/OptionalValue
Appearance
A variable whose type is std::optional<int>
is similar to a pointer to int
in the sense that its value might be std::nullopt
(similar to a null pointer).
In that case, we understand it to semantically mean that the variable "has no meaningful value".
Otherwise, an int
can be stored by assignment, and accessed by dereferencing.
Additional information about optional-value (includes interactive examples)