Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Algorithm to accumulate a range. std::accumulate is defined in numeric.h. Use accumulate_if if you need to supply a predicate.
With std::accumulate, for example, you could sum up the values of a std::vector like the example below:
#include <cassert> |
template <class InputIterator, class T> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.