diff --git a/source/expressions.tex b/source/expressions.tex index a87bfc63a1..642df02266 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -1392,6 +1392,8 @@ the entity is said to be \defnx{implicitly captured}{capture!implicit} by each intervening \grammarterm{lambda-expression} with an associated \grammarterm{capture-default} that does not explicitly capture it. +The implicit capture of \tcode{*this} is deprecated when the +\grammarterm{capture-default} is \tcode{=}; see \ref{depr.capture.this}. \begin{example} \begin{codeblock} void f(int, const int (&)[2] = {}); // \#1 diff --git a/source/future.tex b/source/future.tex index 751897ab77..26665d8e22 100644 --- a/source/future.tex +++ b/source/future.tex @@ -14,6 +14,25 @@ An implementation may declare library names and entities described in this Clause with the \tcode{deprecated} attribute\iref{dcl.attr.deprecated}. +\rSec1[depr.capture.this]{Implicit capture of \tcode{*this} by reference} + +\pnum +For compatibility with prior \Cpp{} International Standards, +a lambda expression with \grammarterm{capture-default} +\tcode{=}\iref{expr.prim.lambda.capture} may implicitly capture +\tcode{*this} by reference. +\begin{example} +\begin{codeblock} +struct X { + int x; + void foo(int n) { + auto f = [=]() { x = n; }; // deprecated: \tcode{x} means \tcode{this->x}, not a copy thereof + auto g = [=, this]() { x = n; }; // recommended replacement + } +}; +\end{codeblock} +\end{example} + \rSec1[depr.static_constexpr]{Redeclaration of \tcode{static constexpr} data members} \pnum