From 7a8a1648d173d4589724d259150f53f7dac57b62 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Wed, 1 Mar 2023 18:32:32 +0800 Subject: [PATCH] feat(containers): add TArray::Reference and TArray::ConstReference etc --- Redcraft.Utility/Source/Public/Containers/Array.h | 9 ++++++--- Redcraft.Utility/Source/Public/Containers/ArrayView.h | 2 ++ Redcraft.Utility/Source/Public/Containers/StaticArray.h | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Containers/Array.h b/Redcraft.Utility/Source/Public/Containers/Array.h index 10f2ca2..4bdddd3 100644 --- a/Redcraft.Utility/Source/Public/Containers/Array.h +++ b/Redcraft.Utility/Source/Public/Containers/Array.h @@ -111,6 +111,9 @@ public: using ElementType = T; using AllocatorType = Allocator; + using Reference = T&; + using ConstReference = const T&; + using Iterator = NAMESPACE_PRIVATE::TArrayIterator; using ConstIterator = NAMESPACE_PRIVATE::TArrayIterator; @@ -1189,8 +1192,8 @@ private: FORCEINLINE size_t& GetMax() { return ArrayMax; } FORCEINLINE size_t GetMax() const { return ArrayMax; } - FORCEINLINE A& GetAllocator() { return Allocator; } - FORCEINLINE const A& GetAllocator() const { return Allocator; } + FORCEINLINE A& GetAllocator() { return AllocatorInstance; } + FORCEINLINE const A& GetAllocator() const { return AllocatorInstance; } private: @@ -1199,7 +1202,7 @@ private: size_t ArrayNum; size_t ArrayMax; - A Allocator; + A AllocatorInstance; }; diff --git a/Redcraft.Utility/Source/Public/Containers/ArrayView.h b/Redcraft.Utility/Source/Public/Containers/ArrayView.h index 786079e..beeb0da 100644 --- a/Redcraft.Utility/Source/Public/Containers/ArrayView.h +++ b/Redcraft.Utility/Source/Public/Containers/ArrayView.h @@ -140,6 +140,8 @@ public: using ElementType = T; + using Reference = T&; + using Iterator = NAMESPACE_PRIVATE::TArrayViewIterator; using ReverseIterator = TReverseIterator; diff --git a/Redcraft.Utility/Source/Public/Containers/StaticArray.h b/Redcraft.Utility/Source/Public/Containers/StaticArray.h index c55f978..f7adf18 100644 --- a/Redcraft.Utility/Source/Public/Containers/StaticArray.h +++ b/Redcraft.Utility/Source/Public/Containers/StaticArray.h @@ -22,7 +22,10 @@ struct TStaticArray final { using ElementType = T; - + + using Reference = T&; + using ConstReference = const T&; + using Iterator = TArrayView< T, N>::Iterator; using ConstIterator = TArrayView::Iterator;