Date: Tue, 13 Jan 2026 14:34:51 +0000
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;
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.
>
> 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;
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.
Received on 2026-01-13 14:35:05
