std::vector<int> v;
// fill it up somehow
v.erase(std::remove(v.begin(), v.end(), 99), v.end());
// really remove all elements with value 99
carVec.erase(std::remove_if(carVec.begin(), carVec.end(), [&id_to_delete](const Car& ele)->bool
{
return ele.getnewId() == id_to_delete;
}), carVec.end());
#include <algorithm>
...
vec.erase(std::remove(vec.begin(), vec.end(), 8), vec.end());