refactor(miscellaneous): clarify which fundamental types are used where
This commit is contained in:
parent
54c795b9a2
commit
bcc39fdf55
@ -378,13 +378,16 @@ static_assert(sizeof(int16_fast) >= 2, "int16_fast must be at least 2 bytes");
|
||||
static_assert(sizeof(int32_fast) >= 4, "int32_fast must be at least 4 bytes");
|
||||
static_assert(sizeof(int64_fast) >= 8, "int64_fast must be at least 8 bytes");
|
||||
|
||||
static_assert(int8(0xFF) == -1, "int8 use two's complement");
|
||||
static_assert(int16(0xFFFF) == -1, "int16 use two's complement");
|
||||
static_assert(int32(0xFFFFFFFF) == -1, "int32 use two's complement");
|
||||
static_assert(int64(0xFFFFFFFFFFFFFFFF) == -1, "int64 use two's complement");
|
||||
static_assert(static_cast<int8>(0xFF) == -1, "int8 use two's complement");
|
||||
static_assert(static_cast<int16>(0xFFFF) == -1, "int16 use two's complement");
|
||||
static_assert(static_cast<int32>(0xFFFFFFFF) == -1, "int32 use two's complement");
|
||||
static_assert(static_cast<int64>(0xFFFFFFFFFFFFFFFF) == -1, "int64 use two's complement");
|
||||
|
||||
// Unsigned integral types
|
||||
|
||||
using uint = unsigned int;
|
||||
using byte = unsigned char;
|
||||
|
||||
using uint8 = NAMESPACE_STD::uint8_t;
|
||||
using uint16 = NAMESPACE_STD::uint16_t;
|
||||
using uint32 = NAMESPACE_STD::uint32_t;
|
||||
@ -491,16 +494,13 @@ static_assert(!PLATFORM_LINUX || sizeof(wchar) == sizeof(u32char), "wchar repr
|
||||
// Pointer types
|
||||
|
||||
using uintptr = NAMESPACE_STD::uintptr_t;
|
||||
using intptr = NAMESPACE_STD::intptr_t;
|
||||
using ptrdiff = NAMESPACE_STD::ptrdiff_t;
|
||||
using size_t = NAMESPACE_STD::size_t;
|
||||
using ssize_t = intptr_t;
|
||||
|
||||
static_assert(sizeof(uintptr) == sizeof(void*), "uintptr must be the same size as a pointer");
|
||||
static_assert(sizeof( intptr) == sizeof(void*), "intptr must be the same size as a pointer");
|
||||
|
||||
static_assert(sizeof(ptrdiff) == sizeof(void*), "ptrdiff must be the same size as a pointer");
|
||||
static_assert(sizeof(size_t) == sizeof(void*), "size_t must be the same size as a pointer");
|
||||
static_assert(static_cast<uintptr>(-1) > static_cast<uintptr>(0), "uintptr must be unsigned");
|
||||
static_assert(static_cast< intptr>(-1) < static_cast< intptr>(0), "intptr must be signed");
|
||||
|
||||
// Null types
|
||||
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
|
||||
// Make sure you call this function after you have destroyed the held object using Destroy().
|
||||
template <typename T, typename U>
|
||||
FORCEINLINE constexpr void Emplace(intptr InCallable, U&& Args)
|
||||
FORCEINLINE constexpr void Emplace(uintptr InCallable, U&& Args)
|
||||
{
|
||||
static_assert(CSameAs<TDecay<T>, TDecay<U>>);
|
||||
ValuePtr = reinterpret_cast<uintptr>(AddressOf(Args));
|
||||
|
@ -53,7 +53,7 @@ FORCEINLINE constexpr size_t GetTypeHash(T A)
|
||||
if constexpr (sizeof(T) == 8) return GetTypeHash(static_cast<uint32>(A)) ^ GetTypeHash(static_cast<uint32>(A >> 32));
|
||||
if constexpr (sizeof(T) == 16) return GetTypeHash(static_cast<uint64>(A)) ^ GetTypeHash(static_cast<uint64>(A >> 64));
|
||||
else check_no_entry();
|
||||
|
||||
|
||||
return INDEX_NONE;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ FORCEINLINE constexpr size_t GetTypeHash(T A)
|
||||
if constexpr (sizeof(T) == 8) return GetTypeHash(*reinterpret_cast<uint64*>(&A));
|
||||
if constexpr (sizeof(T) == 16) return GetTypeHash(*reinterpret_cast<uint64*>(&A) ^ *(reinterpret_cast<uint64*>(&A) + 1));
|
||||
else check_no_entry();
|
||||
|
||||
|
||||
return INDEX_NONE;
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ FORCEINLINE constexpr size_t GetTypeHash(T A)
|
||||
template <typename T> requires (CPointer<T> || CSameAs<T, nullptr_t>)
|
||||
FORCEINLINE constexpr size_t GetTypeHash(T A)
|
||||
{
|
||||
return GetTypeHash(reinterpret_cast<intptr>(A));
|
||||
return GetTypeHash(reinterpret_cast<uintptr>(A));
|
||||
}
|
||||
|
||||
/** Overloads the GetTypeHash algorithm for T::hash_code(). */
|
||||
|
Loading…
Reference in New Issue
Block a user