开发者

Is it safe to store pointer of STL list iterator?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜