(C++) std::accumulate

January 18, 2018 ยท View on GitHub

std::accumulate is an STL algorithm to accumulate a range. std::accumulate is defined in numeric.h.

A definition of std::accumulate

template <class InputIterator, class T>
T accumulate (InputIterator first, InputIterator last, T init)
{
  while (first != last) init = init + *first++;
  return init;
}