From a321bce37834c1f3034bd87df14fc71c13e6b84a Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 29 Aug 2017 12:59:54 -0500 Subject: Disable unary operator- on Math::Vec2/Vec3/Vec4 for unsigned types. It is unlikely we will ever use this without first doing a Cast to a signed type. Fixes 9 "unary minus operator applied to unsigned type, result still unsigned" warnings on MSVC2017.3 --- src/common/vector_math.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/common/vector_math.h') diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 6e2a5ad60..2b05f66ee 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -31,6 +31,7 @@ #pragma once #include +#include namespace Math { @@ -90,7 +91,8 @@ public: y -= other.y; } - Vec2 operator-() const { + template + Vec2::value, U>> operator-() const { return MakeVec(-x, -y); } Vec2 operator*(const Vec2& other) const { @@ -247,7 +249,8 @@ public: z -= other.z; } - Vec3 operator-() const { + template + Vec3::value, U>> operator-() const { return MakeVec(-x, -y, -z); } Vec3 operator*(const Vec3& other) const { @@ -462,7 +465,8 @@ public: w -= other.w; } - Vec4 operator-() const { + template + Vec4::value, U>> operator-() const { return MakeVec(-x, -y, -z, -w); } Vec4 operator*(const Vec4& other) const { @@ -720,4 +724,4 @@ static inline Vec4 MakeVec(const T& x, const Vec3& yzw) { return MakeVec(x, yzw[0], yzw[1], yzw[2]); } -} // namespace +} // namespace Math -- cgit v1.2.3