diff --git a/openVulkanoCpp/Math/Int24.hpp b/openVulkanoCpp/Math/Int24.hpp index e30510a..111bd20 100644 --- a/openVulkanoCpp/Math/Int24.hpp +++ b/openVulkanoCpp/Math/Int24.hpp @@ -7,6 +7,7 @@ #pragma once #include +#include namespace OpenVulkano { @@ -58,18 +59,10 @@ namespace OpenVulkano } #define INT24_OPERATORS(op) \ - int24 operator op(const int24& val) const { return int24( (int)*this op (int)val ); } \ - int24 operator op(const int val) const { return int24( (int)*this op val ); } - - INT24_OPERATORS(+) - INT24_OPERATORS(-) - INT24_OPERATORS(*) - INT24_OPERATORS(/) -#undef INT24_OPERATORS - -#define INT24_OPERATORS(op) \ - int24& operator op##=(const int24& val ) { *this = *this op val; return *this; } \ - int24& operator op##=(const int val ) { *this = *this op val; return *this; } + template, bool> = true> \ + int24 operator op(const T& val) const { return int24( (int)*this op static_cast(val) ); } \ + template, bool> = true> \ + int24& operator op##=(const T& val ) { *this = *this op static_cast(val); return *this; } INT24_OPERATORS(+) INT24_OPERATORS(-) @@ -114,16 +107,16 @@ namespace OpenVulkano return int24( -(int)*this ); } -#define INT24_OPERATORS(op) \ - bool operator op(const int24& val) const { return (int)*this op (int)val; } \ - bool operator op(const int val) const { return (int)*this op val; } + template, bool> = true> + [[nodiscard]] bool operator==(const T& val) const + { + return static_cast(*this) == static_cast(val); + } - INT24_OPERATORS(==) - INT24_OPERATORS(!=) - INT24_OPERATORS(>=) - INT24_OPERATORS(<=) - INT24_OPERATORS(>) - INT24_OPERATORS(<) -#undef INT24_OPERATORS + template, bool> = true> + [[nodiscard]] constexpr auto operator<=>(const T& other) const + { + return operator int() <=> static_cast(other); + } }; } \ No newline at end of file