Predefined Concepts - Part II
Get an overview of important predefined concepts of C++20.
We'll cover the following
A vector supports a random_access_iterator
. A random_access_iterator
is also a bidirectional_iterator
. Hence a std::vector
also supports a bidirectional_iterator
.
General utilities library
Note: The “General utilities library” chapter in the standard has only special memory concepts; therefore, I don’t refer to them here.
Iterators library
The iterators library has many important concepts. They are defined in the <iterator>
header. Here are the iterator categories:
input_iterator
output_iterator
forward_iterator
bidirectional_iterator
random_access_iterator
contiguous_iterator
The six categories of iterators correspond to the respective iterator concepts. The table below provides two interesting pieces of information. For the three most prominent iterator categories, the table shows their properties and the associated standard library containers.
Iterator Category | Properties | Containers |
---|---|---|
std::forward_iterator |
++It, It++ ,*It It == It2, It != It2 |
std::unordered_set std::unordered_map std::unordered_multiset std::unordered_multimap std::forward_list |
std::bidirectional_iterator |
--It, It-- | std::set std::map std::multiset std::multimap std::list |
std::random_access_iterator |
It[i] It += n, It -= n t += n, It -= n n + It It - It2 It < It2, It <= It2 It > It2, It >= It2 |
std::array std::vector std::deque std::string |
Get hands-on with 1200+ tech skills courses.