【发布时间】:2015-06-01 15:09:23
【问题描述】:
我找到了这个 c++ 代码,但我无法理解这个语法:
auto path_dbus = [&](DBus::Connection &bus) {
...
};
【问题讨论】:
我找到了这个 c++ 代码,但我无法理解这个语法:
auto path_dbus = [&](DBus::Connection &bus) {
...
};
【问题讨论】:
这是一个 lambda 函数:
[&]捕获任何使用的变量
(DBus::Connection&)
{...}
分解那条线:
auto path_dbus = [&] (DBus::Connection &bus) {... };
^capture ^arguments ^work
【讨论】:
A common misconception about capture-default is that all variables in the scope are captured whether they are used in the lambda or not”)