加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – VS2010绑定实现不支持仅移动类型?

发布时间:2020-12-16 09:39:52 所属栏目:百科 来源:网络整理
导读:我发现以下代码不能在Visual Studio 2010中编译(但在GCC中可以正常工作): using namespace std;unique_ptrstring up(new string("abc"));auto bound = bind(string::size,move(up));bound(); 我得到的错误是: ‘std::unique_ptr_Ty::unique_ptr’ : cannot
我发现以下代码不能在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’ : cannot access private member
declared in class ‘std::unique_ptr<_Ty>’

是因为VS2010绑定实现只是不支持仅移动类型吗?

解决方法

您的猜测是正确的:std :: bind的Visual C 2010实现不支持移动.请参阅错误报告,“std::bind and std::function are not move-aware.”

这在即将发布的版本Visual C 11中得到修复.修复程序应该出现在9月发布的Visual C Developer Preview中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读