diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-03 17:34:36 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-04 06:58:14 +0100 |
| commit | 542d03a49fc5fc8a3aa0bb301973f68b199274e5 (patch) | |
| tree | a06ec8e800ef445e652f49f722223c7ed4a164b5 /src | |
| parent | e18740b132b10604f7f76f67d92eaff81453436e (diff) | |
a?
Diffstat (limited to 'src')
| -rw-r--r-- | src/timer-test.cpp | 5 | ||||
| -rw-r--r-- | src/timer.hpp | 14 |
2 files changed, 6 insertions, 13 deletions
diff --git a/src/timer-test.cpp b/src/timer-test.cpp index 36d31b30..5c764da0 100644 --- a/src/timer-test.cpp +++ b/src/timer-test.cpp @@ -4,9 +4,8 @@ namespace floormat { namespace { -constexpr auto MAX = 18446744073709551615u, HALF = 9223372036854775808u; -static_assert(std::is_same_v<uint64_t, std::decay_t<decltype(MAX)>>); -static_assert(std::is_same_v<uint64_t, std::decay_t<decltype(HALF)>>); +constexpr uint64_t MAX{18446744073709551615ULL} , HALF{9223372036854775808ULL}; +static_assert(sizeof MAX == 8); static_assert(MAX == (uint64_t)-1); static_assert(HALF + (HALF - 1) == MAX); static_assert(MAX - HALF == HALF - 1); diff --git a/src/timer.hpp b/src/timer.hpp index 1835d7e4..faf92a3e 100644 --- a/src/timer.hpp +++ b/src/timer.hpp @@ -4,6 +4,8 @@ namespace floormat { +// todo! move to .inl + struct Ns { explicit constexpr Ns(): stamp{0} {} @@ -70,14 +72,6 @@ struct Ns } #endif - static constexpr Ns from_millis(uint64_t a) - { - constexpr auto b = uint64_t(1e6); - const auto x = a * b; - fm_assert(a == 0 || x / a == b); - return Ns{x}; - } - friend constexpr Ns operator+(const Ns& lhs, const Ns& rhs) { constexpr auto max = (uint64_t)-1; @@ -186,8 +180,8 @@ struct Ns uint64_t stamp; }; -constexpr inline Ns Second{1000000000}, Millisecond{1000000}, Microsecond{1000}; -constexpr inline const Ns& Seconds{Second}, Milliseconds{Millisecond}, Microseconds{Microsecond}; +constexpr inline Ns Minute{60000000000}, Second{1000000000}, Millisecond{1000000}, Microsecond{1000}; +constexpr inline const Ns& Minutes{Minute}, Seconds{Second}, Milliseconds{Millisecond}, Microseconds{Microsecond}; struct Time final { |
