diff --git a/openVulkanoCpp/Math/Timestamp.hpp b/openVulkanoCpp/Math/Timestamp.hpp index b09b2f8..f848089 100644 --- a/openVulkanoCpp/Math/Timestamp.hpp +++ b/openVulkanoCpp/Math/Timestamp.hpp @@ -18,79 +18,61 @@ namespace OpenVulkano::Math uint64_t timestamp; public: - explicit Timestamp(uint64_t nanos = 0) : timestamp(nanos) {} - explicit Timestamp(double seconds) : timestamp(static_cast(seconds * SECONDS_TO_NANOS)) {} + explicit constexpr Timestamp(uint64_t nanos = 0) : timestamp(nanos) {} + explicit constexpr Timestamp(double seconds) : timestamp(static_cast(seconds * SECONDS_TO_NANOS)) {} - [[nodiscard]] uint64_t GetNanos() const { return timestamp; } - [[nodiscard]] double GetSeconds() const { return timestamp * NANOS_TO_SECONDS; } + [[nodiscard]] constexpr uint64_t GetNanos() const { return timestamp; } + [[nodiscard]] constexpr double GetSeconds() const { return timestamp * NANOS_TO_SECONDS; } - Timestamp& operator+=(const Timestamp& rhs) + constexpr Timestamp& operator+=(const Timestamp& rhs) { timestamp += rhs.timestamp; return *this; } - Timestamp& operator-=(const Timestamp& rhs) + constexpr Timestamp& operator-=(const Timestamp& rhs) { timestamp -= rhs.timestamp; return *this; } - Timestamp& operator =(double time) + constexpr Timestamp& operator =(double time) { timestamp = Timestamp(time).timestamp; return *this; } - Timestamp& operator =(uint64_t time) + constexpr Timestamp& operator =(uint64_t time) { timestamp = time; return *this; } + + constexpr inline bool operator==(const Timestamp& rhs) const { return GetNanos() == rhs.GetNanos(); } + + constexpr inline bool operator!=(const Timestamp& rhs) const { return !(*this == rhs); } + + constexpr inline bool operator<(const Timestamp& rhs) const { return GetNanos() < rhs.GetNanos(); } + + constexpr inline bool operator>(const Timestamp& rhs) const { return rhs < *this; } + + constexpr inline bool operator>=(const Timestamp& rhs) const { return !(*this < rhs); } + + constexpr inline bool operator<=(const Timestamp& rhs) const { return !(rhs < *this); } + + constexpr inline Timestamp operator-(const Timestamp& rhs) const + { + return Timestamp(GetNanos() - rhs.GetNanos()); + } + + constexpr inline Timestamp operator+(const Timestamp& rhs) const + { + return Timestamp(GetNanos() + rhs.GetNanos()); + } + + constexpr inline double operator/(const Timestamp& rhs) const + { + return GetNanos() / static_cast(rhs.GetNanos()); + } }; - - inline bool operator==(const Timestamp& lhs, const Timestamp& rhs) - { - return lhs.GetNanos() == rhs.GetNanos(); - } - - inline bool operator!=(const Timestamp& lhs, const Timestamp& rhs) - { - return !(lhs == rhs); - } - - inline bool operator<(const Timestamp& lhs, const Timestamp& rhs) - { - return lhs.GetNanos() < rhs.GetNanos(); - } - - inline bool operator>(const Timestamp& lhs, const Timestamp& rhs) - { - return rhs < lhs; - } - - inline bool operator>=(const Timestamp& lhs, const Timestamp& rhs) - { - return !(lhs < rhs); - } - - inline bool operator<=(const Timestamp& lhs, const Timestamp& rhs) - { - 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