Conventions
Explore the essential conventions for using C++ algorithms effectively. Understand naming patterns for algorithm variants, iterator types, predicates, and how to ensure valid destination ranges. This lesson helps you grasp how to apply algorithms correctly to improve code clarity and performance.
We'll cover the following...
We'll cover the following...
To use the algorithms, you have to keep a few rules in your head.
The algorithms are defined in various headers.
<algorithm>:
Contains the general algorithms.
<numeric>:
Contains the numeric algorithms.
Many of the algorithms have the name suffix
_if and _copy.
_if:
The algorithm can be parametrized by a predicate.
_copy:
The algorithm copies its elements in another range.
Algorithms like auto num = ...