From 40d27eece6d41b5a65a05fa0bc53b6e8f07086bd Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Sun, 26 Feb 2023 22:13:45 +0800 Subject: [PATCH] refactor(containers): add the CElementalObject concept to constrain elements --- Redcraft.Utility/Source/Public/Containers/Array.h | 2 +- Redcraft.Utility/Source/Public/Containers/ArrayView.h | 10 +++++----- Redcraft.Utility/Source/Public/Containers/Iterator.h | 3 +++ .../Source/Public/Containers/StaticArray.h | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Containers/Array.h b/Redcraft.Utility/Source/Public/Containers/Array.h index b02e23d..db74f27 100644 --- a/Redcraft.Utility/Source/Public/Containers/Array.h +++ b/Redcraft.Utility/Source/Public/Containers/Array.h @@ -175,7 +175,7 @@ private: NAMESPACE_PRIVATE_END /** Dynamic array. The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets to regular pointers to elements. */ -template requires (!CConst && CDestructible && CInstantiableAllocator) +template requires (!CConst) class TArray final { public: diff --git a/Redcraft.Utility/Source/Public/Containers/ArrayView.h b/Redcraft.Utility/Source/Public/Containers/ArrayView.h index 606f0e1..df74a75 100644 --- a/Redcraft.Utility/Source/Public/Containers/ArrayView.h +++ b/Redcraft.Utility/Source/Public/Containers/ArrayView.h @@ -14,7 +14,7 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template +template class TArrayView; NAMESPACE_PRIVATE_BEGIN @@ -103,7 +103,7 @@ private: template friend class TArrayViewIterator; - template + template friend class NAMESPACE_REDCRAFT::TArrayView; }; @@ -116,10 +116,10 @@ struct TEnableArrayNum { size_t ArrayNum; }; NAMESPACE_PRIVATE_END -template +template struct TStaticArray; -template requires (!CConst && CDestructible && CInstantiableAllocator) +template requires (!CConst) class TArray; inline constexpr size_t DynamicExtent = INDEX_NONE; @@ -129,7 +129,7 @@ inline constexpr size_t DynamicExtent = INDEX_NONE; * the sequence at position zero. A TArrayView can either have a static extent, in which case the number of elements in the sequence * is known at compile-time and encoded in the type, or a dynamic extent. */ -template +template class TArrayView final : private NAMESPACE_PRIVATE::TEnableArrayNum { private: diff --git a/Redcraft.Utility/Source/Public/Containers/Iterator.h b/Redcraft.Utility/Source/Public/Containers/Iterator.h index d3e6d1c..bb7d6c7 100644 --- a/Redcraft.Utility/Source/Public/Containers/Iterator.h +++ b/Redcraft.Utility/Source/Public/Containers/Iterator.h @@ -14,6 +14,9 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) +template +concept CElementalObject = CObject && CDestructible; + NAMESPACE_PRIVATE_BEGIN template using WithReference = T&; diff --git a/Redcraft.Utility/Source/Public/Containers/StaticArray.h b/Redcraft.Utility/Source/Public/Containers/StaticArray.h index 5a0d453..c55f978 100644 --- a/Redcraft.Utility/Source/Public/Containers/StaticArray.h +++ b/Redcraft.Utility/Source/Public/Containers/StaticArray.h @@ -17,7 +17,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) /** TStaticArray is a container that encapsulates fixed size arrays. */ -template +template struct TStaticArray final {