.\" ident @(#)Insert_Iterators.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH Insert_Iterators 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2Insert_Iterators\fP \ - An iterator adaptor that allows an iterator to insert into a container rather than overwrite elements in the container. .SH SYNOPSIS .br #include .br template .br class insert_iterator : .RE .RS 5 iterator ; .RE .RS 0 .br template .br class back_insert_iterator; .br .br template .br class front_insert_iterator; .SH DESCRIPTION Insert iterators are iterator adaptors that let an iterator insert new elements into a collection rather than overwrite existing elements when copying to a container. There are several types of insert iterator classes. .HP .5i \(bu The class_back_insert_iterator is used to insert items at the end of a collection. The function \f2back_inserter\fP can be used with an iterator inline, to create an instance of a_back_insert_iterator for a particular collection type. .HP .5i \(bu The class front_insert_iterator is used to insert items at the start of a collection. The function \f2front_inserter\fP creates an instance of a front_insert_iterator for a particular collection type. .HP .5i \(bu An insert_iterator inserts new items into a collection at a location defined by an iterator supplied to the constructor. Like the other insert iterators, insert_iterator has a helper function called \f2inserter\fP, which takes a collection and an iterator into that collection, and creates an instance of the insert_iterator. .HP 0 .SH INTERFACE .br template .br class insert_iterator : public .RE .RS 6 iterator ; { .RE .RS 0 .br public: .RE .RS 2 typedef Container container_type; .br insert_iterator (Container&, typename .RE .RS 19 Container::iterator); .RE .RS 2 insert_iterator& .RE .RS 3 operator= (const typename Container::value_type&); .RE .RS 2 insert_iterator& operator* (); .br insert_iterator& operator++ (); .br insert_iterator& operator++ (int); .RE .RS 0 }; .br .br template .br class back_insert_iterator : public .RE .RS 6 iterator ; { .RE .RS 0 .br public: .RE .RS 2 typedef Container container_type; .br explicit back_insert_iterator (Container&); .br back_insert_iterator& .RE .RS 3 operator= (const typename Container::value_type&); .RE .RS 2 back_insert_iterator& operator* (); .br back_insert_iterator& operator++ (); .br back_insert_iterator operator++ (int); .RE .RS 0 }; .br .br template .br class front_insert_iterator : public .RE .RS 6 iterator ; { .RE .RS 0 .br public: .RE .RS 2 typedef Container container_type; .br explicit front_insert_iterator (Container&); .br front_insert_iterator& .RE .RS 3 operator= (const typename Container::value_type&); .RE .RS 2 front_insert_iterator& operator* (); .br front_insert_iterator& operator++ (); .br front_insert_iterator operator++ (int); .RE .RS 0 }; .br .br template .br insert_iterator inserter (Container&, Iterator); .RE .RS 1 .RE .RS 0 template .br back_insert_iterator back_inserter (Container&); .br .br template .br front_insert_iterator .RE .RS 22 front_inserter (Container&); .SH SEE ALSO back_insert_iterator, front_insert_iterator, insert_iterator