我有一个(相当)简单的按键式和复杂的映射类型,像这样的地图:
map<string, vector<string>> myMap;
如果我有一个vector<string>
在手,是有可能插入进入图,其复制键,但移动映射值? 也就是说,有没有一些方法来做到:
string key = "Key";
vector<string> mapped;
for (int i = 0; i < 1000; ++i)
mapped.push_back("Some dynamic string");
// Insert by moving mapped; I know I'm done with it
myMap.insert(make_pair(key, move(mapped))); // This seems to move key too