template <class InputIterator, class T>
T accumulate(InputIterator first, InputIterator last, T init);
template <class InputIterator, class T, class BinaryOperation>
T accumulate(InputIterator first, InputIterator last, T init,
BinaryOperation binary_op);
Requires:
T shall meet the requirements of
CopyConstructible (Table
24)
and
CopyAssignable (Table
26) types
. In the range
[first, last],
binary_op
shall neither modify elements nor invalidate iterators or subranges
.Effects:
Computes its result by initializing the accumulator
acc
with the initial value
init
and then modifies it with
acc = acc + *i
or
acc = binary_op(acc, *i)
for every iterator
i
in the range
[first, last)
in order
.