How to invalidate an iterator?

后端 未结 4 863
一个人的身影
一个人的身影 2021-01-14 23:44

Since I know an iterator in the program could be invalidated by some previous operation, I want to invalidate it explicitly. Such as assign NULL to a pointer to invalidate i

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-15 00:19

    could be invalidated by some previous operation, I want to invalidate it explicitly

    ... If you know it may not be valid, then all you have to do it stop using it. Invalidating the iterator explicitly accomplishes nothing, because using it is a programming error either way.

提交回复
热议问题