back_insert_iterator Class

Describes an iterator adaptor that satisfies the requirements of an output iterator. It inserts, rather than overwrites, elements into the back end of a sequence and thus provides semantics that are different from the overwrite semantics provided by the iterators of the C++ sequence containers. The back_insert_iterator class is templatized on the type of container.

template <class Container> 
class back_insert_iterator

Parameters

  • Container
    The type of container into the back of which elements are to be inserted by a back_insert_iterator.

Remarks

The container must satisfy the requirements for a back insertion sequence where is it possible to insert elements at the end of the sequence in amortized constant time. STL sequence containers defined by the deque Class, list Class and vector Class provide the needed push_back member function and satisfy these requirements. These three containers as well as strings may each be adapted to use with back_insert_iterators. A back_insert_iterator must always be initialized with its container.

Constructors

back_insert_iterator

Constructs a back_insert_iterator that inserts elements after the last element in a container.

Typedefs

container_type

A type that provides a container for the back_insert_iterator.

reference

A type that provides a reference for the back_insert_iterator.

Operators

operator*

Dereferencing operator used to implement the output iterator expression *i = x for a back insertion.

operator++

Increments the back_insert_iterator to the next location into which a value may be stored.

operator=

Assignment operator used to implement the output iterator expression *i = x for a back insertion.

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

Thread Safety in the Standard C++ Library

Standard Template Library

Other Resources

back_insert_iterator Members

<iterator> Members