Namespaces
Variants
Views
Actions

std::for_each

From cppreference.com
< cpp‎ | algorithm
Revision as of 12:08, 17 August 2011 by Cubbi (Talk | contribs)

Template:cpp/algorithm/sidebar Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <algorithm>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
template< class InputIterator, class UnaryFunction >
UnaryFunction for_each( InputIterator first, InputIterator last, UnaryFunction f );
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

Applies the given function object f to the result of dereferencing every iterator in the range [first, last), in order. If InputIterator is a mutable iterator, f may modify the elements of the range through the dereferenced iterator. If f returns a result, the result is ignored.

Contents

Parameters

first, last - the range to apply the function to
f - the unary function object to be applied (MoveConstructible in (C++11))

Return value

The function that was applied, f Template:mark pre c++11 version
The result of Template:cpp Template:mark c++11 version

Complexity

linear in the distance between first and last

Equivalent function

Template:eq fun cpp

Example

Template:example cpp

Template:example cpp

See also

Template:cpp/algorithm/dcl list transform