Forward iterators and stronger are required to refer to some external sequence (see [forward.iterators]/6 which says “If a
and b
are both dereferenceable, then a == b
if and only if *a
and *b
are bound to the same object.”)
This means they are generally just a lightweight handle onto something else (e.g. a pointer to an element or a node in a container) and so there is little reason not to require that they can be default constructed (even if default construction creates a singular iterator that can’t be used for anything until assigned a new value). It’s possible for all non-pathological* forward iterators to support default construction, and relying on that makes some algorithms easier to implement.
Iterators which only meet the input iterator or output iterator requirements (and nothing stronger) might contain state within themselves which is modified by operator++
and so it might not be possible for that state to be default-constructed. No algorithm that only operates on input/output iterators needs to default construct them, so it isn’t required.
- spot the “no true scotsman” argument here 😉