C++ Logo

std-proposals

Advanced search

Re: [std-proposals] comparison between pointers and bool

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Mon, 12 May 2025 15:34:31 +0100
On Mon, 12 May 2025 at 15:21, Tymi via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I think pointer == bool should be permitted
> For instance
> `if (myPointer == false) throw nullptr;`


This goes in the opposite direction from improvements made since
C++98, which permitted pointers to be initialized with any integral
constant (including false). Now we only allow literal zero as a null
pointer constant, not any constant with value zero.

I don't see any reason to treat false as a pointer value.

Received on 2025-05-12 14:34:47