Skip to content

Commit cdbd6c9

Browse files
authored
Merge 2018-06 CWG Motion 3
Fixes #2115
2 parents a22928a + 4ce0542 commit cdbd6c9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

source/expressions.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,8 @@
13921392
the entity is said to be \defnx{implicitly captured}{capture!implicit}
13931393
by each intervening \grammarterm{lambda-expression} with an associated
13941394
\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}.
13951397
\begin{example}
13961398
\begin{codeblock}
13971399
void f(int, const int (&)[2] = {}); // \#1

source/future.tex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@
1414
An implementation may declare library names and entities described in this Clause with the
1515
\tcode{deprecated} attribute\iref{dcl.attr.deprecated}.
1616

17+
\rSec1[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+
1736
\rSec1[depr.static_constexpr]{Redeclaration of \tcode{static constexpr} data members}
1837

1938
\pnum

0 commit comments

Comments
 (0)