Top of document
©Copyright 1999 Rogue Wave Software

Insert Iterators


     Insert Iterator

Summary

Iterator adaptor that allows an iterator to insert into a container rather than overwrite elements in the container.

Contents

Synopsis

#include <iterator>
template <class Container>
class insert_iterator : public output_iterator;
template <class Container>
class back_insert_iterator:public output_iterator;
template <class Container>
class front_insert_iterator : public output_iterator;

Description

Insert iterators are iterator adaptors that let an iterator insert new elements into a collection rather than overwrite existing elements when copying to a container. There are several types of insert iterator classes.

Interface

template <class Container>
 class insert_iterator : public output_iterator {

public:
   insert_iterator (Container&, typename Container::iterator);
   insert_iterator<Container>&
    operator= (const typename Container::value_type&);
   insert_iterator<Container>& operator* ();
   insert_iterator<Container>& operator++ ();
   insert_iterator<Container>& operator++ (int);
};
template <class Container>
 class back_insert_iterator : public output_iterator {
public:
   explicit back_insert_iterator (Container&);
   back_insert_iterator<Container>&
    operator= (const typename Container::value_type&);
   back_insert_iterator<Container>& operator* ();
   back_insert_iterator<Container>& operator++ ();
   back_insert_iterator<Container> operator++ (int);
};
template <class Container>
 class front_insert_iterator : public output_iterator {
public:
   explicit front_insert_iterator (Container&);
   front_insert_iterator<Container>&
    operator= (const typename Container::value_type&);
   front_insert_iterator<Container>& operator* ();
   front_insert_iterator<Container>& operator++ ();
   front_insert_iterator<Container> operator++ (int);
};
 template <class Container, class Iterator>
 insert_iterator<Container> inserter (Container&, Iterator);
 
 template <class Container>
 back_insert_iterator<Container> back_inserter (Container&);
 template <class Container>
 front_insert_iterator<Container> front_inserter (Container&);

See Also

back_insert_iterator, front_insert_iterator


Top of document