Standard C++ Library Class Reference
 vector<int> v(a1, a1+20), result;
 //Create an insert_iterator for results
 insert_iterator<vector<int> > ins(result, 
 result.begin());
 //Demonstrate includes
 cout << "The vector: " << endl << " ";
 copy(v.begin(),v.end(),ostream_iterator<int>(cout," "));
 //Find the unique elements
 unique_copy(v.begin(), v.end(), ins);
 //Display the results
 cout << endl << endl
 << "Has the following unique elements:"
 << endl << " ";
 copy(result.begin(),result.end(),
 ostream_iterator<int>(cout," "));
 return 0;
}
Output :
The vector:
 4 5 5 9 -1 -1 -1 3 7 5 5 5 6 7 7 7 4 2 1 1
Has the following unique elements:
 4 5 9 -1 3 7 5 6 7 4 2 1
Warning
If your compiler does not support default template parameters, then you need to always supply
the Allocator template argument. For instance, you will need to write :
vector<int, allocator>
instead of:
vector<int>










