Just as a regular pointer to an array guarantees that there is a pointer value pointing past the last element
of the array, so for any iterator type there is an iterator value that points past the last element of a
corresponding sequence
. Values of an iterator
i
for which the expression
*i is defined
are called
dereferenceable. The library never assumes that past-the-end values are dereferenceable
. Iterators can also have singular values that are not associated with any
sequence
. Results of most expressions are undefined for singular values;
the only exceptions are destroying an iterator that holds a singular value,
the assignment of a non-singular value to
an iterator that holds a singular value, and, for iterators that meet the
Cpp17DefaultConstructible requirements, using a value-initialized iterator
as the source of a copy or move operation
. [
Note 2:
This guarantee is not
offered for default-initialization, although the distinction only matters for types
with trivial default constructors such as pointers or aggregates holding pointers
. β
end note]
In these cases the singular
value is overwritten the same way as any other value
. Dereferenceable
values are always non-singular
.