Removing item from vector while iterating?

后端 未结 8 2168
小鲜肉
小鲜肉 2020-11-27 15:40

I have a vector that holds items that are either active or inactive. I want the size of this vector to stay small for performance issues, so I want items that have been mark

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 16:30

    As they said, vector's iterators get invalidated on vector::erase() no matter which form of iterator increment you use. Use an integer index instead.

提交回复
热议问题