Posts Tagged iterator

Erasing Iterators from STL Containers (STL Vector, etc.) in a Loop

for( vector<aType>::iterator it = aVec.begin(); 
      it != aVec.end(); 
      it = (*it).shouldDelete()?aVec.erase(it):it+1){
   // do stuff
}

, , , , , , , , , ,

2 Comments