Iterators Are Fundamental

Get an idea about the basics of iterators in C++ 20.

We'll cover the following

Iterators are a fundamental concept in the STL. Iterators are implemented with the semantics of C pointers, using the same increment, decrement, and dereference operators. The pointer idiom is familiar to most C/C++ programmers, and it allows algorithms such as std::sort and std::transform to work on primitive memory buffersPrimitive memory buffers refer to a type of data structure that provides a fixed-size, contiguous block of memory for temporarily storing data. as well as STL containers.

The STL uses iterators to navigate the elements of its container classes. Most containers include begin() and end() iterators. These are usually implemented as member functions that return an iterator object. The begin() iterator points to the initial container element, and the end() iterator points past the final element:

Get hands-on with 1200+ tech skills courses.