Name

transform function template — Copies one or two ranges after applying an operator to each element

Synopsis

template<typename InIter, typename OutIter, typename UnaryOperation>
  OutIter transform(InIter first, InIter last, OutIter result,
                    UnaryOperation unop);
template<typename InIter1, typename InIter2, typename OutIter, 
         typename BinaryOperation>
  OutIter transform(InIter1 first1, InIter1 last1, InIter2 first2, 
                    OutIter result, BinaryOperation binop);

The transform function template assigns a new value to each element in the range that starts at result. In the first case, the new value is unop(*iter), in which iter is an iterator over [first, last).

In the second case, the new value is binop(*iter1, *iter2), in which iter1 ranges over [first1, last1) and iter2 iterates over the range that starts at first2. The second input range must be at least as long as the first.

The return value is one past the end of the result range. The result range can be the same as any of the input ranges.