Oct 9, 2013 at 9:41pm UTC
oh thanks.. one more question why emplace? why not insert or ??
Oct 9, 2013 at 9:44pm UTC
You could also use this:
"hello"] = 3.1415926;
However in some cases it is better to emplace for efficiency. I would recommend only using emplace if you actually profile your code and find that the above method is really the slowest part of your program - otherwise you need not be concerned about efficiency.
Oct 10, 2013 at 12:12pm UTC
You can't use
data anymore after you add it to map_data, since it won't update when its copy inside map_data does. You need to iterate over iter2->second.
Oct 10, 2013 at 12:47pm UTC
I think there is a potential semantic error. There is no "a map" in a map. There are many map
s in a map. Each (int) key on the outer map corresponds to different <string,double> map.
If the "1 in 1" is just a typo, then everything is ok, but if it does affect thinking too, ...
Oct 10, 2013 at 6:47pm UTC
I figured out the problem.. i need to use the iterator of the map_data to access the inner map.. like
and it works.. thank u all for ur help :)