C++ Standard Library insert_iterator Sample

Description

insert_iterator is a template class used to insert new elements in the middle of a sequence, pushing back existing elements. It is used with the helper function inserter(), in cases where you want to grow a container by adding new elements.

Declaration

	template <class Cont>
	    class insert_iterator : public iterator;

Concept

The sample program sets up a vector of integers, and then adds two elements to it. An insertion iterator is retrieved, and is used to insert elements before the existing element #1 (with value 17) in the vector. The operators * and ++ are used to make the actual insertion. The output of the program is 5 11 16 17 23.

Supported
Supported
Supported