In the current text of the standard, C++23, as well ason
https://eel.is/c++draft/expr.prim.lambda,
I do see a potential imprecision related to the introduction
of the explicit object parameter.
In particular,
[expr.prim.lambda.closure]-p7 reads:
"
"
so that the unnamed non-static data member is const if and only if
either there is mutable or there is an explicit object parameter.
However,
[expr.prim.lambda.capture]-p(14.1) related
to capturing in nested lambda something
captured by the surrounding lambda, reads:
"
If m1 captures the entity by copy, m2 captures the corresponding non-static data member of m1's closure type; if m1 is not mutable, the non-static data member is considered to be const-qualified. "
It seems the final part highlighting only the case of mutable is incomplete,
and I guess it was intended to cover also the case of explicit object
parameter.
that both gcc and clung do so.
Maybe a simple solution is just to cut that final part of (14.1), because
the text of [expr.prim.lambda.closure]-p7 reported above is already clear
on the fact that the data member are non-const in those two cases.
Am I missing any other motivation that makes the note still needed ?
Is such a motivation really applicable only to the mutable case ?
Otherwise, is it better to keep the note by focusing it on the
const-qualification only (no reference to 'mutable') but indicate
to 'see above' to know when the const is applied ?
Regards,
Mauro.