Partial sum

OutputIterator partial_sum (InputIterator first, InputIterator last, OutputIterator result) Function
OutputIterator partial_sum (InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op) Function

template 
OutputIterator partial_sum(InputIterator first, InputIterator last,
                           OutputIterator result);

template 
OutputIterator partial_sum(InputIterator first, InputIterator last,
                           OutputIterator result, BinaryOperation binary_op);

partial_sum assigns to every iterator i in the range [result, result + (last - first)) a value correspondingly equal to ((...(*first + *(first + 1)) + ... ) + *(first + (i - result))) or binary_op(binary_op(..., binary_op(*first, *(first + 1)),...), *(first + (i - result))). partial_sum returns result + (last - first). Exactly (last - first) - 1 applications of binary_op are performed. binary_op is expected not to have any side effects. Result may be equal to first.