This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
[Applied to WP at the February, 2014 meeting.]
The access of the non-static data member corresponding to an init-capture is not specified. The question would be moot if the member were unnamed like the other non-static data members of the closure class.
Proposed resolution (September, 2013):
For every init-capture a non-static data member named by the identifier of the init-capture is declared in the closure type. This member is not a bit-field and not mutable. The type of that member corresponds to the type of a hypotheticalAn init-capture behaves as if it declares and explicitly captures a variabledeclarationof the form “auto init-capture ;” whose declarative region is the lambda-expression's compound-statement, except thatthe variable name (i.e., the identifier of the init-capture) is replaced by a unique identifier.:
if the capture is by copy (see below), the non-static data member declared for the capture and the variable are treated as two different ways of referring to the same object, which has the lifetime of the non-static data member, and no additional copy and destruction is performed, and
if the capture is by reference, the variable's lifetime ends when the closure object's lifetime ends.
[Note: This enables an init-capture like “x = std::move(x)”; the second “x” must bind to a declaration in the surrounding context. —end note]
No entity is captured by an init-capture. Within the lambda-expressions lambda-declarator and compound-statement, the identifier in the init-capture hides any declaration of the same name in scopes enclosing the lambda-expression.[Example:...
Change 7.5.6 [expr.prim.lambda] paragraph 15 as follows:
An entity is captured by copy if it is implicitly captured and the capture-default is = or if it is explicitly captured with a capture thatdoes not include an &is not of the form & identifier or & identifier initializer. For each entity...
Change 7.5.6 [expr.prim.lambda] paragraph 18 as follows:
Every id-expression within the compound-statement of a lambda-expression that is an odr-use (6.3 [basic.def.odr]) of an entity captured by copy is transformed into an access to the corresponding unnamed data member of the closure type. [Note:...
This resolution also resolves issue 1681.