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

Name

Description

sequence

The container whose elements to accumulate.

init

The initial value of the accumulation.

Created with MrDocs