This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


1681. init-captures and nested lambdas

Section: 7.5.6.3  [expr.prim.lambda.capture]     Status: C++14     Submitter: Richard Smith     Date: 2013-05-14

[Applied to WP at the February, 2014 meeting.]

According to 7.5.6 [expr.prim.lambda] paragraph 10,

The identifier in a simple-capture is looked up using the usual rules for unqualified name lookup (6.5.3 [basic.lookup.unqual]); each such lookup shall find a variable with automatic storage duration declared in the reaching scope of the local lambda expression.

This does not permit a nested lambda to capture the non-static data member of the closure type introduced by an init-capture. A similar restriction applies to implicit capture in paragraph 12.

Presumably such captures should be allowed, capturing the non-static data member directly rather than the this pointer from the enclosing lambda's operator().

Proposed resolution (September, 2013):

This issue is resolved by the resolution of issue 1760.