22 Iterators library [iterators]

22.5 Iterator adaptors [predef.iterators]

22.5.2 Insert iterators [insert.iterators]

22.5.2.3 Class template insert_­iterator [insert.iterator]

namespace std {
  template<class Container>
  class insert_iterator {
  protected:
    Container* container;
    typename Container::iterator iter;

  public:
    using iterator_category = output_iterator_tag;
    using value_type        = void;
    using difference_type   = void;
    using pointer           = void;
    using reference         = void;
    using container_type    = Container;

    insert_iterator(Container& x, typename Container::iterator i);
    insert_iterator& operator=(const typename Container::value_type& value);
    insert_iterator& operator=(typename Container::value_type&& value);

    insert_iterator& operator*();
    insert_iterator& operator++();
    insert_iterator& operator++(int);
  };

  template<class Container>
    insert_iterator<Container> inserter(Container& x, typename Container::iterator i);
}

22.5.2.3.1 Operations [insert.iter.ops]

insert_iterator(Container& x, typename Container::iterator i);
Effects: Initializes container with addressof(x) and iter with i.
insert_iterator& operator=(const typename Container::value_type& value);
Effects: As if by:
iter = container->insert(iter, value);
++iter;
Returns: *this.
insert_iterator& operator=(typename Container::value_type&& value);
Effects: As if by:
iter = container->insert(iter, std::move(value));
++iter;
Returns: *this.
insert_iterator& operator*();
Returns: *this.
insert_iterator& operator++(); insert_iterator& operator++(int);
Returns: *this.

22.5.2.3.2 inserter [inserter]

template<class Container> insert_iterator<Container> inserter(Container& x, typename Container::iterator i);
Returns: insert_­iterator<Container>(x, i).