refactor(typetraits): replaces template class type traits with concepts for TypeTraits/PrimaryType.h
This commit is contained in:
@ -12,28 +12,28 @@ NAMESPACE_BEGIN(Memory)
|
||||
|
||||
FORCEINLINE constexpr bool IsValidAlignment(size_t Alignment) { return !(Alignment & (Alignment - 1)); }
|
||||
|
||||
template <typename T> requires TIsIntegral<T>::Value || TIsPointer<T>::Value
|
||||
template <typename T> requires CIntegral<T> || CPointer<T>
|
||||
FORCEINLINE constexpr T Align(T InValue, size_t Alignment)
|
||||
{
|
||||
checkf(IsValidAlignment(Alignment), TEXT("The alignment value must be an integer power of 2."));
|
||||
return (T)(((uint64)(InValue) + static_cast<uint64>(Alignment) - 1) & ~(static_cast<uint64>(Alignment) - 1));
|
||||
}
|
||||
|
||||
template <typename T> requires TIsIntegral<T>::Value || TIsPointer<T>::Value
|
||||
template <typename T> requires CIntegral<T> || CPointer<T>
|
||||
FORCEINLINE constexpr T AlignDown(T InValue, size_t Alignment)
|
||||
{
|
||||
checkf(IsValidAlignment(Alignment), TEXT("The alignment value must be an integer power of 2."));
|
||||
return (T)((uint64)(InValue) & ~(static_cast<uint64>(Alignment) - 1));
|
||||
}
|
||||
|
||||
template <typename T> requires TIsIntegral<T>::Value || TIsPointer<T>::Value
|
||||
template <typename T> requires CIntegral<T> || CPointer<T>
|
||||
FORCEINLINE constexpr T AlignArbitrary(T InValue, size_t Alignment)
|
||||
{
|
||||
checkf(IsValidAlignment(Alignment), TEXT("The alignment value must be an integer power of 2."));
|
||||
return (T)((((uint64)(InValue) + static_cast<uint64>(Alignment) - 1) / static_cast<uint64>(Alignment)) * static_cast<uint64>(Alignment));
|
||||
}
|
||||
|
||||
template <typename T> requires TIsIntegral<T>::Value || TIsPointer<T>::Value
|
||||
template <typename T> requires CIntegral<T> || CPointer<T>
|
||||
FORCEINLINE constexpr bool IsAligned(T InValue, size_t Alignment)
|
||||
{
|
||||
checkf(IsValidAlignment(Alignment), TEXT("The alignment value must be an integer power of 2."));
|
||||
|
@ -56,21 +56,21 @@ FORCEINLINE void* Memcpy(void* Destination, const void* Source, size_t Count)
|
||||
template <typename T>
|
||||
FORCEINLINE void Memset(T& Source, uint8 ValueToSet)
|
||||
{
|
||||
static_assert(!TIsPointer<T>::Value, "For pointers use the three parameters function");
|
||||
static_assert(!CPointer<T>, "For pointers use the three parameters function");
|
||||
Memset(&Source, ValueToSet, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
FORCEINLINE void Memzero(T& Source)
|
||||
{
|
||||
static_assert(!TIsPointer<T>::Value, "For pointers use the two parameters function");
|
||||
static_assert(!CPointer<T>, "For pointers use the two parameters function");
|
||||
Memzero(&Source, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
FORCEINLINE void Memcpy(T& Destination, const T& Source)
|
||||
{
|
||||
static_assert(!TIsPointer<T>::Value, "For pointers use the three parameters function");
|
||||
static_assert(!CPointer<T>, "For pointers use the three parameters function");
|
||||
Memcpy(&Destination, &Source, sizeof(T));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user