File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class mean {
3030 using value_type = ValueType;
3131 using const_reference = const value_type&;
3232
33- struct internal_data_type {
33+ struct impl_type {
3434 value_type sum_;
3535 value_type mean_;
3636 value_type sum_of_deltas_squared_;
@@ -152,9 +152,9 @@ class mean {
152152 }
153153
154154private:
155- friend struct unsafe_access ;
155+ impl_type data_{ 0 , 0 , 0 } ;
156156
157- internal_data_type data_{ 0 , 0 , 0 } ;
157+ friend struct unsafe_access ;
158158};
159159
160160} // namespace accumulators
Original file line number Diff line number Diff line change @@ -116,8 +116,8 @@ struct unsafe_access {
116116 @param obj instance of accumulator.
117117 */
118118 template <class T >
119- static constexpr auto & accumulators_mean_impl (T&& m) {
120- return m. data_ ;
119+ static constexpr auto & accumulators_mean_impl (T& m) {
120+ return reinterpret_cast < typename T::impl_type&>(m) ;
121121 }
122122};
123123
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ int main() {
118118 a (2 );
119119
120120 BOOST_TEST_EQ (a.count (), 2 );
121- unsafe_access::accumulators_mean (a).sum_ = 1 ;
121+ unsafe_access::accumulators_mean_impl (a).sum_ = 1 ;
122122 BOOST_TEST_EQ (a.count (), 1 );
123123 }
124124
You can’t perform that action at this time.
0 commit comments