how to remove element by value in vector in c++ code example
Example 1: how to remove an element from a vector by value c++
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
Example 2: c++ vector remove element by value
carVec.erase(std::remove_if(carVec.begin(), carVec.end(), [&id_to_delete](const Car& ele)->bool
{
return ele.getnewId() == id_to_delete;
}), carVec.end());