Search⌘ K

for_each

Explore how to use std for_each to apply a unary function to each element in a range, and understand the new C++17 for_each_n algorithm that processes the first n elements. This lesson helps you effectively manipulate container elements using standard algorithms.

We'll cover the following...

std::for_each applies a unary callable to each element of its range. The range is given by the input iterators.

C++
UnFunc std::for_each(InpIt first, InpIt second, UnFunc func)
void std::for_each(ExePol pol, FwdIt first, FwdIt second, UnFunc func)

...