C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 12 May 2025 20:39:58 +0100
On Monday, May 12, 2025, Tymi via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> I think pointer == bool should be permitted
> For instance
> `if (myPointer == false) throw nullptr;`
>
> Tymi.
>



Sort of half-related to this, I don't think that function pointers should
implicitly convert to bool. I chased a bug recently:

    assert( wxIsMainThread );

which should have been:

    assert( wxIsMainThread() );

I would be in favour of the deprecation of implicit conversion of a
function pointer to bool -- although maybe that would break too much code.

Received on 2025-05-12 19:40:13