Understanding iterator requirements
Iterators in C++ serve as a consistent interface to various data structures, such as containers and, since C++20, ranges. The iterator library supplies definitions for iterators and associated traits, adaptors, and utility functions.
Given that iterators extend the idea of pointers, they inherently adopt many pointer semantics in C++. Consequently, any function template accepting iterators can also seamlessly work with regular pointers.
Iterators are categorized into six types: LegacyInputIterator, LegacyOutputIterator, LegacyForwardIterator, LegacyBidirectionalIterator, LegacyRandomAccessIterator, and LegacyContiguousIterator. Instead of being determined by their intrinsic types, these categories are distinguished by the operations they support. As an illustration, pointers accommodate all the operations defined for LegacyRandomAccessIterator, allowing them to be utilized wherever a LegacyRandomAccessIterator is required.
These iterator...