template<class InputIterator, class Function>
Function for_each(InputIterator first, InputIterator last, Function f);
Requires: Function shall meet the requirements of MoveConstructible (Table [tab:moveconstructible]). [ Note: Function need not meet the requirements of CopyConstructible (Table [tab: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 non-constant functions through the dereferenced iterator. — end note ]
Returns: f.
Complexity: Applies f exactly last - first times.
Remarks: If f returns a result, the result is ignored.
template<class ExecutionPolicy, class InputIterator, class Function>
void for_each(ExecutionPolicy&& exec,
InputIterator first, InputIterator last,
Function f);
Requires: Function shall meet the requirements of CopyConstructible.
Effects: Applies f to the result of dereferencing every iterator in the range [first, last). [ Note: If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator. — end note ]
Complexity: Applies f exactly last - first times.
Remarks: If f returns a result, the result is ignored.
Notes: Does not return a copy of its Function parameter, since parallelization may not permit efficient state accumulation.
template<class InputIterator, class Size, class Function>
InputIterator for_each_n(InputIterator first, Size n, Function f);
Requires: Function shall meet the requirements of MoveConstructible [ Note: Function need not meet the requirements of CopyConstructible. — end note ]
Requires: n >= 0.
Effects: Applies f to the result of dereferencing every iterator in the range [first, first + n) in order. [ Note: If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator. — end note ]
Returns: first + n.
Remarks: If f returns a result, the result is ignored.
template<class ExecutionPolicy, class InputIterator, class Size, class Function>
InputIterator for_each_n(ExecutionPolicy&& exec, InputIterator first, Size n,
Function f);
Requires: Function shall meet the requirements of CopyConstructible.
Requires: n >= 0.
Effects: Applies f to the result of dereferencing every iterator in the range [first, first + n). [ Note: If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator. — end note ]
Returns: first + n.
Remarks: If f returns a result, the result is ignored.