diff --git a/Redcraft.Utility/Source/Public/Templates/Utility.h b/Redcraft.Utility/Source/Public/Templates/Utility.h index 793bab5..b66dbc5 100644 --- a/Redcraft.Utility/Source/Public/Templates/Utility.h +++ b/Redcraft.Utility/Source/Public/Templates/Utility.h @@ -73,6 +73,18 @@ FORCEINLINE constexpr void Swap(T& A, T& B) B = MoveTemp(Temp); } +/** Overloads the Swap algorithm for array. */ +template requires (CMoveConstructible && CMoveAssignable) +FORCEINLINE constexpr void Swap(T(&A)[N], T(&B)[N]) +{ + for (size_t Index = 0; Index < N; ++Index) + { + T Temp = MoveTemp(A[Index]); + A[Index] = MoveTemp(B[Index]); + B[Index] = MoveTemp(Temp); + } +} + /** Replaces the value of 'A' with 'B' and returns the old value of 'A'. */ template requires (CMoveConstructible && CAssignableFrom) FORCEINLINE constexpr T Exchange(T& A, U&& B)