From 8de154893c9bc1b31f29840715551a75eb76adb2 Mon Sep 17 00:00:00 2001
From: wwylele <wwylele@gmail.com>
Date: Thu, 12 Nov 2015 17:19:02 +0200
Subject: [PATCH 1/2] disable unary minus when the type is not signed

silent warning C4146 on msvc
---
 src/common/vector_math.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/common/vector_math.h b/src/common/vector_math.h
index 4928c9bf2..816ad4e33 100644
--- a/src/common/vector_math.h
+++ b/src/common/vector_math.h
@@ -32,6 +32,7 @@
 #pragma once
 
 #include <cmath>
+#include <type_traits>
 
 namespace Math {
 
@@ -90,6 +91,7 @@ public:
     {
         x-=other.x; y-=other.y;
     }
+    template<class = typename std::enable_if<std::is_signed<T>::value>::type>
     Vec2<decltype(-T{})> operator -() const
     {
         return MakeVec(-x,-y);
@@ -220,6 +222,7 @@ public:
     {
         x-=other.x; y-=other.y; z-=other.z;
     }
+    template<class = typename std::enable_if<std::is_signed<T>::value>::type>
     Vec3<decltype(-T{})> operator -() const
     {
         return MakeVec(-x,-y,-z);
@@ -390,6 +393,7 @@ public:
     {
         x-=other.x; y-=other.y; z-=other.z; w-=other.w;
     }
+    template<class = typename std::enable_if<std::is_signed<T>::value>::type>
     Vec4<decltype(-T{})> operator -() const
     {
         return MakeVec(-x,-y,-z,-w);

From 1f89d5d184ab3a034c1501ad3e9844d787cbae41 Mon Sep 17 00:00:00 2001
From: wwylele <wwylele@gmail.com>
Date: Thu, 12 Nov 2015 20:31:31 +0200
Subject: [PATCH 2/2] fix failure on gcc and clang

---
 src/common/vector_math.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/common/vector_math.h b/src/common/vector_math.h
index 816ad4e33..02688e35e 100644
--- a/src/common/vector_math.h
+++ b/src/common/vector_math.h
@@ -91,7 +91,7 @@ public:
     {
         x-=other.x; y-=other.y;
     }
-    template<class = typename std::enable_if<std::is_signed<T>::value>::type>
+    template<typename Q = T,class = typename std::enable_if<std::is_signed<Q>::value>::type>
     Vec2<decltype(-T{})> operator -() const
     {
         return MakeVec(-x,-y);
@@ -222,7 +222,7 @@ public:
     {
         x-=other.x; y-=other.y; z-=other.z;
     }
-    template<class = typename std::enable_if<std::is_signed<T>::value>::type>
+    template<typename Q = T,class = typename std::enable_if<std::is_signed<Q>::value>::type>
     Vec3<decltype(-T{})> operator -() const
     {
         return MakeVec(-x,-y,-z);
@@ -393,7 +393,7 @@ public:
     {
         x-=other.x; y-=other.y; z-=other.z; w-=other.w;
     }
-    template<class = typename std::enable_if<std::is_signed<T>::value>::type>
+    template<typename Q = T,class = typename std::enable_if<std::is_signed<Q>::value>::type>
     Vec4<decltype(-T{})> operator -() const
     {
         return MakeVec(-x,-y,-z,-w);