...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::histogram::algorithm::sum — Compute the sum over all histogram cells, including underflow/overflow bins.
// In header: <boost/histogram/algorithm/sum.hpp> template<typename A, typename S> auto sum(const histogram< A, S > & h);
If the value type of the histogram is an integral or floating point type, boost::accumulators::sum<double> is used to compute the sum, else the original value type is used. Compilation fails, if the value type does not support operator+=.
Return type is double if the value type of the histogram is integral or floating point, and the original value type otherwise.