...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::accumulators::weighted_sum — Holds sum of weights and its variance estimate.
// In header: <boost/histogram/accumulators/weighted_sum.hpp> template<typename RealType> class weighted_sum { public: // construct/copy/destruct weighted_sum() = default; explicit weighted_sum(const RealType &) noexcept; weighted_sum(const RealType &, const RealType &) noexcept; // public member functions weighted_sum & operator++(); template<typename T> weighted_sum & operator+=(const T &); template<typename T> weighted_sum & operator+=(const weighted_sum< T > &); weighted_sum & operator *=(const RealType &); bool operator==(const RealType &) const noexcept; template<typename T> bool operator==(const weighted_sum< T > &) const noexcept; template<typename T> bool operator!=(const T &) const noexcept; const RealType & value() const noexcept; const RealType & variance() const noexcept; template<typename T> explicit operator T() const; template<typename Archive> void serialize(Archive &, unsigned); };
weighted_sum
public member functionsweighted_sum & operator++();Increment by one.
template<typename T> weighted_sum & operator+=(const T & value);Increment by value.
template<typename T> weighted_sum & operator+=(const weighted_sum< T > & rhs);Added another weighted sum.
weighted_sum & operator *=(const RealType & x);Scale by value.
bool operator==(const RealType & rhs) const noexcept;
template<typename T> bool operator==(const weighted_sum< T > & rhs) const noexcept;
template<typename T> bool operator!=(const T & rhs) const noexcept;
const RealType & value() const noexcept;Return value of the sum.
const RealType & variance() const noexcept;Return estimated variance of the sum.
template<typename T> explicit operator T() const;
template<typename Archive> void serialize(Archive & ar, unsigned);