So, I have this situation where I need to see that something is in my stat map. If it is not, then I want to add it.
char symbolName [] = {'H', 'E', 'L', 'L', 'O', '\ 0'}; Map & LT; String, TheObject & gt; Map; If (theMap.find (symbolName) == theMap.end ()) {TheObject theObject (symbolName); TheMap.insert (pair (symbol name, theObject)); }
I get the map.find at the main dump when the object is not already in the map. It is believed that if the item is not in the map, then this map for an Iterator equal :: end
What's going on here?
GCC: 3.4.6
This accident may be caused by several reasons Without knowing the definition of consultants of TheObject
, I think we have left a great deal to guess on this problem. Until now, your code looks ok, but it can be simplified:
char symbolName [] = "hello"; Map & LT; String, TheObject & gt; Map; TheMap.insert (make_pair (symbol name, TheObject (symbolName)));
Symbols are already mapped, except for the new TheObject object it will not do anything.
Comments
Post a Comment