If I'm using an iterator
in a for
loop and I use erase
on a current iteration of iterator, the for loop should continue fine and access the rest of the list
elements?
From what I have read, this should be the case and is a primary distinguishing characteristic of list
vs deque
or vector
. For my purposes, a queue
might work but I need this behavior.
Here is the loop I am considering:
std::list<Sequence>::iterator iterator;
iterator=m_concurrents.begin();
for (;iterator!=m_concurrents.end();++iterator){
if (iterator->passes()){
m_concurrents.erase(iterator);
}
}