Hello everyone,

I have a map of maps :-

typedef map <string, map <string, int> > myMapofMaps;
myMapofMaps a;

I'm trying to insert an entry but without actually creating the inner map as an object. Is that possible at all ?

In other words, I want to do something like :-

a.insert(pair <string, map <string, int> >("AAA",(pair <string, int> ("A1", 1))));

As you can see in the inner map I'm not specifying the map name.

I need to do this this way because I don't know in advance how many inner maps there will be, so I cannot do :-

map <string, int> x1;
map <string, int> x2;
map <string, int> x3;

I need the compiler to know that once I insert an entry to the outer map, then an inner map needs to be created automatically and I need to be able to access it later.

I tried putting the inner map into a vector, but I still cannot make_pairs this way. I still need to find a way of inserting to a map without actually manually creating it myself.

Does this make sense ? Can I let the compiler create maps for me at run time?

Many thanks for your help.