15 lines
915 B
Markdown
15 lines
915 B
Markdown
[depr.capture.this]
|
||
|
||
# Annex D (normative) Compatibility features [[depr]](./#depr)
|
||
|
||
## D.3 Implicit capture of *this by reference [depr.capture.this]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L41)
|
||
|
||
For compatibility with prior revisions of C++,
|
||
a [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]") with [*capture-default*](expr.prim.lambda.capture#nt:capture-default "7.5.6.3 Captures [expr.prim.lambda.capture]")= ([[expr.prim.lambda.capture]](expr.prim.lambda.capture "7.5.6.3 Captures")) may implicitly capture*this by reference[.](#1.sentence-1)
|
||
|
||
[*Example [1](#example-1)*: struct X {int x; void foo(int n) {auto f = [=]() { x = n; }; // deprecated: x means this->x, not a copy thereofauto g = [=, this]() { x = n; }; // recommended replacement}}; â *end example*]
|