refactor(*): replace the old with the new iterator and range library

This commit is contained in:
2024-12-17 21:49:37 +08:00
parent 0a37460f24
commit 6a37e91639
21 changed files with 312 additions and 640 deletions

View File

@ -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)