refactor(miscellaneous): renamed builtin type, add fixed-width character type

This commit is contained in:
_Redstone_c_ 2022-04-08 17:29:05 +08:00
parent a086f90f25
commit bb89dd6509
3 changed files with 39 additions and 36 deletions

View File

@ -14,7 +14,7 @@ FORCEINLINE constexpr T Align(T InValue, size_t Alignment)
{ {
static_assert(TIsIntegral<T>::Value || TIsPointer<T>::Value, "Align expects an integer or pointer type"); static_assert(TIsIntegral<T>::Value || TIsPointer<T>::Value, "Align expects an integer or pointer type");
return (T)(((uintptr_t)(InValue) + static_cast<uintptr_t>(Alignment) - 1) & ~(static_cast<uintptr_t>(Alignment) - 1)); return (T)(((uintptr)(InValue) + static_cast<uintptr>(Alignment) - 1) & ~(static_cast<uintptr>(Alignment) - 1));
} }
template <typename T> template <typename T>
@ -22,7 +22,7 @@ FORCEINLINE constexpr T AlignDown(T InValue, size_t Alignment)
{ {
static_assert(TIsIntegral<T>::Value || TIsPointer<T>::Value, "AlignDown expects an integer or pointer type"); static_assert(TIsIntegral<T>::Value || TIsPointer<T>::Value, "AlignDown expects an integer or pointer type");
return (T)((uintptr_t)(InValue) & ~(static_cast<uintptr_t>(Alignment) - 1)); return (T)((uintptr)(InValue) & ~(static_cast<uintptr>(Alignment) - 1));
} }
template <typename T> template <typename T>
@ -30,7 +30,7 @@ FORCEINLINE constexpr T AlignArbitrary(T InValue, size_t Alignment)
{ {
static_assert(TIsIntegral<T>::Value || TIsPointer<T>::Value, "AlignArbitrary expects an integer or pointer type"); static_assert(TIsIntegral<T>::Value || TIsPointer<T>::Value, "AlignArbitrary expects an integer or pointer type");
return (T)((((uintptr_t)(InValue) + static_cast<uintptr_t>(Alignment) - 1) / static_cast<uintptr_t>(Alignment)) * static_cast<uintptr_t>(Alignment)); return (T)((((uintptr)(InValue) + static_cast<uintptr>(Alignment) - 1) / static_cast<uintptr>(Alignment)) * static_cast<uintptr>(Alignment));
} }
template <typename T> template <typename T>
@ -38,7 +38,7 @@ FORCEINLINE constexpr bool IsAligned(T InValue, size_t Alignment)
{ {
static_assert(TIsIntegral<T>::Value || TIsPointer<T>::Value, "IsAligned expects an integer or pointer type"); static_assert(TIsIntegral<T>::Value || TIsPointer<T>::Value, "IsAligned expects an integer or pointer type");
return !((uintptr_t)(InValue) & (static_cast<uintptr_t>(Alignment) - 1)); return !((uintptr)(InValue) & (static_cast<uintptr>(Alignment) - 1));
} }
NAMESPACE_END(Memory) NAMESPACE_END(Memory)

View File

@ -17,7 +17,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
#define NO_UNIQUE_ADDRESS [[no_unique_address]] #define NO_UNIQUE_ADDRESS [[no_unique_address]]
constexpr size_t INDEX_NONE = -1; constexpr size_t INDEX_NONE = -1;
constexpr WIDECHAR UNICODE_BOM = 0xfeff; constexpr charw UNICODE_BOM = 0xfeff;
struct FForceInit { explicit FForceInit() = default; }; struct FForceInit { explicit FForceInit() = default; };
struct FNoInit { explicit FNoInit() = default; }; struct FNoInit { explicit FNoInit() = default; };

View File

@ -135,15 +135,18 @@ typedef NAMESPACE_STD::int64_t int64;
// Character types. // Character types.
typedef char ANSICHAR; typedef char chara;
typedef wchar_t WIDECHAR; typedef wchar_t charw;
typedef WIDECHAR TCHAR; typedef charw chart;
typedef char8_t char8;
typedef char16_t char16;
typedef char32_t char32;
// Pointer types. // Pointer types.
typedef NAMESPACE_STD::uintptr_t uintptr_t; typedef NAMESPACE_STD::uintptr_t uintptr;
typedef NAMESPACE_STD::intptr_t intptr_t; typedef NAMESPACE_STD::intptr_t intptr;
typedef NAMESPACE_STD::ptrdiff_t ptrdiff_t; typedef NAMESPACE_STD::ptrdiff_t ptrdiff;
typedef NAMESPACE_STD::size_t size_t; typedef NAMESPACE_STD::size_t size_t;
typedef intptr_t ssize_t; typedef intptr_t ssize_t;