C++ Logo

std-proposals

Advanced search

Re: What happened on "Null safety" in p0946r0 about p <=> nullptr

From: Kazutoshi Satoda <k_satoda_at_[hidden]>
Date: Thu, 5 Dec 2019 19:51:09 +0900
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.

-- 
k_satoda

Received on 2019-12-05 04:53:42