Adjacent difference

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

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

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

adjacent_difference assigns to every element referred to by iterator i in the range [result + 1, result + (last - first)) a value correspondingly equal to *(first + (i - result)) - *(first + (i - result) - 1) or binary_op(*(first + (i - result)), *(first + (i - result) - 1)). result gets the value of *first. adjacent_difference 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.