setting up an array of different unordered_maps

I'm attempting to build an array with two elements.

The first:
 
std::unordered_map<std::string,std::string>

And, the second:
 
std::unordered_map<std::string,std::string,myhash>


So, for these elements, how can I declare and initialize the array?

Thx.
So, for these elements, how can I declare and initialize the array?

These are different types. You can't have different types in the same array in C++.
You could make a separate class containing both of them and only asign one of them the value:

1
2
3
4
5
6
7
8
9
10
11
12
class multiple_unordered_map
{
public:
std::unordered_map<std::string,std::string> map1;
std::unordered_map<std::string,std::string,myhash> map2;
#multiple_unordered_map() definition one;
#multiple_unordered_map() definition two, containing the myhash;
}

multiple_unordered_map maps[..];
maps[0] = multiple_unordered_map(args to define the first type of map);
maps[1] = multiple_unordered_map(args to define the second type);


This sounds very confuding, im sure, but i'm just bad at explanations. Hope I helped.
Thanks for the replies. I have a few follow-up questions.

1. Can I use this forum for this discussion?

2. Is there a parent class for unordered_map? If so, could it be used to for an array to contain the two elements?

3. Is the second element an explicit specialization of the first? If not, how are the two
elements related?

4. FYI: I'm using g++ and Ubuntu 14.04.
1. Can I use this forum for this discussion?
What discussion?

2. Is there a parent class for unordered_map?
No.

3. Is the second element an explicit specialization of the first?
No.
If not, how are the two elements related?
They are unrelated. Two different types.

However: Since the value types are compatible you can always copy the elements from one map to the other.
Topic archived. No new replies allowed.