summaryrefslogtreecommitdiffstats
path: root/src/Defines.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-10-05 14:09:42 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-12-18 22:03:40 +0100
commit090d8305e4e3c3ee085a897b72f2b4708e183eb8 (patch)
treee703cc7fcb7f16c85f16b094d5df0bd0a8d698e8 /src/Defines.h
parentHorsies: don't always broadcast metadata (diff)
downloadcuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.gz
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.bz2
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.lz
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.xz
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.tar.zst
cuberite-090d8305e4e3c3ee085a897b72f2b4708e183eb8.zip
Diffstat (limited to 'src/Defines.h')
-rw-r--r--src/Defines.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Defines.h b/src/Defines.h
index 2f46e079c..fd0d595ae 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -489,7 +489,8 @@ inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, do
-template <class T> inline T Diff(T a_Val1, T a_Val2)
+template <class T, typename = std::enable_if_t<!std::is_integral_v<T>>>
+inline T Diff(T a_Val1, T a_Val2)
{
return std::abs(a_Val1 - a_Val2);
}
@@ -498,6 +499,16 @@ template <class T> inline T Diff(T a_Val1, T a_Val2)
+template <class T, typename = std::enable_if_t<std::is_integral_v<T>>>
+inline auto Diff(T a_Val1, T a_Val2)
+{
+ return static_cast<std::make_unsigned_t<T>>(std::abs(a_Val1 - a_Val2));
+}
+
+
+
+
+
// tolua_begin
/** Normalizes an angle in degrees to the [-180, +180) range: */