C++0x lambda+boost::函数故障
我对MSVC2010中的lambdas有问题 它是成功编译的: 但它带来了一个错误C2440: 错误C2440:C++0x lambda+boost::函数故障,c++,visual-c++,c++11,C++,Visual C++,C++11,我对MSVC2010中的lambdas有问题 它是成功编译的: 但它带来了一个错误C2440: 错误C2440: 'initializing' : cannot convert from 'int' to 'boost::function<Signature>' with [ Signature=void (void) ] No constructor could take the source type, or construct
'initializing' : cannot convert from 'int' to 'boost::function<Signature>'
with
[
Signature=void (void)
]
No constructor could take the source type, or constructor overload resolution was ambiguous
为什么??它在GCC4.6中工作吗?可能是MSVC中的一个错误。错误消息似乎非常可疑。它在GCC 4.7中工作。decltypef3正常。它不是“int”,而是“lambda0”。为什么要使用boost::function而不是std::function?因为我项目的依赖库使用boost::function。它与std::function一起工作吗?我用vc10测试了您的代码,但改用了std::function。它编译得很好。因此,代码使用了Clang3.2和GCC4.6.2。我手头没有boost库,因此无法对您的确切问题发表评论。嗯!
auto f2 = []()
{
auto f3 = []() { };
boost::function<void()> b = f3;
};
'initializing' : cannot convert from 'int' to 'boost::function<Signature>'
with
[
Signature=void (void)
]
No constructor could take the source type, or constructor overload resolution was ambiguous