diff --git a/doc/concepts/Accumulator.qbk b/doc/concepts/Accumulator.qbk index 60ef5774..05ffa189 100644 --- a/doc/concepts/Accumulator.qbk +++ b/doc/concepts/Accumulator.qbk @@ -13,7 +13,7 @@ An [*Accumulator] is a functor which consumes the argument to update some intern * `A` is a type meeting the requirements of [*Accumulator] * `a` and `b` are values of type `A` -* `ts...` is a pack of values +* `ts...` is a pack of values of arbitrary types [table Valid expressions [[Expression] [Returns] [Semantics, Pre/Post-conditions]] @@ -21,7 +21,7 @@ An [*Accumulator] is a functor which consumes the argument to update some intern [`a(ts...)` or `++a`] [] [ - Either a call operator accepting a fixed number of arguments must be implemented, or the pre-increment operator. + Either a call operator accepting a fixed number of arguments must be implemented, or the pre-increment operator. The call operator may not be templated and not overloaded, except to support weights as described under optional features. ] ] [ @@ -44,9 +44,19 @@ An [*Accumulator] is a functor which consumes the argument to update some intern * `A` is a type meeting the requirements of [*Accumulator] * `a` and `b` are values of type `A` +* `w` is a value of type [classref boost::histogram::weight_type], where `T` is a number type +* `ts...` is a pack of values of arbitrary types +* `v` is a number value (integral or floating point) [table Valid expressions [[Expression] [Return] [Semantics, Pre/Post-conditions]] +[ + [`a += v` or `a(w, ts...)`] + [] + [ + Does a weighted fill of the accumulator. Use this to implement weight support for an accumulator that is normally filled with `++a` or `a(ts...)`, respectively. Only the corresponding matching form may be implemented: `a += v` for `++a`, `a(w, ts...)` for `a(ts...)`. The implementations may not be templated and not overloaded. + ] +] [ [`a += b`] [`A&`] @@ -69,10 +79,10 @@ An [*Accumulator] is a functor which consumes the argument to update some intern ] ] [ - [`ar & a`] + [`a.serialize(ar, n)`] [] [ - `ar` is a value of an archive with Boost.Serialization semantics. Serializes `a` to the archive or loads serialized state from the archive. + `ar` is a value of an archive with Boost.Serialization semantics and `n` is an unsigned integral value. Saves to the archive or loads serialized state from the archive. The version number `n` is the stored version when the object is loaded or the current version when the object is saved. ] ] ] diff --git a/doc/concepts/Axis.qbk b/doc/concepts/Axis.qbk index a2223dc4..cf0784ab 100644 --- a/doc/concepts/Axis.qbk +++ b/doc/concepts/Axis.qbk @@ -118,10 +118,10 @@ An [*Axis] maps input values to indices. It holds state specific to that axis, l ] ] [ - [`ar & a`] + [`a.serialize(ar, n)`] [] [ - `ar` is a value of an archive with Boost.Serialization semantics. Serializes `a` to the archive or loads serialized state from the archive. + `ar` is a value of an archive with Boost.Serialization semantics and `n` is an unsigned integral value. Saves to the archive or loads serialized state from the archive. The version number `n` is the stored version when the object is loaded or the current version when the object is saved. ] ] ] diff --git a/doc/concepts/Storage.qbk b/doc/concepts/Storage.qbk index 6ed78f64..99bbabe0 100644 --- a/doc/concepts/Storage.qbk +++ b/doc/concepts/Storage.qbk @@ -149,10 +149,10 @@ A [*Storage] handles memory for the bin counters and provides a uniform vector-l ] ] [ - [`ar & s`] + [`s.serialize(ar, n)`] [] [ - Serializes `s` to the archive or loads serialized state from the archive. + `ar` is a value of an archive with Boost.Serialization semantics and `n` is an unsigned integral value. Saves to the archive or loads serialized state from the archive. The version number `n` is the stored version when the object is loaded or the current version when the object is saved. ] ] ] diff --git a/doc/concepts/Transform.qbk b/doc/concepts/Transform.qbk index 931c7fb8..741583fd 100644 --- a/doc/concepts/Transform.qbk +++ b/doc/concepts/Transform.qbk @@ -52,10 +52,10 @@ A [*Transform] implements a monotonic mapping between two real-valued domains, e [table Valid expressions [[Expression] [Returns] [Semantics, Pre/Post-conditions]] [ - [`ar & t`] + [`t.serialize(ar, n)`] [] [ - Serializes `a` to the archive or loads serialized state from the archive. Can be omitted if `T` is stateless. + `ar` is a value of an archive with Boost.Serialization semantics and `n` is an unsigned integral value. Saves to the archive or loads serialized state from the archive. The version number `n` is the stored version when the object is loaded or the current version when the object is saved. ] ] ] diff --git a/include/boost/histogram/weight.hpp b/include/boost/histogram/weight.hpp index 4054e469..63efab18 100644 --- a/include/boost/histogram/weight.hpp +++ b/include/boost/histogram/weight.hpp @@ -12,9 +12,18 @@ namespace boost { namespace histogram { +/** Weight holder and type envelope. + + You should not construct these directly, use the weight() helper function. + + @tparam Underlying arithmetic type. +*/ template struct weight_type { + /// Access underlying value. T value; + + /// Allow implicit conversions of types when the underlying value type allows them. template operator weight_type() const { return weight_type{static_cast(value)};