Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++0x lambda+boost::函数故障_C++_Visual C++_C++11 - Fatal编程技术网

C++0x lambda+boost::函数故障

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

我对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 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