Understanding C++20 contiguous iterators and container categories
This hard C++ language-knowledge question tests whether you can distinguish between the six iterator categories introduced or refined in C++20, with particular focus on the newly formalized contiguous iterator concept. It requires precise knowledge of the standard library's container guarantees.
Contiguous iterators guarantee that the elements they point to are stored in consecutive memory locations—a property that is formally specified in C++20 but was only implicitly true for certain containers in earlier standards. Identifying which containers meet this guarantee demands understanding both the semantics of each container type and the formal definition of contiguity as standardized.
- Iterator categories: input, output, forward, bidirectional, random-access, and contiguous
- Memory layout guarantees of standard containers
- Differences between dynamic arrays, static arrays, and node-based structures
- C++20 iterator concepts and formal specifications