Since people seem to prefer trying random stuff than clicking the first answer on Google... here it is
(generic version, adapt to your code)for (auto it = v.begin(); it != v.end(); )
{
if (some_condition(*it))
it = v.erase(it);
else
++it;
}
same thing, hidden behind STL functions:
v.erase(std::remove_if(v.begin(), v.end(), [](T item){return some_condition(item);}), v.end());