Added TArrayView support to TSet's constructor and fixed TArrayView deduction in its Append overload.

Added deduction guide for TSet to allow CTAD.

#rb devin.doucette

[CL 31921664 by steve robb in ue5-main branch]
This commit is contained in:
steve robb
2024-02-29 15:55:13 -05:00
parent 07bdca42d5
commit 6fea413641

View File

@@ -317,10 +317,10 @@ public:
*this = Copy;
}
FORCEINLINE explicit TSet(const TArray<ElementType>& InArray)
FORCEINLINE explicit TSet(TArrayView<const ElementType> InArrayView)
: HashSize(0)
{
Append(InArray);
Append(InArrayView);
}
FORCEINLINE explicit TSet(TArray<ElementType>&& InArray)
@@ -774,28 +774,7 @@ public:
return FSetElementId(NewHashIndex);
}
template<typename ViewSizeType>
void Append(TArrayView<ElementType, ViewSizeType> InElements)
{
Reserve(Elements.Num() + InElements.Num());
for (const ElementType& Element : InElements)
{
Add(Element);
}
}
template<typename ViewSizeType>
void Append(TArrayView<const ElementType, ViewSizeType> InElements)
{
Reserve(Elements.Num() + InElements.Num());
for (const ElementType& Element : InElements)
{
Add(Element);
}
}
template<typename ArrayAllocator>
void Append(const TArray<ElementType, ArrayAllocator>& InElements)
void Append(TArrayView<const ElementType> InElements)
{
Reserve(Elements.Num() + InElements.Num());
for (const ElementType& Element : InElements)
@@ -1809,6 +1788,9 @@ public:
FORCEINLINE TRangedForConstIterator end() const { return TRangedForConstIterator(Elements.end()); }
};
template <typename RangeType>
TSet(RangeType&&) -> TSet<TElementType_T<RangeType>>;
namespace Freeze
{
template<typename ElementType, typename KeyFuncs, typename Allocator>