lambda 怎么设置调用约定呢std::for_each(begin,end,[&](const int a){std::coutastd::endl})这里的
lambda 怎么设置调用约定呢 std::for_each(begin,end,[&](const int a) { std::cout<<a<<std::endl; }); 这里的lambda怎么才能设置调用约定呢? [解决办法]
这种情况的 lambda 是可以转换成对应的函数指针的,所以能够作为回调函数。 c++11 5.1.2/6 The closure type for a lambda-expression with no lambda-capture has a public non-virtual non-explicit const conversion function to pointer to function having the same parameter and return types as the closure type’s function call operator. The value returned by this conversion function shall be the address of a function that, when invoked, has the same effect as invoking the closure type’s function call operator. 如果 [] 放了东西,这种隐式转换就不存在了,然后就无法作为回调函数了。 跟什么 call 没有关系。