tmp/tmpufgw_07d/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Implicit capture of `*this` by reference <a id="depr.capture.this">[[depr.capture.this]]</a>
|
| 2 |
+
|
| 3 |
+
For compatibility with prior C++ International Standards, a
|
| 4 |
+
*lambda-expression* with *capture-default* `=`
|
| 5 |
+
[[expr.prim.lambda.capture]] may implicitly capture `*this` by
|
| 6 |
+
reference.
|
| 7 |
+
|
| 8 |
+
[*Example 1*:
|
| 9 |
+
|
| 10 |
+
``` cpp
|
| 11 |
+
struct X {
|
| 12 |
+
int x;
|
| 13 |
+
void foo(int n) {
|
| 14 |
+
auto f = [=]() { x = n; }; // deprecated: x means this->x, not a copy thereof
|
| 15 |
+
auto g = [=, this]() { x = n; }; // recommended replacement
|
| 16 |
+
}
|
| 17 |
+
};
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
— *end example*]
|
| 21 |
+
|