#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 const T(&AsConst(T(&Array)[N]))[N] { return Array; } template constexpr typename TRemoveReference::Type&& MoveTemp(T&& Obj) { typedef typename TRemoveReference::Type CastType; return (CastType&&)Obj; } template constexpr T CopyTemp(T& Val) { return const_cast(Val); } template constexpr T CopyTemp(const T& Val) { return Val; } template constexpr T&& CopyTemp(T&& Val) { return MoveTemp(Val); } template constexpr T&& Forward(typename TRemoveReference::Type& Obj) { return (T&&)Obj; } template constexpr T&& Forward(typename TRemoveReference::Type&& Obj) { return (T&&)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 && CAssignable 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