Standard C++ Library Class Reference
Description
Insert iterators let you insert new elements into a collection rather than copy a new element's
value over the value of an existing element. The class front_insert_iterator is used to insert
items at the beginning of a collection. The function front_inserter creates an instance of a
front_insert_iterator for a particular collection type. A front_insert_iterator can be used with
deques and lists, but not with maps or sets.
Note that a front_insert_iterator makes each element that it inserts the new front of the
container. This has the effect of reversing the order of the inserted elements. For example, if
you use a front_insert_iterator to insert "1" then "2" then "3" onto the front of container exmpl,
you will find, after the three insertions, that the first three elements of exmpl are "3 2 1".
Interface
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>
front_insert_iterator<Container> front_inserter (Container&);
Constructor
explicit
front_insert_iterator (Container& x);
Constructor. Creates an instance of a front_insert_iterator associated with container x.
Operators
front_insert_iterator<Container>&
operator= (const typename Container::value_type& value);
Assignment Operator. Inserts a copy of value on the front of the container, and returns
*this.
front_insert_iterator<Container>&
operator* ();