Lets suppose I have a unsorted list of iterators to delete defined as
std::vector<std::vector<int>::iterator> _unsortedIterList;
Of another vector defined as:
std::vector<int> _listValues;
Then this code will not work (since erasing will invalidate the remaining iterators).
for ( auto it: _unsortedIterList)
{
_listValues.erase(it);
}
Is there a way to erase all of the iterators properly?