28 Algorithms library [algorithms]

28.6 Mutating sequence operations [alg.modifying.operations]

28.6.4 Transform [alg.transform]

template<class InputIterator, class OutputIterator, class UnaryOperation> OutputIterator transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class UnaryOperation> ForwardIterator2 transform(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 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); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class ForwardIterator, class BinaryOperation> ForwardIterator transform(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator result, BinaryOperation binary_op);
Requires: op and binary_­op shall not invalidate iterators or subranges, or modify elements in the ranges
  • [first1, last1],
  • [first2, first2 + (last1 - first1)], and
  • [result, result + (last1 - first1)].265
Effects: Assigns through every iterator i in the range [result, result + (last1 - first1)) a new corresponding value equal to op(*(first1 + (i - result))) or binary_­op(*(first1 + (i - result)), *(first2 + (i - result))).
Returns: result + (last1 - first1).
Complexity: Exactly last1 - first1 applications of op or binary_­op.
This requirement also applies to the overload with an ExecutionPolicy .
Remarks: result may be equal to first in case of unary transform, or to first1 or first2 in case of binary transform.
The use of fully closed ranges is intentional.