Freigeben über


insert_iterator Class

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

template <class Container> class insert_iterator;

Parameters

  • Container
    The type of container into which elements are to be inserted by an insert_iterator.

Remarks

The container of type Container must satisfy the requirements for a variable-sized container and have a two-argument insert member function where the parameters are of type Container::iterator and Container::value_type and that returns a type Container::iterator. Standard Template Library sequence and sorted associative containers satisfy these requirements and can be adapted to use with insert_iterators. For associative containers, the position argument is treated as a hint, which has the potential to improve or degrade performance depending on how good the hint is. An insert_iterator must always be initialized with its container.

Constructors

insert_iterator

Constructs an insert_iterator that inserts an element into a specified position in a container.

Typedefs

container_type

A type that represents the container into which a general insertion is to be made.

reference

A type that provides a reference to an element in a sequence controlled by the associated container.

Operators

operator*

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

operator++

Increments the 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 general insertion.

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

<iterator>

Thread Safety in the C++ Standard Library

Standard Template Library