What does the following syntax with the combination of erase and remove mean?

c++, containers, erase

Solution

It removes all elements equal to `99` from container `c`.

`std::remove` doesn't actually remove any elements. It moves all the elements of interest to the second part of the container, and returns an iterator indicating the first of these. Then the `erase` member function takes an iterator range to actually remove the elements from the container.

See erase-remove idiom.

Problem

Possible Duplicate: Difference between erase and remove suppose i have a container.... what does the following mean. ``` c.erase(remove(c.begin(),c.end(),99),c.end()); ``` aren't erase and remove the same? What is the specific function of erase and remove in the above example?

Original source

Related problems