File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
include/boost/histogram/detail Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ struct atomic_number : std::atomic<T> {
4848 return *this ;
4949 }
5050
51+ // not thread-safe
52+ atomic_number& operator /=(const T& x) noexcept {
53+ this ->store (this ->load () / x);
54+ return *this ;
55+ }
56+
5157private:
5258 // for integral types
5359 template <class U = T>
Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ void run_tests() {
4848 c_t two (2 );
4949 auto six = two * 3 ;
5050 BOOST_TEST_EQ (six, static_cast <T>(6 ));
51+ six *= 2 ;
52+ BOOST_TEST_EQ (six, static_cast <T>(12 ));
53+ }
54+
55+ {
56+ c_t six (6 );
57+ auto two = six / 3 ;
58+ BOOST_TEST_EQ (two, static_cast <T>(2 ));
59+ two /= 2 ;
60+ BOOST_TEST_EQ (two, static_cast <T>(1 ));
5161 }
5262}
5363
You can’t perform that action at this time.
0 commit comments