Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Iterators are a generalization of pointers that allow a C++ program to work with different data structures (containers) in a uniform manner [ISO/IEC 14882-2014]. Pointers, references, and iterators share a close relationship in which it is required that referencing values through such an object be done through a valid iterator (or , pointer or reference). Storing an iterator, reference, or pointer to an element within a container for any length of time comes with a risk that the underlying container may be modified such that the stored value is invalidated. For instance, when a sequence container such as std::vector requires an underlying reallocation, outstanding iterators and references will be invalidated [Kalev 99]. Use only a valid pointer, reference, or iterator to refer to an element of a container.

...