Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Class template weighted_sum

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 {
  // 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++();
  template<typename T> weighted_sum & operator+=(const weight_type< T > &);
  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/destruct

  1. weighted_sum() = default;
  2. weighted_sum(const_reference value) noexcept;
    Initialize sum to value and allow implicit conversion.
  3. template<typename T> weighted_sum(const weighted_sum< T > & s) noexcept;
    Allow implicit conversion from sum<T>
  4. weighted_sum(const_reference value, const_reference variance) noexcept;
    Initialize sum to value and variance.

weighted_sum public member functions

  1. weighted_sum & operator++();
    Increment by one.
  2. template<typename T> weighted_sum & operator+=(const weight_type< T > & w);
    Increment by weight.
  3. weighted_sum & operator+=(const weighted_sum & rhs);
    Added another weighted sum.
  4. weighted_sum & operator *=(const_reference x);
    Scale by value.
  5. bool operator==(const weighted_sum & rhs) const noexcept;
  6. bool operator!=(const weighted_sum & rhs) const noexcept;
  7. const_reference value() const noexcept;
    Return value of the sum.
  8. const_reference variance() const noexcept;
    Return estimated variance of the sum.
  9. explicit operator const_reference() const;
  10. template<typename Archive> void serialize(Archive & ar, unsigned);