summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-11 17:39:43 +0100
committerGitHub <noreply@github.com>2021-01-11 17:39:43 +0100
commiteeb63b8901a9c049f1bb594abb9ce9b4a9c47620 (patch)
treeb07daae788f918b83eeb0bdbd51e49292f1c8d88 /src/Globals.h
parentFixed switch-ups regarding some slab and stair recipes (#5099) (diff)
downloadcuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.gz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.bz2
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.lz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.xz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.zst
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.zip
Diffstat (limited to 'src/Globals.h')
-rw-r--r--src/Globals.h84
1 files changed, 52 insertions, 32 deletions
diff --git a/src/Globals.h b/src/Globals.h
index 192969fa5..cdfea9e5a 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -75,39 +75,8 @@
#endif
-#include <stddef.h>
-// Integral types with predefined sizes:
-typedef signed long long Int64;
-typedef signed int Int32;
-typedef signed short Int16;
-typedef signed char Int8;
-
-typedef unsigned long long UInt64;
-typedef unsigned int UInt32;
-typedef unsigned short UInt16;
-typedef unsigned char UInt8;
-
-typedef unsigned char Byte;
-typedef Byte ColourID;
-
-
-template <typename T, size_t Size>
-class SizeChecker
-{
- static_assert(sizeof(T) == Size, "Check the size of integral types");
-};
-
-template class SizeChecker<Int64, 8>;
-template class SizeChecker<Int32, 4>;
-template class SizeChecker<Int16, 2>;
-template class SizeChecker<Int8, 1>;
-
-template class SizeChecker<UInt64, 8>;
-template class SizeChecker<UInt32, 4>;
-template class SizeChecker<UInt16, 2>;
-template class SizeChecker<UInt8, 1>;
// A macro to disallow the copy constructor and operator = functions
// This should be used in the declarations for any class that shouldn't allow copying itself
@@ -130,6 +99,7 @@ template class SizeChecker<UInt8, 1>;
+
// OS-dependent stuff:
#ifdef _WIN32
@@ -161,6 +131,7 @@ template class SizeChecker<UInt8, 1>;
#include <cstdio>
#include <cmath>
#include <cstdarg>
+#include <cstddef>
@@ -188,10 +159,43 @@ template class SizeChecker<UInt8, 1>;
#include <unordered_map>
#include <unordered_set>
#include <vector>
+#include <variant>
+
+// Integral types with predefined sizes:
+typedef signed long long Int64;
+typedef signed int Int32;
+typedef signed short Int16;
+typedef signed char Int8;
+
+typedef unsigned long long UInt64;
+typedef unsigned int UInt32;
+typedef unsigned short UInt16;
+typedef unsigned char UInt8;
+
+typedef unsigned char Byte;
+typedef Byte ColourID;
+
+
+template <typename T, size_t Size>
+class SizeChecker
+{
+ static_assert(sizeof(T) == Size, "Check the size of integral types");
+};
+
+template class SizeChecker<Int64, 8>;
+template class SizeChecker<Int32, 4>;
+template class SizeChecker<Int16, 2>;
+template class SizeChecker<Int8, 1>;
+
+template class SizeChecker<UInt64, 8>;
+template class SizeChecker<UInt32, 4>;
+template class SizeChecker<UInt16, 2>;
+template class SizeChecker<UInt8, 1>;
+
// Common headers (part 1, without macros):
#include "fmt.h"
#include "StringUtils.h"
@@ -301,6 +305,20 @@ template class SizeChecker<UInt8, 1>;
+
+namespace cpp20
+{
+ template <class T>
+ std::enable_if_t<std::is_array_v<T> && (std::extent_v<T> == 0), std::unique_ptr<T>> make_unique_for_overwrite(std::size_t a_Size)
+ {
+ return std::unique_ptr<T>(new std::remove_extent_t<T>[a_Size]);
+ }
+}
+
+
+
+
+
/** Clamp X to the specified range. */
template <typename T>
T Clamp(T a_Value, T a_Min, T a_Max)
@@ -334,6 +352,9 @@ typename std::enable_if<std::is_arithmetic<T>::value, C>::type CeilC(T a_Value)
using cTickTime = std::chrono::duration<int, std::ratio_multiply<std::chrono::milliseconds::period, std::ratio<50>>>;
using cTickTimeLong = std::chrono::duration<Int64, cTickTime::period>;
+using ContiguousByteBuffer = std::basic_string<std::byte>;
+using ContiguousByteBufferView = std::basic_string_view<std::byte>;
+
#ifndef TOLUA_TEMPLATE_BIND
#define TOLUA_TEMPLATE_BIND(x)
#endif
@@ -355,4 +376,3 @@ auto ToUnsigned(T a_Val)
// Common headers (part 2, with macros):
#include "Vector3.h"
-