Files
cppdraft_translate/cppdraft/depr/capture/this.md
2025-10-25 03:02:53 +03:00

915 B

[depr.capture.this]

Annex D (normative) Compatibility features [depr]

D.3 Implicit capture of *this by reference [depr.capture.this]

1

#

For compatibility with prior revisions of C++, a lambda-expression with capture-default= ([expr.prim.lambda.capture]) may implicitly capture*this by reference.

[Example 1: struct X {int x; void foo(int n) {auto f = = { x = n; }; // deprecated: x means this->x, not a copy thereofauto g = =, this { x = n; }; // recommended replacement}}; — end example]