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

15 lines
915 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[depr.capture.this]
# Annex D (normative) Compatibility features [[depr]](./#depr)
## D.3 Implicit capture of *this by reference [depr.capture.this]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L41)
For compatibility with prior revisions of C++,
a [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1General[expr.prim.lambda.general]") with [*capture-default*](expr.prim.lambda.capture#nt:capture-default "7.5.6.3Captures[expr.prim.lambda.capture]")= ([[expr.prim.lambda.capture]](expr.prim.lambda.capture "7.5.6.3Captures")) may implicitly capture*this by reference[.](#1.sentence-1)
[*Example [1](#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*]