[accumulate] (original) (raw)
26 Algorithms library [algorithms]
26.10 Generalized numeric operations [numeric.ops]
26.10.3 Accumulate [accumulate]
template<class InputIterator, class T> constexpr T accumulate(InputIterator first, InputIterator last, T init);template<class InputIterator, class T, class BinaryOperation> constexpr T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
In the range [first, last],binary_op neither modifies elements nor invalidates iterators or subranges.206
Effects: Computes its result by initializing the accumulator acc with the initial value initand then modifies it withacc = std::move(acc) + *i oracc = binary_op(std::move(acc), *i)for every iterator i in the range [first, last) in order.207