summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-10-10 00:12:51 +0200
committerarchshift <admin@archshift.com>2014-10-10 00:12:51 +0200
commitae5d3116097bae7205993605ca463eb1ece3734d (patch)
treee35345c1278193765e3d170e928c44e3a469930a /src/Globals.h
parentDistortedHeightmap: Fixed crash on number rounding. (diff)
parentFloat/Ciel: If it's going to use C++11, it might as well take advantage of it (diff)
downloadcuberite-ae5d3116097bae7205993605ca463eb1ece3734d.tar
cuberite-ae5d3116097bae7205993605ca463eb1ece3734d.tar.gz
cuberite-ae5d3116097bae7205993605ca463eb1ece3734d.tar.bz2
cuberite-ae5d3116097bae7205993605ca463eb1ece3734d.tar.lz
cuberite-ae5d3116097bae7205993605ca463eb1ece3734d.tar.xz
cuberite-ae5d3116097bae7205993605ca463eb1ece3734d.tar.zst
cuberite-ae5d3116097bae7205993605ca463eb1ece3734d.zip
Diffstat (limited to '')
-rw-r--r--src/Globals.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/Globals.h b/src/Globals.h
index 0926457da..9959d92a9 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -226,10 +226,10 @@ template class SizeChecker<UInt16, 2>;
// CRT stuff:
#include <sys/stat.h>
-#include <assert.h>
-#include <stdio.h>
-#include <math.h>
-#include <stdarg.h>
+#include <cassert>
+#include <cstdio>
+#include <cmath>
+#include <cstdarg>
@@ -400,6 +400,24 @@ 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, 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));
+}
+
+/** 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));
+}
+
+
+
+
+
#ifndef TOLUA_TEMPLATE_BIND
#define TOLUA_TEMPLATE_BIND(x)
#endif