Update concepts

* fix documentation of serialization support for all types
* document optional support of weighted fills for custom accumulators
This commit is contained in:
Hans Dembinski 2019-11-04 21:11:19 +01:00 committed by GitHub
parent 6d7838d8b4
commit a0f75b335d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 10 deletions

View File

@ -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.
]
]
]

View File

@ -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.
]
]
]

View File

@ -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.
]
]
]

View File

@ -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.
]
]
]

View File

@ -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 <class T>
struct weight_type {
/// Access underlying value.
T value;
/// Allow implicit conversions of types when the underlying value type allows them.
template <class U>
operator weight_type<U>() const {
return weight_type<U>{static_cast<U>(value)};