admin管理员组文章数量:1404625
Considering the two examples:
Object obj;
auto val = [&obj](){ return obj.func(); }();
auto val2 = [](const Object& obj){ return obj.func(); }(obj);
Are there differences between the two? As I understand it, the first will create some lambda closure with a member variable assigned by reference to obj
, whereas the second will create a lambda closure with no member variables (just the operator()
that they will both have). Will most compilers make no difference in the end anyway? Does it depend at all on the complexity of the lambda's body?
本文标签:
版权声明:本文标题:c++ - Is there any performance or memory difference between capturing and passing by argument for immediately-evaluated lambdas? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744839010a2627808.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论