Skip to content

Commit 598a51f

Browse files
committed
generic interface for accumulators
1 parent 534743e commit 598a51f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

include/boost/histogram/accumulators/mean.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class mean {
3030
using value_type = ValueType;
3131
using const_reference = const value_type&;
3232

33-
struct impl_type {
33+
struct data_type {
3434
value_type sum_;
3535
value_type mean_;
3636
value_type sum_of_deltas_squared_;
@@ -152,7 +152,7 @@ class mean {
152152
}
153153

154154
private:
155-
impl_type data_{0, 0, 0};
155+
data_type data_{0, 0, 0};
156156

157157
friend struct ::boost::histogram::unsafe_access;
158158
};

include/boost/histogram/unsafe_access.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ struct unsafe_access {
9797
Get buffer of unlimited_storage.
9898
@param storage instance of unlimited_storage.
9999
*/
100-
template <class Allocator>
101-
static constexpr auto& unlimited_storage_buffer(unlimited_storage<Allocator>& storage) {
100+
template <class T>
101+
static constexpr auto& unlimited_storage_buffer(T& storage) {
102102
return storage.buffer_;
103103
}
104104

@@ -107,16 +107,16 @@ struct unsafe_access {
107107
@param storage instance of storage_adaptor.
108108
*/
109109
template <class T>
110-
static constexpr auto& storage_adaptor_impl(storage_adaptor<T>& storage) {
111-
return static_cast<typename storage_adaptor<T>::impl_type&>(storage);
110+
static constexpr auto& storage_adaptor_impl(T& storage) {
111+
return static_cast<typename T::impl_type&>(storage);
112112
}
113113

114114
/**
115-
Get internal data of accumulators::mean.
115+
Get internal data of accumulator.
116116
@param obj instance of accumulator.
117117
*/
118118
template <class T>
119-
static constexpr auto& accumulators_mean_impl(T& m) {
119+
static constexpr auto& accumulator_data(T& m) {
120120
return m.data_;
121121
}
122122
};

test/accumulators_mean_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int main() {
118118
a(2);
119119

120120
BOOST_TEST_EQ(a.count(), 2);
121-
unsafe_access::accumulators_mean_impl(a).sum_ = 1;
121+
unsafe_access::accumulator_data(a).sum_ = 1;
122122
BOOST_TEST_EQ(a.count(), 1);
123123
}
124124

0 commit comments

Comments
 (0)