admin管理员组

文章数量:1356961

I see the following rules in eel and cppref

Within the body of a lambda with capture default =, the type of any capturable entity is as if it were captured (and thus const-qualification is often added if the lambda is not mutable), even though the entity is in an unevaluated operand and not captured (e.g. in decltype)”

If a nested lambda m2 captures something that is also captured by the immediately enclosing lambda m1, then m2's capture is transformed as follows:

  • if the enclosing lambda m1 captures by copy, m2 is capturing the non-static member of m1's closure type, not the original variable or *this; if m1 is not mutable, the non-static data member is considered to be const-qualified.

  • if the enclosing lambda m1 captures by reference, m2 is capturing the original variable or *this.

Now I'm wondering, is the const qualification they describe for value define type decltype(id) or value expr type decltype((id))?

And what is the concept of "often" for the first rule?

本文标签: cQuestions about the strange rules of lambda defaultcaptureStack Overflow