Iterator Concepts
From Cppreference
C++ Standard Library |
---|
Iterator library |
Contents |
[edit] Notation
In the following, as in the standard, the following notation is used:
- X is the iterator type being discussed
- a and b are instances of the iterator, with type X
- reference refers to iterator_traits<X>::reference
- difference_type refers to iterator_traits<X>::difference_type
[edit] Iterator Requirements
Iterator is a general concept that does not guarantee much beyond the ability to advance and dereference elements. Formally, an iterator has the following requirements:
- CopyConstructable
- CopyAssignable
- Destructible
- Swappable
In addition, the following expressions are valid:
- *a returns type reference as long as the itearator is dereferencable.
- ++a returns X&
Examples:
- All iterators in the standard library model the Iterator concept.