1[/ 2 Copyright 2010 Neil Groves 3 Distributed under the Boost Software License, Version 1.0. 4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5/] 6[section:for_each for_each] 7 8[heading Prototype] 9 10`` 11template< 12 class SinglePassRange1, 13 class SinglePassRange2, 14 class BinaryFunction 15 > 16BinaryFunction for_each(const SinglePassRange1& rng1, 17 const SinglePassRange2& rng2, 18 BinaryFunction fn); 19 20template< 21 class SinglePassRange1, 22 class SinglePassRange2, 23 class BinaryFunction 24 > 25BinaryFunction for_each(const SinglePassRange1& rng1, 26 SinglePassRange2& rng2, 27 BinaryFunction fn); 28 29template< 30 class SinglePassRange1, 31 class SinglePassRange2, 32 class BinaryFunction 33 > 34BinaryFunction for_each(SinglePassRange1& rng1, 35 const SinglePassRange2& rng2, 36 BinaryFunction fn); 37 38template< 39 class SinglePassRange1, 40 class SinglePassRange2, 41 class BinaryFunction 42 > 43BinaryFunction for_each(SinglePassRange1& rng1, 44 SinglePassRange2& rng2, 45 BinaryFunction fn); 46`` 47 48[heading Description] 49 50`for_each` traverses forward through `rng1` and `rng2` simultaneously. 51For each iteration, the element `x` is used from `rng1` and the corresponding 52element `y` is used from `rng2` to invoke `fn(x,y)`. 53 54Iteration is stopped upon reaching the end of the shorter of `rng1`, or `rng2`. 55It is safe to call this function with unequal length ranges. 56 57[heading Definition] 58 59Defined in the header file `boost/range/algorithm_ext/for_each.hpp` 60 61[heading Requirements] 62 63# `SinglePassRange1` is a model of the __single_pass_range__ Concept. 64# `SinglePassRange2` is a model of the __single_pass_range__ Concept. 65# `BinaryFunction` is a model of the `BinaryFunctionConcept`. 66# `SinglePassRange1`'s value type is convertible to `BinaryFunction`'s first argument type. 67# `SinglepassRange2`'s value type is convertible to `BinaryFunction`'s second argument type. 68 69[heading Complexity] 70 71Linear. Exactly `min(distance(rng1), distance(rng2))` applications of `BinaryFunction`. 72 73[endsect] 74