unordered_map不同的自定义类型
unordered_map of different custom types
假设我有这两个enums
:
enum Type
{
Type1,
Type2
};
enum Location
{
Location1,
Location2,
Location3
};
现在我想要一个可以引用的容器,例如container[Type1][Location1] = 5;
我不需要对元素进行排序,但我需要能够有重复container[Type1]
可以是Location1
或Location2
等。
我想使用一种unordered_multimap<pair<Type, Location>, unsigned int>>
,它提供了我想要的东西,但不允许我访问所描述的元素(或者至少我不知道该怎么做)
你有什么建议?
我相信
你正在寻找嵌套地图:
std::unordered_map<Type, std::unordered_map<Location, unsigned int>>
相关文章:
- 使用QJsEngine在Qt中注册自定义类型
- 当我使用自定义类型创建动态数组时,即使使用字符串,它似乎也不起作用
- QtQuick - qml:28:错误:未知方法返回类型:自定义类型
- 如何使自定义类型在unordered_map中用作键
- Qt5 远程对象 + 自定义类型,但不在 POD 中
- 标准::原子中的自定义类型
- 如何使用自定义类型声明Arduino数组?
- 使用自定义访问者时具有自定义类型的提升变体失败(源自 boost::static_visitor)
- 您可以将binary_search应用于具有自定义类型的矢量吗?
- 在自定义类型图中重用 SWIG 映射
- 扩展自定义类型的spdlog
- 重载自定义类型的 std::to_string 和 std::to_chars?
- 自定义类型转换运算符在转发引用上调用时不起作用(当对象按值传递时有效)
- 初始化自定义类型构造函数的数组
- 如何使用 QListIterator 的声明自定义类型定义
- 向前删除标题文件中其他名称空间的自定义类型
- 如何为提升日志和自定义类型定义输出流运算符
- typedef 中的自定义类型为 Qt MetaType
- 无法专门化 std::hash 以unordered_map存储自定义类型
- 运算符/ STD :: Chrono ::持续时间和自定义类型与Clang