For every iterator type, a corresponding specialization of iterator_traits class template shall exist, with at least the following member types defined:
| member | description |
|---|---|
| difference_type | Type to express the result of subtracting one iterator from another |
| value_type | The type of the element the iterator can point to |
| pointer | The type of a pointer to an element the iterator can point to |
| reference | The type of a reference to an element the iterator can point to |
| iterator_category | The iterator category. It can be one of these:
|
The iterator_traits class template comes with a default definition for all iterator types that takes these member types from the iterator itself:
| 1 2 3 4 5 6 7 |
|
Therefore, if an iterator has these member types defined does not need to explicitly specialize the iterator_traits class.
The iterator_traits class template also comes with specialized versions for pointers and pointers to const:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
So there is no need to define specific iterator_traits specializations for pointer types.
