I don\'t understand the reasoning for the inclusion of std::nullopt_t in the standard. Does it exist strictly for convenience, or is it required in some niche c
C++ reference says it all:
std::nullopt_tis an empty class type used to indicateoptionaltype with uninitialized state. In particular,std::optionalhas a constructor withnullopt_tas a single argument, which creates anoptionalthat does not contain a value.
std::nullopt_t
nullopt_t is the type of nullopt which indicates disengaged optional state. nullopt allows disambiguating overloads such as (example from the optional proposal):
void run(complex<double> v); void run(optional<string> v); run(nullopt); // pick the second overload run({}); // ambiguous