【问题标题】:VS2010 bind implementation doesn't support move-only types?VS2010 绑定实现不支持只移动类型?
【发布时间】:2012-02-12 19:04:47
【问题描述】:

我发现以下代码在 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 绑定实现不支持仅移动类型?

【问题讨论】:

    标签: c++ visual-c++ c++11 visual-c++-2010 move-semantics


    【解决方案1】:

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

    此问题已在即将发布的 Visual C++ 11 版本中修复。该修复程序应包含在 9 月发布的 Visual C++ Developer Preview 中。

    【讨论】:

      猜你喜欢
      • 2019-03-09
      • 2018-12-31
      • 2017-07-12
      • 1970-01-01
      • 2022-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-21
      相关资源
      最近更新 更多