This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
std::nullopt_t should be comparableSection: 22.5.5 [optional.nullopt] Status: New Submitter: Barry Revzin Opened: 2025-12-21 Last modified: 2025-12-22
Priority: Not Prioritized
View other active issues in [optional.nullopt].
View all other issues in [optional.nullopt].
View all issues with New status.
Discussion:
std::nullopt_t currently has no comparison operators. This prevents perfectly reasonable code from working,
like ranges::find(v, nullopt) where v is a vector<optional<T>>, for no good reason.
optional<T> has the full set of comparisons. But optional<T> is
conceptually a variant<nullopt_t, T>, which wouldn't be comparable... because of nullopt_t.
Other empty types like tuple<> and monostate are also comparable.
Proposed resolution: Add a defaulted member operator<=> to nullopt_t.
Proposed resolution: