What is really the difference between the algorithms remove and remove_if and the member function erase?
Does both of them result in a call to the removed objects destructor?
What is really the difference between the algorithms remove and remove_if and the member
Share
No,
std::remove_ifwill move the elements that don’t match the predicate to the end of list and will return an iterator to the new “end”. Erase will effectively drop the element (call the dtor) from the container.The difference is perfectly illustrated by the examples here and here.