c++ - 如何在 unordered_map 中存储 2 个以上的变量?

标签 c++ unordered-map

如何在 std::unordered_map 中存储 2 个以上的变量?

我想要这样的东西:

std::unordered_map<string, int, int, int> mapss = {{"a",1,1,1},{"b",1,2,3}};

最佳答案

如果字符串是键,其余是值,那么您可以将值设为元组

unordered_map<string, tuple<int, int, int>> mapss

如果你不知道会有多少个值,你可以使用一个vector

unordered_map<string, vector<int>> mapss

关于c++ - 如何在 unordered_map 中存储 2 个以上的变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28796290/

相关文章:

c++ - 存储和检索动态变化的结构

c++ - C/C++ 和 GNU/PGI : undefined reference to `__pgio_ini'

C++11 获取 unordered_map 中一个存储桶的所有项目

c++ - 构造一个持有引用的 unordered_map 是否合法?

c++ - 如何在 unordered_map 的键中使用 std::tr1::function 对象?

c++ - 使用中间结果初始化多个属性

C++ 检查结构是否为空

c++ - 读取文件并将其存储在 unordered_map 中时出现问题

c++ - 从 C++ 调用 Haskell 库

c++ - 使用Unordered_map C++的字符串中的第一个唯一字符