style(*): enclose the requires expression in parentheses as required by GCC

This commit is contained in:
2022-11-16 22:03:54 +08:00
parent d37eee0d23
commit 3f56a2beca
15 changed files with 247 additions and 253 deletions

View File

@ -12,28 +12,28 @@ NAMESPACE_BEGIN(Memory)
constexpr bool IsValidAlignment(size_t Alignment) { return !(Alignment & (Alignment - 1)); }
template <typename T> requires CIntegral<T> || CPointer<T>
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 CIntegral<T> || CPointer<T>
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 CIntegral<T> || CPointer<T>
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 CIntegral<T> || CPointer<T>
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."));

View File

@ -11,8 +11,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
NAMESPACE_BEGIN(Memory)
template <typename ElementType>
requires CDefaultConstructible<ElementType>
template <CDefaultConstructible ElementType>
FORCEINLINE void DefaultConstruct(void* Address, size_t Count = 1)
{
if constexpr (!CTriviallyDefaultConstructible<ElementType>)
@ -27,7 +26,7 @@ FORCEINLINE void DefaultConstruct(void* Address, size_t Count = 1)
}
template <typename DestinationElementType, typename SourceElementType = DestinationElementType>
requires CConstructibleFrom<DestinationElementType, const SourceElementType&>
requires (CConstructibleFrom<DestinationElementType, const SourceElementType&>)
FORCEINLINE void Construct(void* Destination, const SourceElementType* Source, size_t Count = 1)
{
if constexpr (CTriviallyConstructibleFrom<DestinationElementType, const SourceElementType> && sizeof(DestinationElementType) == sizeof(SourceElementType))
@ -46,8 +45,7 @@ FORCEINLINE void Construct(void* Destination, const SourceElementType* Source, s
}
}
template <typename ElementType>
requires CCopyConstructible<ElementType>
template <CCopyConstructible ElementType>
FORCEINLINE void CopyConstruct(void* Destination, const ElementType* Source, size_t Count = 1)
{
if constexpr (CTriviallyCopyConstructible<ElementType>)
@ -66,8 +64,7 @@ FORCEINLINE void CopyConstruct(void* Destination, const ElementType* Source, siz
}
}
template <typename ElementType>
requires CMoveConstructible<ElementType>
template <CMoveConstructible ElementType>
FORCEINLINE void MoveConstruct(void* Destination, ElementType* Source, size_t Count = 1)
{
if constexpr (CTriviallyMoveConstructible<ElementType>)
@ -86,8 +83,7 @@ FORCEINLINE void MoveConstruct(void* Destination, ElementType* Source, size_t Co
}
}
template <typename ElementType>
requires CCopyAssignable<ElementType>
template <CCopyAssignable ElementType>
FORCEINLINE void CopyAssign(ElementType* Destination, const ElementType* Source, size_t Count = 1)
{
if constexpr (CTriviallyCopyAssignable<ElementType>)
@ -106,8 +102,7 @@ FORCEINLINE void CopyAssign(ElementType* Destination, const ElementType* Source,
}
}
template <typename ElementType>
requires CMoveAssignable<ElementType>
template <CMoveAssignable ElementType>
FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_t Count = 1)
{
if constexpr (CTriviallyMoveAssignable<ElementType>)
@ -126,8 +121,7 @@ FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_
}
}
template <typename ElementType>
requires CDestructible<ElementType>
template <CDestructible ElementType>
FORCEINLINE void Destruct(ElementType* Element, size_t Count = 1)
{
if constexpr (!CTriviallyDestructible<ElementType>)