Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::accumulate

 

Algorithm to accumulate a range. std::accumulate is defined in numeric.h. Use accumulate_if if you need to supply a predicate.

 

 

 

 

 

 

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;
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict