summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-09-04 01:51:38 +0200
committerarchshift <admin@archshift.com>2014-10-09 23:57:57 +0200
commit76b37acb421bf10e094182b2e9be111eb29c46f1 (patch)
treee35345c1278193765e3d170e928c44e3a469930a /src/Globals.h
parentUse static casts instead of C casts, add floor-cast functions (diff)
downloadcuberite-76b37acb421bf10e094182b2e9be111eb29c46f1.tar
cuberite-76b37acb421bf10e094182b2e9be111eb29c46f1.tar.gz
cuberite-76b37acb421bf10e094182b2e9be111eb29c46f1.tar.bz2
cuberite-76b37acb421bf10e094182b2e9be111eb29c46f1.tar.lz
cuberite-76b37acb421bf10e094182b2e9be111eb29c46f1.tar.xz
cuberite-76b37acb421bf10e094182b2e9be111eb29c46f1.tar.zst
cuberite-76b37acb421bf10e094182b2e9be111eb29c46f1.zip
Diffstat (limited to 'src/Globals.h')
-rw-r--r--src/Globals.h26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/Globals.h b/src/Globals.h
index 8bf7a0f0c..9959d92a9 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -400,34 +400,20 @@ T Clamp(T a_Value, T a_Min, T a_Max)
-/** Floors a_Value, then casts it to C (an int by default) */
-template <typename C = int>
-C FloorD(double a_Value)
+/** Floors a value, then casts it to C (an int by default) */
+template <typename C = int, typename T>
+typename std::enable_if<std::is_arithmetic<T>::value, C>::type FloorC(T a_Value)
{
return static_cast<C>(std::floor(a_Value));
}
-/** Floors a_Value, then casts it to C (an int by default) */
-template <typename C = int>
-C FloorF(double a_Value)
-{
- return static_cast<C>(std::floorf(a_Value));
-}
-
-/** Ciels a_Value, then casts it to C (an int by default) */
-template <typename C = int>
-C CeilD(double a_Value)
+/** Ceils a value, then casts it to C (an int by default) */
+template <typename C = int, typename T>
+typename std::enable_if<std::is_arithmetic<T>::value, C>::type CeilC(T a_Value)
{
return static_cast<C>(std::ceil(a_Value));
}
-/** Ciels a_Value, then casts it to C (an int by default) */
-template <typename C = int>
-C CeilF(double a_Value)
-{
- return static_cast<C>(std::ceilf(a_Value));
-}
-