C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal: -Wverbose-style

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 16 Oct 2025 12:54:41 +0100
On Tue, Oct 14, 2025 at 6:21 PM Jerome Saint-Martin wrote:
>
> Just write `if (flag)`
> if (flag == true)


I think your post here is interesting though along the lines of being
able to specify an option/switch/flag to the compiler, because
currently the Standard doesn't allow for it, so perhaps consider
writing a proposal about having the compiler accept
options/switches/flags.

Just by the way, when I'm checking for 'true', I do:

    if ( flag )

And when I'm checking for 'false', I do:

    if ( false == flag )

because I like the verbosity. It's less easy to miss a "false ==" than a "!".

By the way, be careful with comparing things to 'true' because integer
promotion might screw you (as 'true' becomes 1), for example:

    int CheckFlag(void) { return 7; }

    int main(void) { return true == CheckFlag(); }

Received on 2025-10-16 11:54:54