diff --git a/Redcraft.Utility/Source/Public/Templates/UniquePointer.h b/Redcraft.Utility/Source/Public/Templates/UniquePointer.h index 628d3f3..ec05de6 100644 --- a/Redcraft.Utility/Source/Public/Templates/UniquePointer.h +++ b/Redcraft.Utility/Source/Public/Templates/UniquePointer.h @@ -2,6 +2,7 @@ #include "CoreTypes.h" #include "Templates/Utility.h" +#include "Templates/Noncopyable.h" #include "TypeTraits/PrimaryType.h" #include "TypeTraits/Miscellaneous.h" #include "TypeTraits/TypeProperties.h" @@ -14,24 +15,24 @@ NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_PRIVATE_BEGIN template && !CFinal> -class TUniquePtrStorage; +class TUniqueStorage; template -class TUniquePtrStorage : private E +class TUniqueStorage : private E { public: - FORCEINLINE constexpr TUniquePtrStorage() = delete; + FORCEINLINE constexpr TUniqueStorage() = delete; - FORCEINLINE constexpr TUniquePtrStorage(T* InPtr) : E(), Pointer(InPtr) { } + FORCEINLINE constexpr TUniqueStorage(T* InPtr) : E(), Pointer(InPtr) { } template - FORCEINLINE constexpr TUniquePtrStorage(T* InPtr, U&& InDeleter) : E(Forward(InDeleter)), Pointer(InPtr) { } + FORCEINLINE constexpr TUniqueStorage(T* InPtr, U&& InDeleter) : E(Forward(InDeleter)), Pointer(InPtr) { } - FORCEINLINE constexpr TUniquePtrStorage(const TUniquePtrStorage&) = delete; - FORCEINLINE constexpr TUniquePtrStorage(TUniquePtrStorage&& InValue) = default; - FORCEINLINE constexpr TUniquePtrStorage& operator=(const TUniquePtrStorage&) = delete; - FORCEINLINE constexpr TUniquePtrStorage& operator=(TUniquePtrStorage&&) = default; + FORCEINLINE constexpr TUniqueStorage(const TUniqueStorage&) = delete; + FORCEINLINE constexpr TUniqueStorage(TUniqueStorage&& InValue) = default; + FORCEINLINE constexpr TUniqueStorage& operator=(const TUniqueStorage&) = delete; + FORCEINLINE constexpr TUniqueStorage& operator=(TUniqueStorage&&) = default; FORCEINLINE constexpr T*& GetPointer() { return Pointer; } FORCEINLINE constexpr T* GetPointer() const { return Pointer; } @@ -48,21 +49,21 @@ private: }; template -class TUniquePtrStorage +class TUniqueStorage { public: - FORCEINLINE constexpr TUniquePtrStorage() = delete; + FORCEINLINE constexpr TUniqueStorage() = delete; - FORCEINLINE constexpr TUniquePtrStorage(T* InPtr) : E(), Pointer(InPtr) { } + FORCEINLINE constexpr TUniqueStorage(T* InPtr) : E(), Pointer(InPtr) { } template - FORCEINLINE constexpr TUniquePtrStorage(T* InPtr, U&& InDeleter) : Pointer(InPtr), Deleter(Forward(InDeleter)) { } + FORCEINLINE constexpr TUniqueStorage(T* InPtr, U&& InDeleter) : Pointer(InPtr), Deleter(Forward(InDeleter)) { } - FORCEINLINE constexpr TUniquePtrStorage(const TUniquePtrStorage&) = delete; - FORCEINLINE constexpr TUniquePtrStorage(TUniquePtrStorage&& InValue) = default; - FORCEINLINE constexpr TUniquePtrStorage& operator=(const TUniquePtrStorage&) = delete; - FORCEINLINE constexpr TUniquePtrStorage& operator=(TUniquePtrStorage&&) = default; + FORCEINLINE constexpr TUniqueStorage(const TUniqueStorage&) = delete; + FORCEINLINE constexpr TUniqueStorage(TUniqueStorage&& InValue) = default; + FORCEINLINE constexpr TUniqueStorage& operator=(const TUniqueStorage&) = delete; + FORCEINLINE constexpr TUniqueStorage& operator=(TUniqueStorage&&) = default; FORCEINLINE constexpr T*& GetPointer() { return Pointer; } FORCEINLINE constexpr T* GetPointer() const { return Pointer; } @@ -122,8 +123,7 @@ struct TDefaultDelete }; /** This is essentially a reference version of TUniquePtr. */ -template > requires (CObject && !CBoundedArray && !CRValueReference - && ((!CArray && CInvocable) || (CArray && CInvocable*>))) +template *> E = TDefaultDelete> requires (CObject && !CBoundedArray && !CRValueReference) class TUniqueRef final : private FSingleton { public: @@ -233,7 +233,7 @@ public: private: - NAMESPACE_PRIVATE::TUniquePtrStorage Storage; + NAMESPACE_PRIVATE::TUniqueStorage Storage; }; @@ -358,13 +358,12 @@ public: private: - NAMESPACE_PRIVATE::TUniquePtrStorage Storage; + NAMESPACE_PRIVATE::TUniqueStorage Storage; }; /** Single-ownership smart pointer. Use this when you need an object's lifetime to be strictly bound to the lifetime of a single smart pointer. */ -template > requires (CObject && !CBoundedArray && !CRValueReference - && ((!CArray && CInvocable) || (CArray && CInvocable*>))) +template *> E = TDefaultDelete> requires (CObject && !CBoundedArray && !CRValueReference) class TUniquePtr final : private FNoncopyable { public: @@ -488,10 +487,9 @@ public: private: - NAMESPACE_PRIVATE::TUniquePtrStorage Storage; + NAMESPACE_PRIVATE::TUniqueStorage Storage; - template requires (CObject && !CBoundedArray && !CRValueReference - && ((!CArray && CInvocable) || (CArray && CInvocable*>))) + template *> OtherE> requires (CObject && !CBoundedArray && !CRValueReference) friend class TUniquePtr; }; @@ -631,10 +629,9 @@ public: private: - NAMESPACE_PRIVATE::TUniquePtrStorage Storage; - - template requires (CObject && !CBoundedArray && !CRValueReference - && ((!CArray && CInvocable) || (CArray && CInvocable*>))) + NAMESPACE_PRIVATE::TUniqueStorage Storage; + + template *> OtherE> requires (CObject && !CBoundedArray && !CRValueReference) friend class TUniquePtr; };