Using the std::copy_if algorithm

The standard library provides over 100 general-purpose algorithms. As we discussed in the introductory lesson for the ranges library earlier, these have one thing in common: they work with abstract ranges with the help of iterators. They take iterators as arguments, and they sometimes return iterators. That makes it cumbersome to repeatedly use with standard containers or arrays. Here’s an example:

Get hands-on with 1200+ tech skills courses.