我发现以下代码不能在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绑定实现不支持仅移动类型吗?
1 回答
您的猜测是正确的:
std::bind
的Visual C 2010实现不支持移动 . 查看错误报告,"std::bind and std::function are not move-aware."这在即将发布的版本Visual C 11中得到修复 . 修复程序应该出现在9月发布的Visual C Developer Preview中 .