diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-05 15:47:35 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-05 21:56:17 +0100 |
commit | 38d2c8eb13b5317f77697e72574983d79a992353 (patch) | |
tree | 247c886733aa1e680abb3c10c497ee53b4421528 /src | |
parent | 60332d17f567e56d18234e679b6908d86cdb69c3 (diff) |
test/critter: fix it
Diffstat (limited to 'src')
-rw-r--r-- | src/timer.hpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/timer.hpp b/src/timer.hpp index 6e9bd651..36874e9e 100644 --- a/src/timer.hpp +++ b/src/timer.hpp @@ -60,18 +60,6 @@ struct Ns return Ns{(uint64_t)x}; } -#if 0 - template<typename T> - requires (std::is_same_v<T, double>) - static Ns from_nonzero(T seconds) - { - constexpr double max{uint64_t{1} << 53}; - fm_assert(seconds >= 0); - fm_assert(seconds <= max); - return Ns((uint64_t)seconds); - } -#endif - friend constexpr Ns operator+(const Ns& lhs, const Ns& rhs) { constexpr auto max = (uint64_t)-1; @@ -144,6 +132,19 @@ struct Ns return Ns{a / b}; } +#if 0 + template<typename T> + requires std::is_floating_point_v<T> + friend constexpr double operator/(const Ns& lhs, double b) + { + fm_assert(b != 0.); + auto x = double{lhs.stamp / b}; + constexpr auto max = double{uint64_t{1} << 53}; + fm_assert(x <= max); + return x; + } +#endif + friend constexpr uint64_t operator%(const Ns& lhs, const Ns& rhs) { auto a = lhs.stamp, b = rhs.stamp; |