From eeb63b8901a9c049f1bb594abb9ce9b4a9c47620 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 11 Jan 2021 16:39:43 +0000 Subject: zlib -> libdeflate (#5085) + Use libdeflate + Use std::byte * Fix passing temporary to string_view + Emulate make_unique_for_overwrite --- src/Globals.h | 84 ++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 32 deletions(-) (limited to 'src/Globals.h') 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 -// 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 -class SizeChecker -{ - static_assert(sizeof(T) == Size, "Check the size of integral types"); -}; - -template class SizeChecker; -template class SizeChecker; -template class SizeChecker; -template class SizeChecker; - -template class SizeChecker; -template class SizeChecker; -template class SizeChecker; -template class SizeChecker; // 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; + // OS-dependent stuff: #ifdef _WIN32 @@ -161,6 +131,7 @@ template class SizeChecker; #include #include #include +#include @@ -188,10 +159,43 @@ template class SizeChecker; #include #include #include +#include + +// 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 +class SizeChecker +{ + static_assert(sizeof(T) == Size, "Check the size of integral types"); +}; + +template class SizeChecker; +template class SizeChecker; +template class SizeChecker; +template class SizeChecker; + +template class SizeChecker; +template class SizeChecker; +template class SizeChecker; +template class SizeChecker; + // Common headers (part 1, without macros): #include "fmt.h" #include "StringUtils.h" @@ -301,6 +305,20 @@ template class SizeChecker; + +namespace cpp20 +{ + template + std::enable_if_t && (std::extent_v == 0), std::unique_ptr> make_unique_for_overwrite(std::size_t a_Size) + { + return std::unique_ptr(new std::remove_extent_t[a_Size]); + } +} + + + + + /** Clamp X to the specified range. */ template T Clamp(T a_Value, T a_Min, T a_Max) @@ -334,6 +352,9 @@ typename std::enable_if::value, C>::type CeilC(T a_Value) using cTickTime = std::chrono::duration>>; using cTickTimeLong = std::chrono::duration; +using ContiguousByteBuffer = std::basic_string; +using ContiguousByteBufferView = std::basic_string_view; + #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" - -- cgit v1.2.3