我有一个(相当)简单的键类型和复杂的映射类型的地图,如下所示:
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