From 433615ff0d8fe45d167eb65094fb24baa896097d Mon Sep 17 00:00:00 2001 From: mniip Date: Thu, 23 Feb 2023 22:26:30 +0100 Subject: [PATCH] Actually use enable_if correctly --- src/common/Geometry.h | 22 +++++++++++----------- src/graphics/Pixel.h | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/common/Geometry.h b/src/common/Geometry.h index 2c5d3091b..eaa9a4d00 100644 --- a/src/common/Geometry.h +++ b/src/common/Geometry.h @@ -4,10 +4,10 @@ #include #include -template, void>> +template>> struct Rect; -template, void>> +template>> struct Vec2 { T X, Y; @@ -18,7 +18,7 @@ struct Vec2 { } - template, void>> + template>> constexpr explicit Vec2(Vec2 other): X(other.X), Y(other.Y) @@ -52,13 +52,13 @@ struct Vec2 return Vec2() - std::declval())>(X - other.X, Y - other.Y); } - template, void>> + template>> constexpr inline Vec2() * std::declval())> operator*(S other) const { return Vec2() * std::declval())>(X * other, Y * other); } - template, void>> + template>> constexpr inline Vec2() / std::declval())> operator/(S other) const { return Vec2() / std::declval())>(X / other, Y / other); @@ -94,7 +94,7 @@ struct Vec2 } // Return a rectangle starting at origin, whose dimensions match this vector - template, void>> + template>> constexpr inline Rect OriginRect() const { return RectSized(Vec2(0, 0), *this); @@ -106,7 +106,7 @@ struct Vec2 template Vec2 Vec2::Zero = Vec2(0, 0); -template, void>> +template>> struct Mat2 { // ⎛A B⎞ @@ -149,7 +149,7 @@ Mat2 Mat2::MirrorY = Mat2(1, 0, 0, -1); template Mat2 Mat2::CCW = Mat2(0, 1, -1, 0); // reminder: the Y axis points down -template, void>> +template>> constexpr static inline Rect RectBetween(Vec2, Vec2); template @@ -236,7 +236,7 @@ public: return point.X >= TopLeft.X && point.X <= BottomRight.X && point.Y >= TopLeft.Y && point.Y <= BottomRight.Y; } - template, void>> + template>> inline Vec2 Size() const { return BottomRight - TopLeft + Vec2(1, 1); @@ -259,13 +259,13 @@ constexpr static inline Rect RectBetween(Vec2 topLeft, Vec2 bottomRight return Rect(topLeft, bottomRight); } -template, void>> +template>> static inline Rect RectAt(Vec2 pos) { return RectBetween(pos, pos); } -template, void>> +template>> constexpr static inline Rect RectSized(Vec2 topLeft, Vec2 dimen) { return RectBetween(topLeft, topLeft + dimen - Vec2(1, 1)); diff --git a/src/graphics/Pixel.h b/src/graphics/Pixel.h index 99d422b9a..c82d3f88e 100644 --- a/src/graphics/Pixel.h +++ b/src/graphics/Pixel.h @@ -32,11 +32,11 @@ constexpr int PIXB(pixel x) return x & 0xFF; } -template, void>> +template>> class RGBA; -template, void>> -struct alignas(std::min(alignof(uint32_t), alignof(T))) RGB +template>> +struct alignas(alignof(uint32_t) > alignof(T) ? alignof(uint32_t) : alignof(T)) RGB { T Blue, Green, Red; @@ -50,7 +50,7 @@ struct alignas(std::min(alignof(uint32_t), alignof(T))) RGB template // Avoid referring to the non-intuitive order of components RGB(std::initializer_list) = delete; - template, void>> + template>> inline RGB Blend(RGBA other) const { if (other.Alpha == 0xFF) @@ -63,7 +63,7 @@ struct alignas(std::min(alignof(uint32_t), alignof(T))) RGB ); } - template, void>> + template>> inline RGB Add(RGBA other) const { return RGB( @@ -73,7 +73,7 @@ struct alignas(std::min(alignof(uint32_t), alignof(T))) RGB ); } - template, void>> + template>> inline RGB Inverse() const { return RGB(0xFF - Red, 0xFF - Green, 0xFF - Blue); @@ -84,13 +84,13 @@ struct alignas(std::min(alignof(uint32_t), alignof(T))) RGB return RGBA(Red, Green, Blue, a); } - template, void>> + template>> inline pixel Pack() const { return PIXRGB(Red, Green, Blue); } - template, void>> + template>> static inline RGB Unpack(pixel px) { return RGB(PIXR(px), PIXG(px), PIXB(px)); @@ -98,7 +98,7 @@ struct alignas(std::min(alignof(uint32_t), alignof(T))) RGB }; template -struct alignas(std::min(alignof(uint32_t), alignof(T))) RGBA +struct alignas(alignof(uint32_t) > alignof(T) ? alignof(uint32_t) : alignof(T)) RGBA { T Blue, Green, Red, Alpha; @@ -110,7 +110,7 @@ struct alignas(std::min(alignof(uint32_t), alignof(T))) RGBA { } - template, void>> + template>> RGBA(T r, T g, T b): Blue(b), Green(g),