1
我在MSVC2010中遇到了lambdas問題。C++ 0x lambda + boost :: function trouble
它是成功的編譯:
auto f1 = []() { };
boost::function<void()> a = f1;
但它帶來的錯誤C2440:
auto f2 = []()
{
auto f3 = []() { };
boost::function<void()> b = f3;
};
錯誤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中工作嗎?
爲什麼你使用boost :: function而不是std :: function? – 2012-04-20 11:40:41
因爲我的項目的依賴庫使用boost :: function。它是否適用於std :: function? – dizel3d 2012-04-20 11:44:34
我用vc10測試了你的代碼,但是使用了'std :: function'代替。它編譯好。因此,使用clang 3.2和gcc 4.6.2的代碼。我沒有助推庫方便,所以我不能評論你的確切問題。 HTH! – dirkgently 2012-06-07 01:26:45