Date: Thu, 4 May 2023 16:37:41 -0700
Let's say you have this as a lambda:
int a = ...;
auto lambda = [x(int(a))]{ return x + 1 };
[expr.prim.lambda.capture]/6
<https://eel.is/c++draft/expr.prim.lambda.capture#6> says the following:
An *init-capture* inhabits the lambda scope ([basic.scope.lambda]) of the
*lambda-expression*.
<https://eel.is/c++draft/expr.prim.lambda.capture#6.sentence-1>
An *init-capture* without ellipsis behaves as if it declares and explicitly
captures a variable of the form “auto *init-capture* ;”, except that
*(...omitted...)*
The "auto init-capture ;" part seems wrong here, because the lambda above
would fall to the most vexing parse rule:
auto x(int(a)); // declares a function, not an int
I guess this could be an editorial-level issue? Clearly the Standard's
intent is that x would be interpreted as an int here, rather than be a very
weird application of the most vexing parse rule...?
Melissa
int a = ...;
auto lambda = [x(int(a))]{ return x + 1 };
[expr.prim.lambda.capture]/6
<https://eel.is/c++draft/expr.prim.lambda.capture#6> says the following:
An *init-capture* inhabits the lambda scope ([basic.scope.lambda]) of the
*lambda-expression*.
<https://eel.is/c++draft/expr.prim.lambda.capture#6.sentence-1>
An *init-capture* without ellipsis behaves as if it declares and explicitly
captures a variable of the form “auto *init-capture* ;”, except that
*(...omitted...)*
The "auto init-capture ;" part seems wrong here, because the lambda above
would fall to the most vexing parse rule:
auto x(int(a)); // declares a function, not an int
I guess this could be an editorial-level issue? Clearly the Standard's
intent is that x would be interpreted as an int here, rather than be a very
weird application of the most vexing parse rule...?
Melissa
Received on 2023-05-04 23:37:54