Standard C++ Library Class Reference

Click on the banner to return to the Class Reference home page.
©Copyright 1996 Rogue Wave Software
for_each
Algorithm
Summary
Applies a function to each element in a range.
Contents
Synopsis
Description
Complexity
Example
Warning
See Also
Synopsis
#include <algorithm>
template <class InputIterator, class Function>
void for_each(InputIterator first, InputIterator last,
Function f);
Description
The for_each algorithm applies function f to all members of the sequence in the range [first,
last), where first and last are iterators that define the sequence. Since this a non-mutating
algorithm, the function f cannot make any modifications to the sequence, but it can achieve
results through side effects (such as copying or printing). If f returns a result, the result is
ignored.