```
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 and CopyAssignable types. In the range [first, last], binary_op shall neither modify elements nor invalidate iterators or subranges.281

The use of fully closed ranges is intentional.

accumulate is similar to the APL reduction operator and Common Lisp reduce function, but it avoids the difficulty of defining the result of reduction on an empty sequence by always requiring an initial value.