C++ Logo


Advanced search

Subject: Re: [std-proposals] What happened on "Null safety" in p0946r0 about p <=> nullptr
From: Kazutoshi Satoda (k_satoda_at_[hidden])
Date: 2019-12-05 04:51:09

On 2019/12/05 18:55 +0900, Jake Arkinstall via Std-Proposals wrote:
> Out of pure interest, what is the problem in returning a strong ordering
> with nullptr always being less than p, unless p is a nullptr too, in which
> case the result would be equality?

If it can be used only for equality, expressing it with
equality operators (==, !=) will be always better. Equality operators
express the meaning clearer, shorter, and don't need #include <compare>.

> As nullptr is implicitly convertible to any pointer, that's the outcome
> that one might expect.

It is inconsistent with other relational operators (like p < nullptr,
which is ill-formed).

> But if not, then ill formed is infinitely better than unspecified IMO.


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups