Result type of AveragingCounter<int>::mean
The AveragingAccumulator
has some disadvantages when used with integer types. I think constraining the return type of mean()
to be the same as the underlying type is maybe not a good default as it forces the use of floating point types even if the underlying values are integers:
https://gitlab.cern.ch/gaudi/Gaudi/blob/master/GaudiKernel/GaudiKernel/Counters.h#L535-546
/**
* AveragingAccumulator. A AveragingAccumulator is an Accumulator able to compute an average
* @see Gaudi::Accumulators for detailed documentation
*/
template <typename Arithmetic, atomicity Atomicity = atomicity::full>
struct AveragingAccumulator : AccumulatorSet<Arithmetic, Atomicity, CountAccumulator, SumAccumulator> {
Arithmetic mean() const
{
auto n = this->nEntries();
return n ? this->sum() / n : Arithmetic{};
}
};
I wonder if we should introduce an additional typename ResultType = double
for mean()
. Or could it be simply auto mean() const
? The same would apply for all other Accumulators and their methods where divisions are involved.