Standard C++ Library Class Reference
Increments the input iterator and returns *this.
Helper Function
template <class Container>
back_insert_iterator<Container>
back_inserter (Container& x)
Returns a back_insert_iterator that will insert elements at the end of container x. This
function allows you to create insert iterators inline.
Example
//
// ins_itr.cpp
//
#include <iterator>
#include <deque>
#include <iostream.h>
int main ()
{
//
// Initialize a deque using an array.
//
int arr[4] = { 3,4,7,8 };
deque<int> d(arr+0, arr+4);
//
// Output the original deque.
//
cout << "Start with a deque: " << endl << " ";
copy(d.begin(), d.end(), ostream_iterator<int>(cout," "));
//
// Insert into the middle.
//
insert_iterator<deque<int> > ins(d, d.begin()+2);
*ins = 5; *ins = 6;
//
// Output the new deque.
//
cout << endl << endl;
cout << "Use an insert_iterator: " << endl << " ";
copy(d.begin(), d.end(), ostream_iterator<int>(cout," "));
//
// A deque of four 1s.
//