From 673e043950e7e0f4110f2028cef0ce7e0a645ff6 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Mon, 16 Nov 2020 23:53:11 +0100 Subject: [PATCH] Add more operators to Timestamp --- openVulkanoCpp/Math/Timestamp.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/openVulkanoCpp/Math/Timestamp.hpp b/openVulkanoCpp/Math/Timestamp.hpp index 21f95c2..b99fb95 100644 --- a/openVulkanoCpp/Math/Timestamp.hpp +++ b/openVulkanoCpp/Math/Timestamp.hpp @@ -23,6 +23,18 @@ namespace openVulkanoCpp::Math [[nodiscard]] uint64_t GetNanos() const { return timestamp; } [[nodiscard]] double GetSeconds() const { return timestamp * NANOS_TO_SECONDS; } + + Timestamp& operator+=(const Timestamp& rhs) + { + timestamp += rhs.timestamp; + return *this; + } + + Timestamp& operator-=(const Timestamp& rhs) + { + timestamp -= rhs.timestamp; + return *this; + } }; inline bool operator==(const Timestamp& lhs, const Timestamp& rhs) @@ -54,4 +66,19 @@ namespace openVulkanoCpp::Math { return !(rhs < lhs); } + + inline Timestamp operator-(const Timestamp& lhs, const Timestamp& rhs) + { + return Timestamp(lhs.GetNanos() - rhs.GetNanos()); + } + + inline Timestamp operator+(const Timestamp& lhs, const Timestamp& rhs) + { + return Timestamp(lhs.GetNanos() + rhs.GetNanos()); + } + + inline double operator/(const Timestamp& lhs, const Timestamp& rhs) + { + return lhs.GetNanos() / static_cast(rhs.GetNanos()); + } } \ No newline at end of file