The following code
using vptr = std::vector<std::unique_ptr<int>>;
auto m = std::unordered_map<int, std::any>{};
m.try_emplace(0, move(vptr{}));
Fails to compile, complaining about using of deleted copy constructor of unique_ptr
. After replacing std::any
with vptr
in template argument this code compiles, so the issue is clearly with any
How can I force std::any
to be moved instead of copied?
move(vptr{})
,vptr{}
is already an rvalue. – Ambsace