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)
6 [section:transform transform]
12 class SinglePassRange1,
16 OutputIterator transform(const SinglePassRange1& rng,
21 class SinglePassRange1,
22 class SinglePassRange2,
26 OutputIterator transform(const SinglePassRange1& rng1,
27 const SinglePassRange2& rng2,
34 [*UnaryOperation version:]
36 `transform` assigns the value `y` to each element `[out, out + distance(rng)), y = fun(x)` where `x` is the corresponding value to `y` in `rng1`. The return value is `out + distance(rng)`.
38 [*BinaryOperation version:]
40 `transform` assigns the value `z` to each element `[out, out + min(distance(rng1), distance(rng2))), z = fun(x,y)` where `x` is the corresponding value in `rng1` and `y` is the corresponding value in `rng2`. This version of `transform` stops upon reaching either the end of `rng1`, or the end of `rng2`. Hence there isn't a requirement for `distance(rng1) == distance(rng2)` since there is a safe guaranteed behaviour, unlike with the iterator counterpart in the standard library.
42 The return value is `out + min(distance(rng1), distance(rng2))`.
46 Defined in the header file `boost/range/algorithm/transform.hpp`
48 [heading Requirements]
50 [*For the unary versions of transform:]
52 * `SinglePassRange1` is a model of the __single_pass_range__ Concept.
53 * `OutputIterator` is a model of the `OutputIteratorConcept`.
54 * `UnaryOperation` is a model of the `UnaryFunctionConcept`.
55 * `SinglePassRange1`'s value type must be convertible to `UnaryFunction`'s argument type.
56 * `UnaryFunction`'s result type must be convertible to a type in `OutputIterator`'s set of value types.
58 [*For the binary versions of transform:]
60 * `SinglePassRange1` is a model of the __single_pass_range__ Concept.
61 * `SinglePassRange2` is a model of the __single_pass_range__ Concept.
62 * `OutputIterator` is a model of the `OutputIteratorConcept`.
63 * `BinaryOperation` is a model of the `BinaryFunctionConcept`.
64 * `SinglePassRange1`'s value type must be convertible to `BinaryFunction`'s first argument type.
65 * `SinglePassRange2`'s value type must be convertible to `BinaryFunction`'s second argument type.
66 * `BinaryOperation`'s result type must be convertible to a type in `OutputIterator`'s set of value types.
68 [heading Precondition:]
70 [*For the unary version of transform:]
72 * `out` is not an iterator within the range `[begin(rng1) + 1, end(rng1))`.
73 * `[out, out + distance(rng1))` is a valid range.
75 [*For the binary version of transform:]
77 * `out` is not an iterator within the range `[begin(rng1) + 1, end(rng1))`.
78 * `out` is not an iterator within the range `[begin(rng2) + 1, end(rng2))`.
79 * `[out, out + min(distance(rng1), distance(rng2)))` is a valid range.
84 Linear. The operation is applied exactly `distance(rng1)` for the unary version and `min(distance(rng1), distance(rng2))` for the binary version.