I know any insert or remove operations of STL list never invalidate their iterator. However, I'm not sure whether list still preserves iterator itself or not.
So, can I store pointer of list iter开发者_Python百科ator and use it later?
For an std::list:
In case of Insertion,
All iterators and references unaffected [23.2.2.3/1]
In case of Erase,
Only the iterators and references to the erased element get invalidated [23.2.2.3/3]
So, Its safe as long as you erase an element and don't use its stored Iterator.
精彩评论