std::remove_if
re-arranges the elements of the vector such that the elements you want to keep are in the range [vec.begin(), return_iterator)
(note the partially open range). So you need to call std::vector::erase
to make sure the vector contains only the desired elements. This is called the erase-remove idiom:
auto it = remove_if(vec.begin(),
vec.end(),
[](foo & f) { return f.release() == true; });
vec.erase(it, vec.end());
Here, I have split it into two lines for clarity, but it is often seen as a one-liner.