c_plus_plus_iterator

C++ Iterator library

https://en.cppreference.com/w/cpp/iterator

The iterator library provides definitions for

kinds of iterators as well as iterator traits, adaptors, and utility functions.

Iterator categories

There are

kinds of iterators:

,

,

,

,

}}.

Instead of being defined by specific types, each category of iterator is defined by the operations that can be performed on it. This definition means that any type that supports the necessary operations can be used as an iterator – for example, a pointer supports all of the operations required by

, so a pointer can be used anywhere a

is expected.

All of the iterator categories (except

) can be organized into a hierarchy, where more powerful iterator categories (e.g.

) support the operations of less powerful categories (e.g.

). If an iterator falls into one of these categories and also satisfies the requirements of

, then it is called a mutable iterator and supports both input and output. Non-mutable iterators are called constant iterators.

Iterator category Defined operations

  • read
  • increment (without multiple passes)

|-

  • increment (with multiple passes)

|-

  • decrement

|-

  • random access

|-

  • contiguous storage

|-

Iterators that fall into one of the above categories and also meet the requirements of

are called mutable iterators.

  • write
  • increment (without multiple passes)

|}

Note:

category was only formally specified in C++17, but the iterators of

,

,

, and

, as well as pointers into C arrays are often treated as a separate category in pre-C++17 code.

=== C++20 iterator concepts === C++20 introduces a new system of iterators based on concepts that are different from C++17 iterators. While the basic taxonomy remains similar, the requirements for individual iterator categories are somewhat different.

=== Iterator associated types ===

=== Iterator primitives ===

=== Iterator customization points ===

=== Algorithm concepts and utilities === C++20 also provides a set of concepts and related utility templates designed to ease constraining common algorithm operations.

=== Iterator adaptors ===

=== Stream iterators ===

=== Iterator operations ===

=== Range access === These non-member functions provide a generic interface for containers, plain arrays, and

.

c_plus_plus_iterator.txt · Last modified: 2024/04/28 03:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki