This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See for the official list.


1632. Lambda capture in member initializers

Section:  [expr.prim.lambda.capture]     Status: CD5     Submitter: Vinny Romano     Date: 2013-03-04

[Accepted as a DR as part of paper P0588R1 at the October, 2017 meeting.]

According to 7.5.5 [expr.prim.lambda] paragraph 9,

A lambda-expression whose smallest enclosing scope is a block scope (6.4.3 [basic.scope.block]) is a local lambda expression; any other lambda-expression shall not have a capture-list in its lambda-introducer. The reaching scope of a local lambda expression is the set of enclosing scopes up to and including the innermost enclosing function and its parameters.

Consequently, lambdas appearing in mem-initializers and brace-or-equal-initializers cannot have a capture-list. However, these expressions are evaluated in the context of the constructor and are permitted to access this and non-static data members.

Should the definition of a local lambda be modified to permit capturing lambdas within these contexts?

Notes from the April, 2013 meeting:

CWG agreed with the intent of this issue.