Apache C++ Standard Library Reference Guide

## <iterator>

Library: Iterators

    Header

- Local Index
- Summary
- Synopsis
- See Also
- Standards Conformance

### Local Index

No Entries

### Summary

The header `<iterator>` represents the Iterators library of the Standard C++ Library. It defines:

- the class template iterator_traits and two partial specializations of iterator_traits on pointers and const pointers

- the classes input_iterator_tag, output_iterator_tag, forward_iterator_tag, bidirectional_iterator_tag and random_access_iterator_tag

- the class templates reverse_iterator, back_insert_iterator, front_insert_iterator, insert_iterator, istream_iterator, ostream_isterator, istreambuf_iterator, and ostreambuf_iterator

- the helper function templates `advance()`, `distance()`, `back_inserter()`, `front_inserter()`, `inserter()`

- a set of relational operators that C++ programs may use to perform equality and inequality tests on specializations of reverse_iterator

- the equality and inequality operators specialized for istream_iterator and istreambuf_iterator

### Synopsis

    namespace std {
      template<class Iterator> struct iterator_traits;
      template<class T> struct iterator_traits<T*>;
      template<class T> struct iterator_traits<const T*>;

      template<class Category, class T,
               class Distance = ptrdiff_t,
               class Pointer = T*, class Reference = T&>
      struct iterator;

      struct input_iterator_tag {};
      struct output_iterator_tag {};
      struct forward_iterator_tag: input_iterator_tag {};
      struct bidirectional_iterator_tag : forward_iterator_tag {};
      struct random_access_iterator_tag :
                    bidirectional_iterator_tag {};

      template <class InputIterator, class Distance>
      void advance(InputIterator& i, Distance n);
      template <class InputIterator>
      typename iterator_traits<InputIterator>::difference_type
      distance(InputIterator start, InputIterator finish);

      template <class Iterator>
      class reverse_iterator;

      template <class Iterator>
      bool operator==(const reverse_iterator<Iterator>&,
                      const reverse_iterator<Iterator>&);
      template <class Iterator>
      bool operator<(const reverse_iterator<Iterator>&,
                     const reverse_iterator<Iterator>&);
      template <class Iterator>
      bool operator!=(const reverse_iterator<Iterator>&,
                      const reverse_iterator<Iterator>&);
      template <class Iterator>
      bool operator>(const reverse_iterator<Iterator>&,
                     const reverse_iterator<Iterator>&);
      template <class Iterator>
      bool operator>=(const reverse_iterator<Iterator>&,
                      const reverse_iterator<Iterator>&);
      template <class Iterator>
      bool operator<=(const reverse_iterator<Iterator>&,
                      const reverse_iterator<Iterator>&);

      template <class Iterator>
      typename reverse_iterator<Iterator>::difference_type
      operator-(const reverse_iterator<Iterator>&,
                const reverse_iterator<Iterator>&);
      template <class Iterator>
      reverse_iterator<Iterator>
      operator+(typename
                reverse_iterator<Iterator>::difference_type,
                const reverse_iterator<Iterator>&);

      template <class Container> class back_insert_iterator;
      template <class Container>
      back_insert_iterator<Container> back_inserter(Container&);

      template <class Container> class front_insert_iterator;
      template <class Container>
      front_insert_iterator<Container> front_inserter(Container&);

      template <class Container> class insert_iterator;
      template <class Container, class Iterator>
      insert_iterator<Container> inserter(Container&, Iterator);

      template <class T, class charT = char,
                class traits = char_traits<charT>,
                class Distance = ptrdiff_t>
      class istream_iterator;
      template <class T, class charT, class traits,
                class Distance>
      bool operator==(const istream_iterator<T, charT, traits,
                      Distance>&, const istream_iterator<T, charT,
                      traits, Distance>&);
      template <class T, class charT, class traits,
                class Distance>
      bool operator!=(const istream_iterator<T, charT, traits,
                      Distance>&, const istream_iterator<T,
                      charT, traits, Distance>&);

      template <class T, class charT = char,
                class traits = char_traits<charT> >
      class ostream_iterator;

      template<class charT, class traits = char_traits<charT> >
      class istreambuf_iterator;
      template <class charT, class traits>
      bool operator==(const istreambuf_iterator<charT, traits>&,
                      const istreambuf_iterator<charT, traits>&);
      template <class charT, class traits>
      bool operator!=(const istreambuf_iterator<charT, traits>&,
                      const istreambuf_iterator<charT, traits>&);

      template <class charT, class traits = char_traits<charT> >
      class ostreambuf_iterator;
    }

### See Also

iterator_traits, iterator, `advance()`, `distance()`, reverse_iterator, back_insert_iterator, `back_inserter()`, front_insert_iterator, `front_inserter()`, insert_iterator, `inserter()`, istream_iterator, ostream_iterator, istreambuf_iterator, ostreambuf_iterator, Bidirectional Iterators, Input Iterators, Insert Iterators, Iterators, Output Iterators, Random Access Iterators, Stream Iterators

### Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems --Programming Language C++, Section 24