insert iterator and remove_copy_if : insert_iterator « STL Algorithms Iterator « C++ Tutorial






#include <algorithm>
#include <functional>
#include <iterator>
#include <vector>
#include <iostream>
#include <set>

using namespace std;

int main(int argc, char** argv)
{
  vector<int> vectorOne;
  set<int> setOne;
  vectorOne.push_back(1);
  vectorOne.push_back(2);
  vectorOne.push_back(3);
  vectorOne.push_back(4);
  

  insert_iterator<set<int> > inserter(setOne, setOne.begin());
  remove_copy_if(vectorOne.begin(), vectorOne.end(), inserter,bind2nd(equal_to<int>(), 100));

  copy(setOne.begin(), setOne.end(), ostream_iterator<int>(cout, " "));
  cout << endl;

  return (0);
}








30.4.insert_iterator
30.4.1.Create insert_iterator to element 2
30.4.2.insert iterator and remove_copy_if
30.4.3.insert_iterator from vector: set the position
30.4.4.Demonstrate insert_iterator