Let's say I have some kind of collection and I obtained an iterator for the beginning of it. Now let's say I modified the collection. Can I still use the iterator safely, regardless of the type of the collection or the iterator?
To avoid confusion, here is the order of operations I talk about:
- Get an iterator of the collection.
- Modify the collection (obviously
not an element in it, but the collection itself).
- Use the iterator obtained at step 1. Is it stil valid according to STL standard?!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…