Collection iteration is perhaps the most insidious language construct. Yet lurking within lies the ability to create random non-local defects.
Monstrous bugs that you’ll spend hours, if not days, trying to find, if you even notice them. Many C++ container operations have the property of “invalidating iterators”: after such an operation any iterator to the container is invalid, and using it results in undefined behaviour.
Here is a prime example of a defective loop, found in the source of my Leaf compiler. For example, inserting a value into a may invalidate iterators.
STLport in debug mode is as much exception-safe and thread-safe as in release mode.Debug mode lets you find very obscure bugs in application code which uses STL iterators and algorithms.It performs runtime checking of iterator validity and ownership and algorithm preconditions.If an element is removed should the iteration just cover the remainder of the collection?
Other than for C++ it’s about the level understanding I have for all languages.To be fair, in C++ the rules are so complex that I generally have to assume I don’t understand it either.