C++ Logo


Advanced search

Re: nullptr_t and nullopt_t should both have operator<=> and operator== to enable the *_with concepts

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Fri, 9 Jul 2021 20:57:41 +0300
On Fri, 9 Jul 2021 at 19:51, Nevin Liber via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> On Fri, Jul 9, 2021 at 10:23 AM Ville Voutilainen via Std-Proposals <std-proposals_at_[hidden]> wrote:
>> These tag types are not for general programming, they're for use as
>> constructor arguments.
> It is more than just that, as we have the full set of heterogeneous comparisons between optional<T> and nullopt_t, as well as smart_ptr<T, ...> and nullptr_t. It is inconsistent that they themselves don't have a full set of homogeneous comparisons, especially given how simple it is to define them.

Inconsistent it may be, sure, but making it consistent has a possible
semantic cost for programmers; if comparisons between two nullopts
have no practical uses, it's questionable whether they should be made
well-formed, because they can become something that papers
over logic errors in code.

Received on 2021-07-09 12:57:54