C++ Logo

std-proposals

Advanced search

Re: [std-proposals] return if

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 13 Jan 2026 22:41:04 +0000
On Tue, Jan 13, 2026 at 6:06 PM Ville Voutilainen
<ville.voutilainen_at_[hidden]> wrote:
> >
> > Anyway it would be more readable as:
> >
> > return false if SomeFunction();
> >
> > In this context the 'false' really means 'inverted'. I don't know if that would bug people too much.
>
> That quite clearly should mean that the function returns false if
> SomeFunction() returns true, not that there's some
> inversion of SomeFunction's return value going on.


I deeply fear that I'll be lambasted for suggesting this . . . but how about:

    return ! if SomeFunction();

which would become:

    if ( decltype(auto) x = SomeFunction() ) return !x;

So just just to be crystal clear about what I'm proposing, here's the
ordinary one:

    return if SomeFunction() => if ( decltype(auto) x =
SomeFunction() ) return x;

And here's the inverted one:

    return ! if SomeFunction() => if ( decltype(auto) x =
SomeFunction() ) return !x;

Received on 2026-01-13 22:40:05