mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-09 23:04:07 +00:00
Fix and test for missing count division (#329)
This commit is contained in:
parent
90a58d03ee
commit
4a10c2c11b
@ -48,6 +48,12 @@ struct atomic_number : std::atomic<T> {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// not thread-safe
|
||||||
|
atomic_number& operator/=(const T& x) noexcept {
|
||||||
|
this->store(this->load() / x);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// for integral types
|
// for integral types
|
||||||
template <class U = T>
|
template <class U = T>
|
||||||
|
@ -48,6 +48,16 @@ void run_tests() {
|
|||||||
c_t two(2);
|
c_t two(2);
|
||||||
auto six = two * 3;
|
auto six = two * 3;
|
||||||
BOOST_TEST_EQ(six, static_cast<T>(6));
|
BOOST_TEST_EQ(six, static_cast<T>(6));
|
||||||
|
six *= 2;
|
||||||
|
BOOST_TEST_EQ(six, static_cast<T>(12));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
c_t six(6);
|
||||||
|
auto two = six / 3;
|
||||||
|
BOOST_TEST_EQ(two, static_cast<T>(2));
|
||||||
|
two /= 2;
|
||||||
|
BOOST_TEST_EQ(two, static_cast<T>(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user