Removing item from vector while iterating?

后端 未结 8 2174
小鲜肉
小鲜肉 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:26

    You might want to consider using a std::list instead of a std::vector for your data structure. It is safer (less bug prone) to use when combining erasure with iteration.

提交回复
热议问题