Stl invalidating iterators

6854933580_2c8b688306_z

Since I know an iterator in the program could be invalidated by some previous operation, I want to invalidate it explicitly.Such as assign NULL to a pointer to invalidate it, I just want to do the same on iterator.

What happens in practice is that your implementation might offer debug options in which iterators will do their best to detect whether they're valid or not.I understand they'll both work, but I usually take the same approach as James, to me it seems simpler & more obvious.At a certain point, I start to ask myself, "what am I missing?Surprisingly enough a lot of C programmers do not know the answer to this question.Therefore, they don't know how to avoid the problem of invalidating iterators. This might depend on implementation details of whether they'll currently "work", though, rather than on whether the standard Kinda crazy, if well intentioned.

You must have an account to comment. Please register or login here!