This documentation is archived and is not being maintained.

iterator Class 

An empty base class used to ensure that a user-defined iterator class works properly with iterator_traits.


template<class Category, class Type, class Distance = ptrdiff_t
   class Pointer = Type*, class Reference = Type&>
   struct iterator {
   typedef Category iterator_category;
   typedef Type value_type;
   typedef Distance difference_type;
   typedef Pointer pointer;
   typedef Reference reference;
   };

The template class serves as a base type for all iterators. It defines the member types

  • iterator_category (a synonym for the template parameter Category).

  • value_type (a synonym for the template parameter Type).

  • difference_type (a synonym for the template parameter Distance).

  • pointer (a synonym for the template parameter Pointer).

  • reference (a synonym for the template parameter Reference).

Note that value_type should not be a constant type even if pointer points at an object of const Type and reference designates an object of const Type.

See iterator_traits for an example of how to declare and use the types in the iterator base class.

Header: <iterator>

Show: