diff --git a/src/utils/timestamp.hpp b/src/utils/timestamp.hpp index df42be256..5dced5e5e 100644 --- a/src/utils/timestamp.hpp +++ b/src/utils/timestamp.hpp @@ -8,7 +8,6 @@ #include #include "utils/exceptions.hpp" -#include "utils/total_ordering.hpp" namespace utils { @@ -17,7 +16,7 @@ class TimestampError : public StacktraceException { using StacktraceException::StacktraceException; }; -class Timestamp : public TotalOrdering { +class Timestamp final { public: Timestamp() : Timestamp(0, 0) {} @@ -28,9 +27,6 @@ class Timestamp : public TotalOrdering { throw TimestampError("Unable to construct from {}", time); } - Timestamp(const Timestamp &) = default; - Timestamp(Timestamp &&) = default; - static Timestamp Now() { timespec time; clock_gettime(CLOCK_REALTIME, &time); @@ -85,6 +81,22 @@ class Timestamp : public TotalOrdering { (a.unix_time == b.unix_time && a.nsec < b.nsec); } + constexpr friend bool operator!=(const Timestamp &a, const Timestamp &b) { + return !(a == b); + } + + constexpr friend bool operator<=(const Timestamp &a, const Timestamp &b) { + return a < b || a == b; + } + + constexpr friend bool operator>(const Timestamp &a, const Timestamp &b) { + return !(a <= b); + } + + constexpr friend bool operator>=(const Timestamp &a, const Timestamp &b) { + return !(a < b); + } + private: std::tm time;