Possible Duplicate:
discover when the element is inserted to the std::map
I track inserting of 137 elements in to the map When I check using VS2010 debugger the size of map I get indeed 137.Using printf I print all elements of the map by
(it = map.begin();it !=map.end();++it) {
printf ("%x",it->second);
}
As a result 137 values are printed.
After that my program continues to execute.And near the end of execution I need to treat the values of the map.
I once more check with debugger that it has 137 elements but when I print all of them as previously I get 138 values printed,when the last one is invalid value.
I need to understand how/when it happens and what causes map.end() to be shifted.
Without the code it is hard to tell. We can guess.
I suggest you rewrite operator that adds to your map, and after each adding check what is the size of your map. When the size is > 137 cause your program to GPF (or call function that will cause debugger to break.) Run your program in debugger, and bingo, the stack trace will tell you where you have the problem.