Is end() required to be constant in an STL map/set?

前端 未结 10 527
别跟我提以往
别跟我提以往 2021-02-01 15:00

§23.1.2.8 in the standard states that insertion/deletion operations on a set/map will not invalidate any iterators to those objects (except iterators pointing to a deleted eleme

10条回答
  •  旧巷少年郎
    2021-02-01 15:20

    23.1/7 says that end() returns an iterator that

    is the past-the-end value for the container.

    First, it confirms that what end() returns is the iterator. Second, it says that the iterator doesn't point to a particular element. Since deletion can only invalidate iterators that point somewhere (to the element being deleted), deletions can't invalidate end().

提交回复
热议问题