adjacent_difference()
By default, creates a new sequence in which the value of each new element, other than the first one, represents the difference of the current and the preceding element. Given the sequence {0,1,1,2,3,5,8}, the new sequence is {0,1,0,1,1,2,3}. A binary operation can be passed in to override subtraction. For example, times<int> yields the sequence {0,0,1,2,6,15,40}. The third argument is an iterator that addresses the container into which to copy the results.
#include <numeric>
adjacent_difference( ilist.begin(), ilist.end(), iresult.begin() );
adjacent_difference( ilist.begin(), ilist.end(), iresult.begin(),
times<int>() );
|