transform

C/C++ Reference

transform
Syntax:
  #include <algorithm>
  iterator transform( iterator start, iterator end, iterator result, UnaryFunction f );
  iterator transform( iterator start1, iterator end1, iterator start2, iterator result, BinaryFunction f );

The transform() algorithm applies the function f to some range of elements, storing the result of each application of the function in result.

The first version of the function applies f to each element in [start,end) and assigns the first output of the function to result, the second output to (result+1), etc.

The second version of the transform() works in a similar manner, except that it is given two ranges of elements and calls a binary function on a pair of elements.

Related topics: