File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 1392
1392
the entity is said to be \defnx {implicitly captured}{capture!implicit}
1393
1393
by each intervening \grammarterm {lambda-expression} with an associated
1394
1394
\grammarterm {capture-default} that does not explicitly capture it.
1395
+ The implicit capture of \tcode {*this} is deprecated when the
1396
+ \grammarterm {capture-default} is \tcode {=}; see \ref {depr.capture.this }.
1395
1397
\begin {example }
1396
1398
\begin {codeblock }
1397
1399
void f(int, const int (&)[2] = {}); // \# 1
Original file line number Diff line number Diff line change 48
48
\pnum
49
49
The \grammarterm {noexcept-specifier} \tcode {throw()} is deprecated.
50
50
51
+ \rSec 1[depr.capture.this]{Implicit capture of \tcode {*this} by reference}
52
+
53
+ \pnum
54
+ For compatibility with prior \Cpp {} International Standards,
55
+ a lambda expression with \grammarterm {capture-default}
56
+ \tcode {=}\iref {expr.prim.lambda.capture } can implicitly capture
57
+ \tcode {*this} by reference.
58
+ \begin {example }
59
+ \begin {codeblock }
60
+ struct X {
61
+ int x;
62
+ void foo(int n) {
63
+ auto f = [=]() { x = n; }; // deprecated: \tcode {x} means \tcode {this->x}, not a copy thereof
64
+ auto g = [=, this]() { x = n; }; // recommended replacement
65
+ }
66
+ };
67
+ \end {codeblock }
68
+ \end {example }
69
+
51
70
\rSec 1[depr.cpp.headers]{\Cpp {} standard library headers}
52
71
53
72
\pnum
You can’t perform that action at this time.
0 commit comments