Skip to content

strata::Sum

Part of Reductions.

template <typename Acc = void>
struct strata::Sum;

The sum, in Acc if one is given, else in the type T + T gives.

Sum<double> sums floats in double, and ints without overflow far longer. The sum of no values is the default-constructed accumulator, zero.

Template parameters

Name Description
Acc The accumulator type, or void for the type T + T gives: an int for an int8, a float for a float, a length for a length.

Members

accumulator

template <typename T>
using strata::Sum< Acc >::accumulator = detail::accumulate_as<Acc, T>::type

What the sum keeps while values come in.

identity

template <typename T>
constexpr accumulator<T> identity() const

The sum of no values: zero.

accumulate

template <typename A, typename T>
constexpr A accumulate(A acc, const T &value) const

acc plus one value.

combine

template <typename A>
constexpr A combine(A lhs, A rhs) const

The sum of two partial sums.

finalize

template <typename A>
constexpr A finalize(A acc, std::size_t) const

The accumulator itself, whatever the count.