Concepts in the <iterator> Header
Get an overview of the concepts in the <iterator> header that are shipped with the C++ standard library.
We'll cover the following
In the <iterator>
header, we’ll find concepts that can be very useful in dealing with algorithms. The functions in <iterator>
do not operate directly on containers but through iterators
.
std::indirect_unary_predicate<F, I>
Some concepts are related to callables. For those, we can specify that we accept only unary predicates.
A predicate is a callable that returns either a bool
value or a value that can be converted to a bool
. A unary predicate is a predicate that takes one parameter as its input.
The following example is just for demonstration. It will generate an error when compiled. Let’s look at the code below to get an idea of how unary predicates work.
Get hands-on with 1200+ tech skills courses.