Well the type of your map is map of (int -> map of (string -> int))
but you are trying to insert an entry of type map of (int -> pair (string, int))
. A pair
is not a map
, thus the error.
EDIT:
According to the documentation, a call to map's []
operator is equivalent to a series of other operations:
mapped_type& operator[] (const key_type& k);
A call to this function is equivalent to:
(*((this->insert(make_pair(k,mapped_type()))).first)).second
so in your case, the call mapa[10]["aaa"] = 20;
is equivalent to:
(*(( (*((mapa.insert(make_pair(10,map<string, int>()))).first)).second
.insert(make_pair("aaa",20))).first)).second
but I believe if either key 10
or aaa
exist, no element will be inserted in the map. I suggest you read the docs thoroughly and test for the expected behavior.