neilsolent
12/17/2008 8:05:00 AM
Hi Kai-Uwe
Thanks for the reply.
> Your program will have undefined behavior when and only when Check() removes
> the item that the iterator it identifies. This is a consequence of std::map
> being an associative container: erase only invalidates iterators pointing
> to the removed element.
If the item that "it" points at is removed - the loop next runs "it++"
- I guess that's where the problem is?
I will check my code to see if the current item can ever get deleted
by Check(), and if so find another way.
> When Check() inserts items, those whose key are behind it->first will be
> visited in the loop, those inserted before won't. Whether that is what you
> want, I cannot say.
That behaviour is fine for my app, and I expected as much.