...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 ValueType> class weighted_sum { public: // types typedef ValueType value_type; typedef const value_type & const_reference; // construct/copy/destruct weighted_sum() = default; weighted_sum(const_reference) noexcept; template<typename T> weighted_sum(const weighted_sum< T > &) noexcept; weighted_sum(const_reference, const_reference) noexcept; // public member functions weighted_sum & operator++(); weighted_sum & operator+=(const weight_type< value_type > &); weighted_sum & operator+=(const weighted_sum &); weighted_sum & operator/=(const weighted_sum &); weighted_sum & operator *=(const_reference); bool operator==(const weighted_sum &) const noexcept; bool operator!=(const weighted_sum &) const noexcept; const_reference value() const noexcept; const_reference variance() const noexcept; explicit operator const_reference() const; template<typename Archive> void serialize(Archive &, unsigned); };
weighted_sum
public
construct/copy/destructweighted_sum() = default;
weighted_sum(const_reference value) noexcept;Initialize sum to value and allow implicit conversion.
template<typename T> weighted_sum(const weighted_sum< T > & s) noexcept;Allow implicit conversion from sum<T>
weighted_sum(const_reference value, const_reference variance) noexcept;Initialize sum to value and variance.
weighted_sum
public member functionsweighted_sum & operator++();Increment by one.
weighted_sum & operator+=(const weight_type< value_type > & w);Increment by weight.
weighted_sum & operator+=(const weighted_sum & rhs);Added another weighted sum.
weighted_sum & operator/=(const weighted_sum & rhs);Divide by another weighted sum.
weighted_sum & operator *=(const_reference x);Scale by value.
bool operator==(const weighted_sum & rhs) const noexcept;
bool operator!=(const weighted_sum & rhs) const noexcept;
const_reference value() const noexcept;Return value of the sum.
const_reference variance() const noexcept;Return estimated variance of the sum.
explicit operator const_reference() const;
template<typename Archive> void serialize(Archive & ar, unsigned);