Date: Tue, 13 Jan 2026 15:20:02 +0000
On Tuesday, January 13, 2026, Thiago Macieira wrote:
>
>
> Then:
>
> if (auto x = SomeFunction) return !x;
>
I'm assuming you meant SomeFunction().
SomeFunction could return an Lvalue, a PRvalue, or an Xvalue, for example:
mutex SomeFunction(void);
mutex &SomeFunction(void);
mutex &&SomeFunction(void);
This is why we need:
decltype(SomeFunction) x = SomeFunction();
if ( x ) return !x;
And so the problem is that you need to type out the expression twice, give
the variable a non-clashing name, and mention the variable's name twice as
well.
Much easier to mention the function only once and to not mention the
variable at all.
>
>
> Then:
>
> if (auto x = SomeFunction) return !x;
>
I'm assuming you meant SomeFunction().
SomeFunction could return an Lvalue, a PRvalue, or an Xvalue, for example:
mutex SomeFunction(void);
mutex &SomeFunction(void);
mutex &&SomeFunction(void);
This is why we need:
decltype(SomeFunction) x = SomeFunction();
if ( x ) return !x;
And so the problem is that you need to type out the expression twice, give
the variable a non-clashing name, and mention the variable's name twice as
well.
Much easier to mention the function only once and to not mention the
variable at all.
Received on 2026-01-13 15:20:06
