Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

front_insert_iterator, front_inserter()

Library:  Iterators


Function

Local Index

Members

Non-Members

Summary

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

Synopsis

#include <iterator>

namespace std {
  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 template front_insert_iterator is used to insert items at the beginning of a collection. The convenience function template front_inserter() creates an instance of a front_insert_iterator for a particular collection type. A front_insert_iterator can be used with any container that defines the push_front() member function, specifically the sequences deque and list, but not with associative containers (e.g., map or set).

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

Member Types

container_type

Constructors

explicit
front_insert_iterator(container_type& x);

Operators

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

Nonmember Functions

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

Example

See Also

Insert Iterators

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 24.4.2.3



Previous fileTop of DocumentContentsIndex pageNext file