From cfbfeb1dfc071ff12cdd6d8ec6111c18497a4833 Mon Sep 17 00:00:00 2001 From: Matej Ferencevic <matej.ferencevic@memgraph.io> Date: Mon, 27 Jan 2020 17:23:48 +0100 Subject: [PATCH] Remove TotalOrdering from utils::Timestamp Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2646 --- src/utils/timestamp.hpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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 <fmt/format.h> #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<Timestamp> { +class Timestamp final { public: Timestamp() : Timestamp(0, 0) {} @@ -28,9 +27,6 @@ class Timestamp : public TotalOrdering<Timestamp> { 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<Timestamp> { (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;