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 14
14
An implementation may declare library names and entities described in this Clause with the
15
15
\tcode {deprecated} attribute\iref {dcl.attr.deprecated }.
16
16
17
+ \rSec 1[depr.capture.this]{Implicit capture of \tcode {*this} by reference}
18
+
19
+ \pnum
20
+ For compatibility with prior \Cpp {} International Standards,
21
+ a lambda expression with \grammarterm {capture-default}
22
+ \tcode {=}\iref {expr.prim.lambda.capture } may implicitly capture
23
+ \tcode {*this} by reference.
24
+ \begin {example }
25
+ \begin {codeblock }
26
+ struct X {
27
+ int x;
28
+ void foo(int n) {
29
+ auto f = [=]() { x = n; }; // deprecated: \tcode {x} means \tcode {this->x}, not a copy thereof
30
+ auto g = [=, this]() { x = n; }; // recommended replacement
31
+ }
32
+ };
33
+ \end {codeblock }
34
+ \end {example }
35
+
17
36
\rSec 1[depr.static_constexpr]{Redeclaration of \tcode {static constexpr} data members}
18
37
19
38
\pnum
You can’t perform that action at this time.
0 commit comments