If there is just one element to removed it seems the approch to go is to use std::find_if()
rather than std::remove_if()
and locate the object in the specific range:
auto it = std::find_if(v.begin() + index1, v.begin() + index2, pred);
if (it != v.begin() + index2) {
v.erase(it);
}
If there are potentially more elements you could use
v.erase(std::remove_if(v.begin() + index1, v.begin() + index2, pred), v.begin() + index2);
You can use v.erase()
to remove elements from an internal range.