Date: Tue, 13 Jan 2026 15:45:29 +0100
Hi Frederick,
On Tue, Jan 13, 2026 at 02:34:51PM +0000, Frederick Virchanza Gotham via Std-Proposals wrote:
> On Mon, Jan 12, 2026 at 5:17 PM Sebastian Wittmeier wrote:
> >
> > or even better
> >
> > return false if ();
>
>
> Yeah scrap my idea of "return if !".
>
> If you want to return the original value unchanged, then do:
>
> return if SomeFunction();
>
> And if you want to invert the value, then do:
>
> return false if SomeFunction();
>
> which would be equivalent to:
>
> decltype(SomeFunction()) x = SomeFunction();
> if ( static_cast<bool>(x) ) return !x;
Isn't this exactly the same as the following?
if (SomeFunction())
return false;
Have a lovely day!
Alex
> We could debate whether or not this should be permitted for types
> other than "void" and "bool" and pointers. I think it would be fine
> for integer types (i.e. return 'false' would be return zero). And as
> for user-defined types, well let the author of the class do what they
> want with their user-defined operator!.
>
> Yeah I think "return false if" is good.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
On Tue, Jan 13, 2026 at 02:34:51PM +0000, Frederick Virchanza Gotham via Std-Proposals wrote:
> On Mon, Jan 12, 2026 at 5:17 PM Sebastian Wittmeier wrote:
> >
> > or even better
> >
> > return false if ();
>
>
> Yeah scrap my idea of "return if !".
>
> If you want to return the original value unchanged, then do:
>
> return if SomeFunction();
>
> And if you want to invert the value, then do:
>
> return false if SomeFunction();
>
> which would be equivalent to:
>
> decltype(SomeFunction()) x = SomeFunction();
> if ( static_cast<bool>(x) ) return !x;
Isn't this exactly the same as the following?
if (SomeFunction())
return false;
Have a lovely day!
Alex
> We could debate whether or not this should be permitted for types
> other than "void" and "bool" and pointers. I think it would be fine
> for integer types (i.e. return 'false' would be return zero). And as
> for user-defined types, well let the author of the class do what they
> want with their user-defined operator!.
>
> Yeah I think "return false if" is good.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
-- <https://www.alejandro-colomar.es>
Received on 2026-01-13 14:45:37
