mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-11 13:14:06 +00:00
fix
This commit is contained in:
parent
b731ef252c
commit
34e11b787e
@ -30,7 +30,7 @@ public:
|
|||||||
using value_type = ValueType;
|
using value_type = ValueType;
|
||||||
using const_reference = const value_type&;
|
using const_reference = const value_type&;
|
||||||
|
|
||||||
struct internal_data_type {
|
struct impl_type {
|
||||||
value_type sum_;
|
value_type sum_;
|
||||||
value_type mean_;
|
value_type mean_;
|
||||||
value_type sum_of_deltas_squared_;
|
value_type sum_of_deltas_squared_;
|
||||||
@ -152,9 +152,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct unsafe_access;
|
impl_type data_{0, 0, 0};
|
||||||
|
|
||||||
internal_data_type data_{0, 0, 0};
|
friend struct unsafe_access;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace accumulators
|
} // namespace accumulators
|
||||||
|
@ -116,8 +116,8 @@ struct unsafe_access {
|
|||||||
@param obj instance of accumulator.
|
@param obj instance of accumulator.
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
static constexpr auto& accumulators_mean_impl(T&& m) {
|
static constexpr auto& accumulators_mean_impl(T& m) {
|
||||||
return m.data_;
|
return reinterpret_cast<typename T::impl_type&>(m);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ int main() {
|
|||||||
a(2);
|
a(2);
|
||||||
|
|
||||||
BOOST_TEST_EQ(a.count(), 2);
|
BOOST_TEST_EQ(a.count(), 2);
|
||||||
unsafe_access::accumulators_mean(a).sum_ = 1;
|
unsafe_access::accumulators_mean_impl(a).sum_ = 1;
|
||||||
BOOST_TEST_EQ(a.count(), 1);
|
BOOST_TEST_EQ(a.count(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user