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?

本文标签: