Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

front_insert_iterator, front_inserter


Insert Iterator

Summary

An insert iterator used to insert items at the beginning of a collection.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <iterator>
template <class Container>
class front_insert_iterator ;

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 find, after the three insertions, that the first three elements of exmpl are "3 2 1".

Interface

Types

container_type

Constructors

explicit
front_insert_iterator(Container& x);

Operators

front_insert_iterator<Container>&
operator=(const typename Container::value_type& value);
front_insert_iterator<Container>& 
operator*();
front_insert_iterator<Container>& 
operator++();
front_insert_iterator<Container> 
operator++(int);

Non-member Functions

template <class Container>
front_insert_iterator<Container>
front_inserter(Container& x)

Example

Program Output

Warnings

If your compiler does not support default template parameters, then you always need to supply the Allocator template argument. For instance, you have to write:

deque<int, allocator<int> >

instead of:

deque<int>

If your compiler does not support namespaces, then you do not need the using declaration for std.

See Also

Insert Iterators



Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998