for_each
std::for_each
applies a unary callable to each element of its range. The range is given by the input iterators.
std::for_each
when used without an explicit execution policy is a special algorithm because it returns its callable argument. If you invoke std::for_each
with a function object, you can store the result of the function call directly in the function object.
std::for_each_n
is new with C++17 and applies a unary callable to the first n elements of its range. The range is given by an input iterator and a size.