C++ Logo

std-discussion

Advanced search

example with deprecated equivalence of lambda capture [=] as [=, this]

From: mauro russo <ing.russomauro_at_[hidden]>
Date: Thu, 9 Oct 2025 18:32:21 +0200
In [expr.prim.lambda.capture].

as well known, p(7.3) reads as follows since C++20:
"
*The implicit capture of *this is deprecated when the capture-default
<https://eel.is/c++draft/expr.prim.lambda#nt:capture-default> is =;
see [depr.capture.this] <https://eel.is/c++draft/depr.capture.this>.
<https://eel.is/c++draft/expr.prim.lambda#capture-7.sentence-3>*
"

Then, shouldn't p2 refine the Example1 as follows ?

from:
"
[=, this]{ }; // OK, equivalent to [=]
"

to:
"
[=, this]{ }; // OK, deprecated equivalence to [=]
"

Tiny, but consistent change, despite Examples are not formally part of the
standard,
but the deprecation implies there is no guarantee about the equivalence,
isn't it ?

Received on 2025-10-09 16:32:37