iterator erase ( iterator position );
iterator erase ( iterator first, iterator last );
Erase elements Removes from the vector container either a single element (position) or a range of elements ([first,last)).
This effectively reduces the vector size by the number of elements removed, calling each element's destructor before.
and:
remove
Removes all elements equaling the given value value from the range, defined by [first, last). Removing is done by shifting the elements in the range in such a way that required elements are overwritten. The elements between the old and the new ends of the range are left intact. Iterator to the new end of the range is returned.
Is there any way to remove elements from a std::vector within an iterator range(something like remove, but ALL elements from [first, last]) without resizing the vector? I need to keep it's maximum size that it reached at runtime to prevent reallocs.
Thanks!