Reputation: 89
Suppose if I have these two enums
:
enum Type
{
Type1,
Type2
};
enum Location
{
Location1,
Location2,
Location3
};
Now I would like to have a container that I can reference like container[Type1][Location1] = 5;
I don't need the elements to be sorted but I need to be able to have duplicates like container[Type1]
can be either Location1
or Location2
etc.
I was thinking to use an unordered_multimap<pair<Type, Location>, unsigned int>>
which kind of provides what I want, but does not allow me to access the elements as described (or at least I don't know how to do that)
What suggestions do you have?
Upvotes: 1
Views: 476
Reputation: 171127
I believe you're looking for nested maps:
std::unordered_map<Type, std::unordered_map<Location, unsigned int>>
Upvotes: 2