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

Possible duplicate:
The difference between erasing and deleting

Suppose I have a container ... which means the following.

c.erase(remove(c.begin(),c.end(),99),c.end()); 

not erased and deleted the same way? What is the specific erase and delete function in the above example?

+4
source share
1 answer

It removes all elements equal to 99 from container c .

std::remove does not 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 them. The erase member function erase takes an iterator range to actually remove items from the container.

See erase-delete idiom .

+10
source

All Articles