absl::c_accumulate

c_accumulate overloads

Synopses

Declared in <absl/algorithm/container.h>

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.

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

Overload of c_accumulate() for using a binary operations other than addition for computing the accumulation.

template<
    typename Sequence,
    typename T,
    typename BinaryOp>
constexpr
std::decay_t<T>
c_accumulate(
    Sequence const& sequence,
    T&& init,
    BinaryOp&& binary_op);
» more...

Return Value

The accumulated result.

Parameters

NameDescription
sequenceThe container whose elements to accumulate.
initThe initial value of the accumulation.
binary_opThe binary operation used to combine values.