If naming the entity from outside of an unevaluated operand within
S
would refer to an entity
captured by copy in some intervening
lambda-expression,
then let
E be the innermost such
lambda-expression. If there is such a
lambda-expression and
if
P is in
E's function parameter scope
but not its
parameter-declaration-clause, then
the type of the expression is
the type of a class member access expression (
[expr.ref])
naming the non-static data member
that would be declared for such a capture
in the object parameter (
[dcl.fct]) of the function call operator of
E. [
Note 3:
If
E is not declared
mutable,
the type of such an identifier will typically be
const qualified
. —
end note]
If the entity is a template parameter object for
a template parameter of type
T (
[temp.param]),
the type of the expression is
const T. In all other cases, the type of the expression is the type of the entity
. [
Note 4:
The type will be adjusted as described in
[expr.type]
if it is cv-qualified or is a reference type
. —
end note]
The expression is an xvalue if it is move-eligible (see below);
an lvalue
if the entity is a function, variable,
structured binding, data member, or
template parameter object;
and a prvalue otherwise (
[basic.lval]);
it is a bit-field if the identifier designates a bit-field
. [
Example 1:
void f() {
float x, &r = x;
[=]() -> decltype((x)) {
decltype(x) y1;
decltype((x)) y2 = y1;
decltype(r) r1 = y1;
decltype((r)) r2 = y2;
return y2;
};
[=](decltype((x)) y) {
decltype((x)) z = x;
};
[=] {
[](decltype((x)) y) {};
[x=1](decltype((x)) y) {
decltype((x)) z = x;
};
};
}
—
end example]