back_insert_iterator

back_insert_iterator

template<class Cont>
    class back_insert_iterator
        : public iterator<output_iterator_tag, void, void> {
public:
    typedef Cont container_type;
    typedef Cont::value_type value_type;
    explicit back_insert_iterator(Cont& x);
    back_insert_iterator& operator=(const Cont::value_type& val);
    back_insert_iterator& operator*();
    back_insert_iterator& operator++();
    back_insert_iterator operator++(int);
protected:
    Cont& container;
    };

The template class describes an output iterator object. It inserts elements into a container of type Cont, which it accesses via the protected reference object it stores called container. The container must define:

  • The member type value_type, which is the type of an element of the sequence controlled by the container.
  • The member function push_back``(value_type c), which appends a new element with value c to the end of the sequence.