最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - Questions about the strange rules of lambda default = capture - Stack Overflow

programmeradmin0浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论