Declaration
template <class InputIterator, class OutputIterator, class UnaryOperation> OutputIterator transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op); template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation> OutputIterator transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation binary_op);
Description From the sequence in the range [ first, last) , the first transform function generates the sequence . The sequence that results is the original sequence with a unary operation (or unary function) applied to each element of the original sequence.
From the sequence in the range [ first1, last1) , and the sequence in the range beginning at first2 , the second transform function generates the sequence
. The sequence that results is the two original sequences combined with a binary operation (or binary function) , element by element.
For both functions, the results are placed in a range of size n beginning at the location referenced by result, and the past-the-end iterator is returned.
Type requirements
Group Mutating sequence operations.
Time complexity Linear.
The number of applications of op is the size of the range [ first, last)
and the number of applications of binary_op is the size of of the range [ first1, last1) .
Space complexity Constant.
Mutative? Yes.
Example Select here to view the source code for the example.
Implementation Select here to view source code (Copyright (C) 1994, Hewlett-Packard Company) for this algorithm.