C++ 23 · Containers and algorithms

Sum a range

Add up the elements, starting from 0.

#include <numeric>

int total = std::accumulate(v.begin(), v.end(), 0);

Official C++ 23 documentation

More containers and algorithms commands

All containers and algorithms commands · C++ 23 cheatsheet

Was this page helpful?