8 Expressions [expr]

8.4 Primary expressions [expr.prim]

8.4.4 Names [expr.prim.id]

8.4.4.1 Unqualified names [expr.prim.id.unqual]

unqualified-id:
	identifier
	operator-function-id
	conversion-function-id
	literal-operator-id
	~ class-name
	~ decltype-specifier
	template-id
An identifier is an id-expression provided it has been suitably declared ([dcl.dcl]).
[Note
:
A class-name or decltype-specifier prefixed by ~ denotes a destructor; see [class.dtor].
Within the definition of a non-static member function, an identifier that names a non-static member is transformed to a class member access expression ([class.mfct.non-static]).
end note
]
The result is the entity denoted by the identifier.
If the entity is a local entity and naming it from outside of an unevaluated operand within the declarative region where the unqualified-id appears would result in some intervening lambda-expression capturing it by copy ([expr.prim.lambda.capture]), 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 closure object of the innermost such intervening lambda-expression.
[Note
:
If that lambda-expression is not declared mutable, the type of such an identifier will typically be const qualified.
end note
]
Otherwise, the type of the expression is the type of the result.
[Note
:
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 lvalue if the entity is a function, variable, or data member and a prvalue otherwise ([basic.lval]); it is a bit-field if the identifier designates a bit-field ([dcl.struct.bind]).
[Example
:
void f() {
  float x, &r = x;
  [=] {
    decltype(x) y1;             // y1 has type float
    decltype((x)) y2 = y1;      // y2 has type float const& because this lambda
                                // is not mutable and x is an lvalue
    decltype(r) r1 = y1;        // r1 has type float&
    decltype((r)) r2 = y2;      // r2 has type float const&
  };
}
end example
]