return ! if

 

could be also written as

 

    return not if

 

improving it perhaps or not.

 

 

but I don't think that applying the ! operator helps with your proposal acceptance.

 

next you continue with

 

    return transform if

 

calling a function transform(parameter)

 

I would concentrate on the 'return if' case first and foremost

 

and again, it has the same basic semantic as .try?

a conditional return. Except that .try? implicitly returns with some value and provides another value for the expression itself.

So return if is the simple case of .try? and .try? can provide its full functionality.

 

-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 13.01.2026 23:40
Betreff: Re: [std-proposals] return if
An: std-proposals <std-proposals@lists.isocpp.org>;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;
On Tue, Jan 13, 2026 at 6:06 PM Ville Voutilainen
<ville.voutilainen@gmail.com> 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;
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals