remove
doesn't give a range. It just gives one iterator. The range you pass to erase
starts at that iterator and ends at vec.end()
, which is your second argument.
remove
works by rearranging the sequence so that all the elements to be removed are at the end, of the sequence, and it returns the iterator that points to the first of those to-be-removed elements.
(So remove
doesn't actually remove anything - but the content of the to-be-removed elements is indeterminate and should not be accessed anyway.)