Confusion on iterators invalidation in deque

后端 未结 3 2000
暗喜
暗喜 2020-12-15 22:38

I\'m bit confused regarding iterator invalidation in deque. (In the context of this question)

Following is the excerpts from -- The C++ Standard Library: A Tutorial

3条回答
  •  误落风尘
    2020-12-15 22:51

    The SGI implementation probably uses a growable array, so if an insert causes the array to grow, the iterators pointing to the old array are invalid.

    EDIT:

    Looking in section 17.2.3 of The C++ Programming Language Third Edition, I don't see anything in the description of deque that indicates what operations preserve or invalidate iterators. I may be looking in the wrong spot or the behavior may be undefined.

提交回复
热议问题