absl::c_accumulate

Container-based version of the <numeric> std::accumulate() function to accumulate the element values of a container to init and return that accumulation by value.

Synopsis

Declared in <absl/algorithm/container.h>

template<
    typename Sequence,
    typename T>
constexpr
std::decay_t<T>
c_accumulate(
    Sequence const& sequence,
    T&& init);

Description

Note: Due to a language technicality this function has return type std::decay_t<T>. As a user of this function you can casually read this as "returns T by value" and assume it does the right thing.

Return Value

The accumulated result.

Parameters

NameDescription
sequenceThe container whose elements to accumulate.
initThe initial value of the accumulation.