Does pop_back() really invalidate *all* iterators on an std::vector?

前端 未结 11 1741
半阙折子戏
半阙折子戏 2021-01-05 06:26
std::vector ints;

// ... fill ints with random values

for(std::vector::iterator it = ints.begin(); it != ints.end(); )
{
    if(*it < 10)
         


        
11条回答
  •  甜味超标
    2021-01-05 06:51

    Iterators are only invalidated on reallocation of storage. Google is your friend: see footnote 5.

    Your code is not working for other reasons.

提交回复
热议问题