Remove Elements and Ranges

Apart from insertion, copying, and replacement, we can also delete elements completely.

The four variations std::remove, std::remove_if, std::remove_copy, and std::remove_copy_if support two kinds of operations. On the one hand, these algorithms can be used to remove elements with and without a predicate from a range. On the other hand, they can be used to copy the result of the modification to a new range.

remove: Removes elements from the range which have the value val.

Get hands-on with 1200+ tech skills courses.