簡體   English   中英

VS2010綁定實現不支持只移動類型?

[英]VS2010 bind implementation doesn't support move-only types?

我發現以下代碼不能在Visual Studio 2010中編譯(但在GCC中可以正常工作):

using namespace std;
unique_ptr<string> up(new string("abc"));
auto bound = bind(&string::size, move(up));
bound();

我得到的錯誤是:

'std :: unique_ptr <_Ty> :: unique_ptr':無法訪問類'std :: unique_ptr <_Ty>'中聲明的私有成員

是因為VS2010綁定實現只是不支持僅移動類型嗎?

您的猜測是正確的: std::bind的Visual C ++ 2010實現不支持移動。 請參閱錯誤報告, “std :: bind和std :: function不能移動。”

這是在即將發布的版本Visual C ++ 11中修復的。修復程序應該出現在9月發布的Visual C ++ Developer Preview中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM