- Title
- Name lookup in nested lambda-expressions
- Status
- cd2
- Section
- 7.5.6 [expr.prim.lambda]
- Submitter
- Daveed Vandevoorde
Created on 2008-12-10.00:00:00 last changed 199 months ago
Messages
Date: 2009-07-15.00:00:00
[Voted into the WP at the July, 2009 meeting as part of N2927.]
Date: 2009-07-15.00:00:00
Proposed resolution (July, 2009) See document PL22.16/09-0117 = WG21 N2927.
Date: 2026-07-27.15:54:01
N2800 comment
US 31 How does name binding work in nested lambda-expressions? For
example, According to 7.5.6 [expr.prim.lambda] paragraph 3, One possible interpretation is that the lambda expression in
f1 is ill-formed because v is used in the
compound-statement of the outer lambda expression but does not
appear in its effective capture set. However, the appearance of
v in the inner lambda-capture is not a
“use” in the sense of 6.3 [basic.def.odr] paragraph
2, because a lambda-capture is not an expression, and
it's not clear whether the reference in the inner lambda expression's
return expression should be considered a use of the automatic
variable or of the member of the inner lambda expression's closure
object. Similarly, the lambda expression in f2 could be deemed
to be ill-formed because the reference to v in the inner
lambda expression's lambda-capture would refer to the field
of the outer lambda-expression's closure object, not to a local
automatic variable; however, it's not clear whether the inner
lambda expression should be evaluated in situ or as part of
the generated operator() member of the outer lambda
expression's closure object.
void f1() {
float v;
[]() { return [v]() { return v; } }
}
void f2() {
float v;
[v]() { return [v]() { return v; } }
}
A name in the lambda-capture shall be in scope in the context
of the lambda expression, and shall be this or shall refer to
a local variable or reference with automatic storage duration.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2010-03-29 00:00:00 | admin | set | status: wp -> cd2 |
| 2009-11-08 00:00:00 | admin | set | status: dr -> wp |
| 2009-08-03 00:00:00 | admin | set | messages: + msg2232 |
| 2009-08-03 00:00:00 | admin | set | status: review -> dr |
| 2009-03-23 00:00:00 | admin | set | messages: + msg1898 |
| 2009-03-23 00:00:00 | admin | set | status: open -> review |
| 2008-12-10 00:00:00 | admin | create | |