#pragma once #include "CoreTypes.h" #include "TypeTraits/CompositeType.h" #include "TypeTraits/Miscellaneous.h" #include "TypeTraits/SupportedOperations.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) template constexpr const T& AsConst(T& Ref) { return Ref; } template void AsConst(const T&& Ref) = delete; template constexpr TRemoveReference&& MoveTemp(T&& Obj) { using CastType = TRemoveReference; return static_cast(Obj); } template constexpr T CopyTemp(T& Obj) { return const_cast(Obj); } template constexpr T CopyTemp(const T& Obj) { return Obj; } template constexpr T&& CopyTemp(T&& Obj) { return MoveTemp(Obj); } template constexpr T&& Forward(TRemoveReference& Obj) { return static_cast(Obj); } template constexpr T&& Forward(TRemoveReference&& Obj) { return static_cast(Obj); } template requires requires(T& A, T& B) { A.Swap(B); } || (CMoveConstructible && CMoveAssignable) constexpr void Swap(T& A, T& B) { if constexpr (requires(T& A, T& B) { A.Swap(B); }) { A.Swap(B); } else { T Temp = MoveTemp(A); A = MoveTemp(B); B = MoveTemp(Temp); } } template requires CMoveConstructible && CAssignableFrom constexpr T Exchange(T& A, U&& B) { T Temp = MoveTemp(A); A = Forward(B); return Temp; } template constexpr T&& DeclVal(); template requires CObject constexpr T* AddressOf(T& Object) { return reinterpret_cast(&const_cast(reinterpret_cast(Object))); } template requires (!CObject) constexpr T* AddressOf(T& Object) { return &Object; } struct FIgnore { template constexpr void operator=(T&&) const { } }; inline constexpr FIgnore Ignore; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END