Skip to content

Commit

Permalink
generic interface for accumulators
Browse files Browse the repository at this point in the history
  • Loading branch information
HDembinski committed Apr 27, 2021
1 parent 8b889c5 commit db6e4c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/boost/histogram/accumulators/mean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class mean {
using value_type = ValueType;
using const_reference = const value_type&;

struct impl_type {
struct data_type {
value_type sum_;
value_type mean_;
value_type sum_of_deltas_squared_;
Expand Down Expand Up @@ -152,7 +152,7 @@ class mean {
}

private:
impl_type data_{0, 0, 0};
data_type data_{0, 0, 0};

friend struct ::boost::histogram::unsafe_access;
};
Expand Down
12 changes: 6 additions & 6 deletions include/boost/histogram/unsafe_access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ struct unsafe_access {
Get buffer of unlimited_storage.
@param storage instance of unlimited_storage.
*/
template <class Allocator>
static constexpr auto& unlimited_storage_buffer(unlimited_storage<Allocator>& storage) {
template <class T>
static constexpr auto& unlimited_storage_buffer(T& storage) {
return storage.buffer_;
}

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

/**
Get internal data of accumulators::mean.
Get internal data of accumulator.
@param obj instance of accumulator.
*/
template <class T>
static constexpr auto& accumulators_mean_impl(T& m) {
static constexpr auto& accumulator_data(T& m) {
return m.data_;
}
};
Expand Down
2 changes: 1 addition & 1 deletion test/accumulators_mean_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int main() {
a(2);

BOOST_TEST_EQ(a.count(), 2);
unsafe_access::accumulators_mean_impl(a).sum_ = 1;
unsafe_access::accumulator_data(a).sum_ = 1;
BOOST_TEST_EQ(a.count(), 1);
}

Expand Down

0 comments on commit db6e4c3

Please sign in to comment.