refactor(*): replace the old with the new iterator and range library
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Miscellaneous/Container.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
@ -13,8 +12,7 @@ template <typename T, T... Ints>
|
||||
struct TIntegerSequence
|
||||
{
|
||||
using FValueType = T;
|
||||
FORCEINLINE static constexpr size_t Num() { return sizeof...(Ints); }
|
||||
FORCEINLINE static constexpr const T* GetData() { return NAMESPACE_REDCRAFT::GetData({ Ints... }); }
|
||||
FORCEINLINE static constexpr size_t Num() { return sizeof...(Ints); }
|
||||
};
|
||||
|
||||
NAMESPACE_PRIVATE_BEGIN
|
||||
|
@ -56,8 +56,8 @@ public:
|
||||
FORCEINLINE constexpr TOptional(FInvalid) : TOptional() { }
|
||||
|
||||
/** Constructs an object with initial content an object, direct-initialized from Forward<U>(InValue). */
|
||||
template <typename U = T> requires (CConstructibleFrom<T, U&&>)
|
||||
&& (!CSameAs<TRemoveCVRef<U>, FInPlace>) && (!CSameAs<TOptional, TRemoveCVRef<U>>)
|
||||
template <typename U = T> requires (CConstructibleFrom<T, U&&>
|
||||
&& !CSameAs<TRemoveCVRef<U>, FInPlace> && !CSameAs<TOptional, TRemoveCVRef<U>>)
|
||||
FORCEINLINE constexpr explicit (!CConvertibleTo<U&&, T>) TOptional(U&& InValue)
|
||||
: TOptional(InPlace, Forward<U>(InValue))
|
||||
{ }
|
||||
|
@ -94,6 +94,20 @@ FORCEINLINE constexpr size_t GetTypeHash(const T& A)
|
||||
return GetTypeHash(A.hash_code());
|
||||
}
|
||||
|
||||
/** Overloads the GetTypeHash algorithm for arrays. */
|
||||
template <typename T, size_t N> requires (requires(const T& A) { { GetTypeHash(A) } -> CSameAs<size_t>; })
|
||||
FORCEINLINE constexpr size_t GetTypeHash(T(&A)[N])
|
||||
{
|
||||
size_t Result = 3516520171;
|
||||
|
||||
for (size_t Index = 0; Index < N; ++Index)
|
||||
{
|
||||
Result = HashCombine(Result, GetTypeHash(A[Index]));
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
concept CHashable = requires(const T& A) { { GetTypeHash(A) } -> CSameAs<size_t>; };
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/CompositeType.h"
|
||||
#include "TypeTraits/Common.h"
|
||||
#include "TypeTraits/Miscellaneous.h"
|
||||
#include "TypeTraits/SupportedOperations.h"
|
||||
|
||||
@ -73,6 +73,17 @@ FORCEINLINE constexpr void Swap(T& A, T& B)
|
||||
B = MoveTemp(Temp);
|
||||
}
|
||||
|
||||
/** Overloads the Swap algorithm for arrays. */
|
||||
template <typename T, typename U, size_t N> requires (CCommonReference<T, U>
|
||||
&& requires(T& A, U& B) { Swap(A, A); Swap(B, B); Swap(A, B); Swap(B, A); })
|
||||
FORCEINLINE constexpr void Swap(T(&A)[N], U(&B)[N])
|
||||
{
|
||||
for (size_t Index = 0; Index < N; ++Index)
|
||||
{
|
||||
Swap(A[Index], B[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Replaces the value of 'A' with 'B' and returns the old value of 'A'. */
|
||||
template <typename T, typename U = T> requires (CMoveConstructible<T> && CAssignableFrom<T&, U>)
|
||||
FORCEINLINE constexpr T Exchange(T& A, U&& B)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Templates/Meta.h"
|
||||
#include "Templates/Invoke.h"
|
||||
#include "Templates/Utility.h"
|
||||
@ -478,7 +479,7 @@ struct TVariantVisitImpl
|
||||
for (size_t Index = 0; Index < sizeof...(VariantTypes); ++Index)
|
||||
{
|
||||
Result *= VariantNums[Index];
|
||||
Result += GetData(Indices)[Index];
|
||||
Result += Range::Begin(Indices)[Index];
|
||||
}
|
||||
|
||||
return Result;
|
||||
|
Reference in New Issue
Block a user