25 Algorithms library [algorithms]

25.2 Non-modifying sequence operations [alg.nonmodifying]

25.2.4 For each [alg.foreach]

template<class InputIterator, class Function> Function for_each(InputIterator first, InputIterator last, Function f);

Requires: Function shall meet the requirements of MoveConstructible (Table [moveconstructible]). [ Note: Function need not meet the requirements of CopyConstructible (Table [copyconstructible]).  — end note ]

Effects: Applies f to the result of dereferencing every iterator in the range [first,last), starting from first and proceeding to last - 1. [ Note: If the type of first satisfies the requirements of a mutable iterator, f may apply nonconstant functions through the dereferenced iterator. — end note ]

Returns: std::move(f).

Complexity: Applies f exactly last - first times.

Remarks: If f returns a result, the result is ignored.