Ann*_*eta 0 c++ dictionary c++11
我有一个将字符串映射到字符串向量的映射:
std::unordered_map<std::string, std::vector<std::string>>> myMap;。
std::unordered_map<std::string, std::vector<std::string>>> myMap;
是否有一种很好的方法(在仍然可读的情况下,尽可能少的代码)将值附加到给定键的向量上?
如何处理为尚未初始化向量的新键向向量添加值的情况?
Hol*_*Cat 7
你要:
myMap["key"].push_back("string");
如果此键的向量不存在,它将自动创建。
归档时间:
6 年,7 月 前
查看次数:
55 次
最近记录: