Iterator Traits

To implement algorithms only in terms of iterators, it is often necessary to determine the value and difference types for a particular iterator type. Therefore, it is required that if iterator is the type of an iterator, then the types

  iterator_traits<Iterator>::difference_type
  iterator_traits<Iterator>::value_type
  iterator_traits<Iterator>::iterator_category
  

are defined as the iterator's difference type, value type and iterator category, respectively.

In the case of an output iterator, the types

  iterator_traits<Iterator>::difference_type
  
  iterator_traits<Iterator>::value_type
  

defined as void.

The template iterator_traits<Iterator> is specialized for pointers and for pointers to const