I am looping through a vector with a loop such as for(int i = 0; i < vec.size(); i++). Within this loop, I check a condition on the element at that vector i
for(int i = 0; i < vec.size(); i++)
if(vector_name.empty() == false) { for(int i = vector_name.size() - 1; i >= 0; i--) { if(condition) vector_name.erase(vector_name.at(i)); } }
This works for me. And Don't need to think about indexes have already erased.