相关疑难解决方法(0)

无法移动std :: any

以下代码

using vptr = std::vector<std::unique_ptr<int>>;
auto m = std::unordered_map<int, std::any>{};
m.try_emplace(0, move(vptr{}));
Run Code Online (Sandbox Code Playgroud)

无法编译,抱怨使用的已删除副本构造函数unique_ptr。在模板参数中替换std::any为之后,vptr此代码将编译,因此问题显然与any

如何强制std::any移动而不是复制?

c++ move move-semantics c++17 stdany

0
推荐指数
1
解决办法
87
查看次数

标签 统计

c++ ×1

c++17 ×1

move ×1

move-semantics ×1

stdany ×1