int main()
{
const int SIZE = 10;
int a[SIZE] = {10, 2, 35, 5, 10, 26, 67, 2, 5, 10};
std::ostream_iterator< int > output(cout, \" \")
Because std::remove
doesn't actually shrink the container, it just moves all the elements down to to fill up the spot used by the "removed" element. For example, if you have a sequence 1 2 3 4 5
and use std::remove
to remove the value 2
, your sequence will look like 1 3 4 5 5
. If you then remove the value 4
, you'll get 1 3 5 5 5
. At no point does the sequence ever get told to be shorter.