Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

for_each
PrevUpHomeNext
Prototype

template<
    class SinglePassRange,
    class UnaryFunction
    >
UnaryFunction for_each(SinglePassRange& rng, UnaryFunction fun);

template<
    class SinglePassRange,
    class UnaryFunction
    >
UnaryFunction for_each(const SinglePassRange& rng, UnaryFunction fun);

Description

for_each traverses forward through rng and for each element x it invokes fun(x).

Definition

Defined in the header file boost/range/algorithm/for_each.hpp

Requirements
  • SinglePassRange is a model of the Single Pass Range Concept.
  • UnaryFunction is a model of the UnaryFunctionConcept.
  • UnaryFunction does not apply any non-constant operation through its argument.
  • SinglePassRange's value type is convertible to UnaryFunction's argument type.
Complexity

Linear. Exactly distance(rng) applications of UnaryFunction.


PrevUpHomeNext