Quick Q: How do I move an expensive object into a map? -- StackOverflow

Quick A: Using the form of insert that takes an rvalue and passing a temporary or a std::move'd object, or calling emplace.

Moving an object into a map

The problem with this is that the huge objects will be copied into the maps


Huge huge1(some,args);
Huge huge2(some,args);

std::map<int,Huge> map1;
std::map<Huge,int> map2;


how can I guarantee a move? Will this work or is there more to it?


Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.