fix(containers): remove qualifiers for Iterator::ElementType

This commit is contained in:
Redstone1024 2024-10-30 23:14:52 +08:00
parent 1f20b782bf
commit 1cfa252779
10 changed files with 196 additions and 200 deletions

View File

@ -259,10 +259,10 @@ void TestStringView()
always_check(ViewI == LITERAL(T, "Hello, World! Goodbye, World!")); always_check(ViewI == LITERAL(T, "Hello, World! Goodbye, World!"));
always_check(ViewII == LITERAL(T, "Hello, World! Goodbye, World!")); always_check(ViewII == LITERAL(T, "Hello, World! Goodbye, World!"));
TStringView<T> ViewA(ViewI.Begin(), 13); TStringView ViewA(ViewI.Begin(), 13);
TStringView<T> ViewB(ViewI.Begin(), ViewI.End()); TStringView ViewB(ViewI.Begin(), ViewI.End());
TStringView<T> ViewC(&Buffer[0], 13); TStringView ViewC(&Buffer[0], 13);
TStringView<T> ViewD(&Buffer[0]); TStringView ViewD(&Buffer[0]);
always_check(ViewA == LITERAL(T, "Hello, World!")); always_check(ViewA == LITERAL(T, "Hello, World!"));
always_check(ViewB == LITERAL(T, "Hello, World! Goodbye, World!")); always_check(ViewB == LITERAL(T, "Hello, World! Goodbye, World!"));
@ -335,10 +335,11 @@ void TestTemplateString()
always_check(TStringView(Empty.ToCString()) == LITERAL(T, "")); always_check(TStringView(Empty.ToCString()) == LITERAL(T, ""));
TString<T> StrA(32, LITERAL(T, 'A')); TString<T> StrA(32, LITERAL(T, 'A'));
TString<T> StrB(LITERAL(T, "ABCDEFG"), 3);
TString<T> StrC(LITERAL(T, "ABCDEFG")); TString StrB(LITERAL(T, "ABCDEFG"), 3);
TString<T> StrD(TStringView(LITERAL(T, "ABCDEFG"))); TString StrC(LITERAL(T, "ABCDEFG"));
TString<T> StrE({ LITERAL(T, 'A'), LITERAL(T, 'B'), LITERAL(T, 'C') }); TString StrD(TStringView(LITERAL(T, "ABCDEFG")));
TString StrE({ LITERAL(T, 'A'), LITERAL(T, 'B'), LITERAL(T, 'C') });
always_check(TStringView(StrA.ToCString()) == LITERAL(T, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); always_check(TStringView(StrA.ToCString()) == LITERAL(T, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
always_check(TStringView(StrB.ToCString()) == LITERAL(T, "ABC")); always_check(TStringView(StrB.ToCString()) == LITERAL(T, "ABC"));
@ -346,11 +347,11 @@ void TestTemplateString()
always_check(TStringView(StrD.ToCString()) == LITERAL(T, "ABCDEFG")); always_check(TStringView(StrD.ToCString()) == LITERAL(T, "ABCDEFG"));
always_check(TStringView(StrE.ToCString()) == LITERAL(T, "ABC")); always_check(TStringView(StrE.ToCString()) == LITERAL(T, "ABC"));
TString<T> StrI(StrC); TString StrI(StrC);
TString<T> StrII(MoveTemp(StrC)); TString StrII(MoveTemp(StrC));
TString<T> StrIII = Empty; TString StrIII = Empty;
TString<T> StrIV = Empty; TString StrIV = Empty;
StrIII = StrD; StrIII = StrD;
StrIV = MoveTemp(StrD); StrIV = MoveTemp(StrD);
@ -370,7 +371,7 @@ void TestTemplateString()
} }
{ {
TString<T> Str = LITERAL(T, "A"); TString Str = LITERAL(T, "A");
always_check(!Str.IsEmpty()); always_check(!Str.IsEmpty());
always_check(Str.Num() == 1); always_check(Str.Num() == 1);
@ -398,7 +399,7 @@ void TestTemplateString()
} }
{ {
TString<T> Str = LITERAL(T, "##"); TString Str = LITERAL(T, "##");
Str.Insert(1, LITERAL(T, 'A')); Str.Insert(1, LITERAL(T, 'A'));
@ -418,7 +419,7 @@ void TestTemplateString()
} }
{ {
TString<T> Str = LITERAL(T, "A"); TString Str = LITERAL(T, "A");
Str.PushBack(LITERAL(T, 'B')); Str.PushBack(LITERAL(T, 'B'));

View File

@ -23,8 +23,8 @@ class TArray final
{ {
private: private:
template <bool bConst> template <bool bConst, typename = TConditional<bConst, const T, T>>
class IteratorImpl; class TIteratorImpl;
public: public:
@ -34,8 +34,8 @@ public:
using Reference = T&; using Reference = T&;
using ConstReference = const T&; using ConstReference = const T&;
using Iterator = IteratorImpl<false>; using Iterator = TIteratorImpl<false>;
using ConstIterator = IteratorImpl<true >; using ConstIterator = TIteratorImpl<true >;
using ReverseIterator = TReverseIterator< Iterator>; using ReverseIterator = TReverseIterator< Iterator>;
using ConstReverseIterator = TReverseIterator<ConstIterator>; using ConstReverseIterator = TReverseIterator<ConstIterator>;
@ -975,56 +975,56 @@ private:
private: private:
template <bool bConst> template <bool bConst, typename U>
class IteratorImpl class TIteratorImpl
{ {
public: public:
using ElementType = TConditional<bConst, const T, T>; using ElementType = TRemoveCV<T>;
FORCEINLINE IteratorImpl() = default; FORCEINLINE TIteratorImpl() = default;
# if DO_CHECK # if DO_CHECK
FORCEINLINE IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Owner(InValue.Owner), Pointer(InValue.Pointer) : Owner(InValue.Owner), Pointer(InValue.Pointer)
{ } { }
# else # else
FORCEINLINE IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Pointer(InValue.Pointer) : Pointer(InValue.Pointer)
{ } { }
# endif # endif
FORCEINLINE IteratorImpl(const IteratorImpl&) = default; FORCEINLINE TIteratorImpl(const TIteratorImpl&) = default;
FORCEINLINE IteratorImpl(IteratorImpl&&) = default; FORCEINLINE TIteratorImpl(TIteratorImpl&&) = default;
FORCEINLINE IteratorImpl& operator=(const IteratorImpl&) = default; FORCEINLINE TIteratorImpl& operator=(const TIteratorImpl&) = default;
FORCEINLINE IteratorImpl& operator=(IteratorImpl&&) = default; FORCEINLINE TIteratorImpl& operator=(TIteratorImpl&&) = default;
NODISCARD friend FORCEINLINE bool operator==(const IteratorImpl& LHS, const IteratorImpl& RHS) { return LHS.Pointer == RHS.Pointer; } NODISCARD friend FORCEINLINE bool operator==(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { return LHS.Pointer == RHS.Pointer; }
NODISCARD friend FORCEINLINE strong_ordering operator<=>(const IteratorImpl& LHS, const IteratorImpl& RHS) { return LHS.Pointer <=> RHS.Pointer; } NODISCARD friend FORCEINLINE strong_ordering operator<=>(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { return LHS.Pointer <=> RHS.Pointer; }
NODISCARD FORCEINLINE ElementType& operator*() const { CheckThis(true); return *Pointer; } NODISCARD FORCEINLINE U& operator*() const { CheckThis(true); return *Pointer; }
NODISCARD FORCEINLINE ElementType* operator->() const { CheckThis(true); return Pointer; } NODISCARD FORCEINLINE U* operator->() const { CheckThis(true); return Pointer; }
NODISCARD FORCEINLINE ElementType& operator[](ptrdiff Index) const { IteratorImpl Temp = *this + Index; return *Temp; } NODISCARD FORCEINLINE U& operator[](ptrdiff Index) const { TIteratorImpl Temp = *this + Index; return *Temp; }
FORCEINLINE IteratorImpl& operator++() { ++Pointer; CheckThis(); return *this; } FORCEINLINE TIteratorImpl& operator++() { ++Pointer; CheckThis(); return *this; }
FORCEINLINE IteratorImpl& operator--() { --Pointer; CheckThis(); return *this; } FORCEINLINE TIteratorImpl& operator--() { --Pointer; CheckThis(); return *this; }
FORCEINLINE IteratorImpl operator++(int) { IteratorImpl Temp = *this; ++*this; return Temp; } FORCEINLINE TIteratorImpl operator++(int) { TIteratorImpl Temp = *this; ++*this; return Temp; }
FORCEINLINE IteratorImpl operator--(int) { IteratorImpl Temp = *this; --*this; return Temp; } FORCEINLINE TIteratorImpl operator--(int) { TIteratorImpl Temp = *this; --*this; return Temp; }
FORCEINLINE IteratorImpl& operator+=(ptrdiff Offset) { Pointer += Offset; CheckThis(); return *this; } FORCEINLINE TIteratorImpl& operator+=(ptrdiff Offset) { Pointer += Offset; CheckThis(); return *this; }
FORCEINLINE IteratorImpl& operator-=(ptrdiff Offset) { Pointer -= Offset; CheckThis(); return *this; } FORCEINLINE TIteratorImpl& operator-=(ptrdiff Offset) { Pointer -= Offset; CheckThis(); return *this; }
NODISCARD friend FORCEINLINE IteratorImpl operator+(IteratorImpl Iter, ptrdiff Offset) { IteratorImpl Temp = Iter; Temp += Offset; return Temp; } NODISCARD friend FORCEINLINE TIteratorImpl operator+(TIteratorImpl Iter, ptrdiff Offset) { TIteratorImpl Temp = Iter; Temp += Offset; return Temp; }
NODISCARD friend FORCEINLINE IteratorImpl operator+(ptrdiff Offset, IteratorImpl Iter) { IteratorImpl Temp = Iter; Temp += Offset; return Temp; } NODISCARD friend FORCEINLINE TIteratorImpl operator+(ptrdiff Offset, TIteratorImpl Iter) { TIteratorImpl Temp = Iter; Temp += Offset; return Temp; }
NODISCARD FORCEINLINE IteratorImpl operator-(ptrdiff Offset) const { IteratorImpl Temp = *this; Temp -= Offset; return Temp; } NODISCARD FORCEINLINE TIteratorImpl operator-(ptrdiff Offset) const { TIteratorImpl Temp = *this; Temp -= Offset; return Temp; }
NODISCARD friend FORCEINLINE ptrdiff operator-(const IteratorImpl& LHS, const IteratorImpl& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Pointer - RHS.Pointer; } NODISCARD friend FORCEINLINE ptrdiff operator-(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Pointer - RHS.Pointer; }
NODISCARD FORCEINLINE explicit operator TObserverPtr<ElementType[]>() const { CheckThis(); return TObserverPtr<ElementType[]>(Pointer); } NODISCARD FORCEINLINE explicit operator TObserverPtr<U[]>() const { CheckThis(); return TObserverPtr<U[]>(Pointer); }
private: private:
@ -1032,14 +1032,14 @@ private:
const TArray* Owner = nullptr; const TArray* Owner = nullptr;
# endif # endif
ElementType* Pointer = nullptr; U* Pointer = nullptr;
# if DO_CHECK # if DO_CHECK
FORCEINLINE IteratorImpl(const TArray* InContainer, ElementType* InPointer) FORCEINLINE TIteratorImpl(const TArray* InContainer, U* InPointer)
: Owner(InContainer), Pointer(InPointer) : Owner(InContainer), Pointer(InPointer)
{ } { }
# else # else
FORCEINLINE IteratorImpl(const TArray* InContainer, ElementType* InPointer) FORCEINLINE TIteratorImpl(const TArray* InContainer, U* InPointer)
: Pointer(InPointer) : Pointer(InPointer)
{ } { }
# endif # endif
@ -1050,7 +1050,7 @@ private:
checkf(!(bExceptEnd && Owner->End() == *this), TEXT("Read access violation. Please check IsValidIterator().")); checkf(!(bExceptEnd && Owner->End() == *this), TEXT("Read access violation. Please check IsValidIterator()."));
} }
template <bool> friend class IteratorImpl; template <bool, typename> friend class TIteratorImpl;
friend TArray; friend TArray;

View File

@ -303,7 +303,7 @@ public:
{ {
public: public:
using ElementType = T; using ElementType = TRemoveCV<T>;
FORCEINLINE constexpr Iterator() = default; FORCEINLINE constexpr Iterator() = default;
FORCEINLINE constexpr Iterator(const Iterator&) = default; FORCEINLINE constexpr Iterator(const Iterator&) = default;
@ -315,10 +315,10 @@ public:
NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const Iterator& LHS, const Iterator& RHS) { return LHS.Pointer <=> RHS.Pointer; } NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const Iterator& LHS, const Iterator& RHS) { return LHS.Pointer <=> RHS.Pointer; }
NODISCARD FORCEINLINE constexpr ElementType& operator*() const { CheckThis(true); return *Pointer; } NODISCARD FORCEINLINE constexpr T& operator*() const { CheckThis(true); return *Pointer; }
NODISCARD FORCEINLINE constexpr ElementType* operator->() const { CheckThis(true); return Pointer; } NODISCARD FORCEINLINE constexpr T* operator->() const { CheckThis(true); return Pointer; }
NODISCARD FORCEINLINE constexpr ElementType& operator[](ptrdiff Index) const { Iterator Temp = *this + Index; return *Temp; } NODISCARD FORCEINLINE constexpr T& operator[](ptrdiff Index) const { Iterator Temp = *this + Index; return *Temp; }
FORCEINLINE constexpr Iterator& operator++() { ++Pointer; CheckThis(); return *this; } FORCEINLINE constexpr Iterator& operator++() { ++Pointer; CheckThis(); return *this; }
FORCEINLINE constexpr Iterator& operator--() { --Pointer; CheckThis(); return *this; } FORCEINLINE constexpr Iterator& operator--() { --Pointer; CheckThis(); return *this; }
@ -336,7 +336,7 @@ public:
NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const Iterator& LHS, const Iterator& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Pointer - RHS.Pointer; } NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const Iterator& LHS, const Iterator& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Pointer - RHS.Pointer; }
NODISCARD FORCEINLINE constexpr explicit operator TObserverPtr<ElementType[]>() const { CheckThis(); return TObserverPtr<ElementType[]>(Pointer); } NODISCARD FORCEINLINE constexpr explicit operator TObserverPtr<T[]>() const { CheckThis(); return TObserverPtr<T[]>(Pointer); }
private: private:
@ -344,14 +344,14 @@ public:
const TArrayView* Owner = nullptr; const TArrayView* Owner = nullptr;
# endif # endif
ElementType* Pointer = nullptr; T* Pointer = nullptr;
# if DO_CHECK # if DO_CHECK
FORCEINLINE constexpr Iterator(const TArrayView* InContainer, ElementType* InPointer) FORCEINLINE constexpr Iterator(const TArrayView* InContainer, T* InPointer)
: Owner(InContainer), Pointer(InPointer) : Owner(InContainer), Pointer(InPointer)
{ } { }
# else # else
FORCEINLINE constexpr Iterator(const TArrayView* InContainer, ElementType* InPointer) FORCEINLINE constexpr Iterator(const TArrayView* InContainer, T* InPointer)
: Pointer(InPointer) : Pointer(InPointer)
{ } { }
# endif # endif

View File

@ -26,7 +26,7 @@ class TBitset final
private: private:
template <bool bConst> template <bool bConst>
class IteratorImpl; class TIteratorImpl;
public: public:
@ -37,8 +37,8 @@ public:
class Reference; class Reference;
using ConstReference = bool; using ConstReference = bool;
using Iterator = IteratorImpl<false>; using Iterator = TIteratorImpl<false>;
using ConstIterator = IteratorImpl<true >; using ConstIterator = TIteratorImpl<true >;
using ReverseIterator = TReverseIterator< Iterator>; using ReverseIterator = TReverseIterator< Iterator>;
using ConstReverseIterator = TReverseIterator<ConstIterator>; using ConstReverseIterator = TReverseIterator<ConstIterator>;
@ -905,7 +905,7 @@ public:
FORCEINLINE Reference& operator=(bool InValue) { Data = (Data & ~Mask) | (InValue ? Mask : 0); return *this; } FORCEINLINE Reference& operator=(bool InValue) { Data = (Data & ~Mask) | (InValue ? Mask : 0); return *this; }
FORCEINLINE Reference& operator=(const Reference& InValue) { return *this = static_cast<bool>(InValue); } FORCEINLINE Reference& operator=(const Reference& InValue) { *this = static_cast<bool>(InValue); return *this; }
FORCEINLINE Reference& operator&=(bool InValue) { Data &= InValue ? -1 : ~Mask; return *this; } FORCEINLINE Reference& operator&=(bool InValue) { Data &= InValue ? -1 : ~Mask; return *this; }
FORCEINLINE Reference& operator|=(bool InValue) { Data |= InValue ? Mask : 0; return *this; } FORCEINLINE Reference& operator|=(bool InValue) { Data |= InValue ? Mask : 0; return *this; }
@ -931,55 +931,53 @@ public:
private: private:
template <bool bConst> template <bool bConst>
class IteratorImpl class TIteratorImpl
{ {
private:
public: public:
using ElementType = TConditional<bConst, const bool, bool>; using ElementType = bool;
FORCEINLINE IteratorImpl() = default; FORCEINLINE TIteratorImpl() = default;
# if DO_CHECK # if DO_CHECK
FORCEINLINE IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Owner(InValue.Owner), Pointer(InValue.Pointer), Offset(InValue.Offset) : Owner(InValue.Owner), Pointer(InValue.Pointer), BitOffset(InValue.BitOffset)
{ } { }
# else # else
FORCEINLINE IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Pointer(InValue.Pointer), Offset(InValue.Offset) : Pointer(InValue.Pointer), BitOffset(InValue.BitOffset)
{ } { }
# endif # endif
FORCEINLINE IteratorImpl(const IteratorImpl&) = default; FORCEINLINE TIteratorImpl(const TIteratorImpl&) = default;
FORCEINLINE IteratorImpl(IteratorImpl&&) = default; FORCEINLINE TIteratorImpl(TIteratorImpl&&) = default;
FORCEINLINE IteratorImpl& operator=(const IteratorImpl&) = default; FORCEINLINE TIteratorImpl& operator=(const TIteratorImpl&) = default;
FORCEINLINE IteratorImpl& operator=(IteratorImpl&&) = default; FORCEINLINE TIteratorImpl& operator=(TIteratorImpl&&) = default;
NODISCARD friend FORCEINLINE bool operator==(const IteratorImpl& LHS, const IteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.Offset == RHS.Offset; } NODISCARD friend FORCEINLINE bool operator==(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.BitOffset == RHS.BitOffset; }
NODISCARD friend FORCEINLINE strong_ordering operator<=>(const IteratorImpl& LHS, const IteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.Offset <=> RHS.Offset; } NODISCARD friend FORCEINLINE strong_ordering operator<=>(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.BitOffset <=> RHS.BitOffset; }
NODISCARD FORCEINLINE Reference operator*() const requires (!bConst) { CheckThis(true); return Reference(*(Pointer + Offset / BlockWidth), 1ull << Offset % BlockWidth); } NODISCARD FORCEINLINE Reference operator*() const requires (!bConst) { CheckThis(true); return Reference(*(Pointer + BitOffset / BlockWidth), 1ull << BitOffset % BlockWidth); }
NODISCARD FORCEINLINE ConstReference operator*() const requires ( bConst) { CheckThis(true); return (*(Pointer + Offset / BlockWidth) & (1ull << Offset % BlockWidth)); } NODISCARD FORCEINLINE ConstReference operator*() const requires ( bConst) { CheckThis(true); return (*(Pointer + BitOffset / BlockWidth) & (1ull << BitOffset % BlockWidth)); }
NODISCARD FORCEINLINE auto operator[](ptrdiff Index) const { IteratorImpl Temp = *this + Index; return *Temp; } NODISCARD FORCEINLINE auto operator[](ptrdiff Index) const { TIteratorImpl Temp = *this + Index; return *Temp; }
FORCEINLINE IteratorImpl& operator++() { ++Offset; CheckThis(); return *this; } FORCEINLINE TIteratorImpl& operator++() { ++BitOffset; CheckThis(); return *this; }
FORCEINLINE IteratorImpl& operator--() { --Offset; CheckThis(); return *this; } FORCEINLINE TIteratorImpl& operator--() { --BitOffset; CheckThis(); return *this; }
FORCEINLINE IteratorImpl operator++(int) { IteratorImpl Temp = *this; ++*this; return Temp; } FORCEINLINE TIteratorImpl operator++(int) { TIteratorImpl Temp = *this; ++*this; return Temp; }
FORCEINLINE IteratorImpl operator--(int) { IteratorImpl Temp = *this; --*this; return Temp; } FORCEINLINE TIteratorImpl operator--(int) { TIteratorImpl Temp = *this; --*this; return Temp; }
FORCEINLINE IteratorImpl& operator+=(ptrdiff Offset) { this->Offset += Offset; CheckThis(); return *this; } FORCEINLINE TIteratorImpl& operator+=(ptrdiff Offset) { BitOffset += Offset; CheckThis(); return *this; }
FORCEINLINE IteratorImpl& operator-=(ptrdiff Offset) { this->Offset -= Offset; CheckThis(); return *this; } FORCEINLINE TIteratorImpl& operator-=(ptrdiff Offset) { BitOffset -= Offset; CheckThis(); return *this; }
NODISCARD friend FORCEINLINE IteratorImpl operator+(IteratorImpl Iter, ptrdiff Offset) { IteratorImpl Temp = Iter; Temp += Offset; return Temp; } NODISCARD friend FORCEINLINE TIteratorImpl operator+(TIteratorImpl Iter, ptrdiff Offset) { TIteratorImpl Temp = Iter; Temp += Offset; return Temp; }
NODISCARD friend FORCEINLINE IteratorImpl operator+(ptrdiff Offset, IteratorImpl Iter) { IteratorImpl Temp = Iter; Temp += Offset; return Temp; } NODISCARD friend FORCEINLINE TIteratorImpl operator+(ptrdiff Offset, TIteratorImpl Iter) { TIteratorImpl Temp = Iter; Temp += Offset; return Temp; }
NODISCARD FORCEINLINE IteratorImpl operator-(ptrdiff Offset) const { IteratorImpl Temp = *this; Temp -= Offset; return Temp; } NODISCARD FORCEINLINE TIteratorImpl operator-(ptrdiff Offset) const { TIteratorImpl Temp = *this; Temp -= Offset; return Temp; }
NODISCARD friend FORCEINLINE ptrdiff operator-(const IteratorImpl& LHS, const IteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.Offset - RHS.Offset; } NODISCARD friend FORCEINLINE ptrdiff operator-(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.BitOffset - RHS.BitOffset; }
private: private:
@ -989,16 +987,16 @@ private:
using BlockPtr = TConditional<bConst, const BlockType*, BlockType*>; using BlockPtr = TConditional<bConst, const BlockType*, BlockType*>;
BlockPtr Pointer = nullptr; BlockPtr Pointer = nullptr;
size_t Offset = 0; size_t BitOffset = 0;
# if DO_CHECK # if DO_CHECK
FORCEINLINE IteratorImpl(const TBitset* InContainer, BlockPtr InPointer, size_t InOffset) FORCEINLINE TIteratorImpl(const TBitset* InContainer, BlockPtr InPointer, size_t Offset)
: Owner(InContainer), Pointer(InPointer), Offset(InOffset) : Owner(InContainer), Pointer(InPointer), BitOffset(Offset)
{ } { }
# else # else
FORCEINLINE IteratorImpl(const TBitset* InContainer, BlockPtr InPointer, size_t InOffset) FORCEINLINE TIteratorImpl(const TBitset* InContainer, BlockPtr InPointer, size_t Offset)
: Pointer(InPointer), Offset(InOffset) : Pointer(InPointer), BitOffset(Offset)
{ } { }
# endif # endif
@ -1008,7 +1006,7 @@ private:
checkf(!(bExceptEnd && Owner->End() == *this), TEXT("Read access violation. Please check IsValidIterator().")); checkf(!(bExceptEnd && Owner->End() == *this), TEXT("Read access violation. Please check IsValidIterator()."));
} }
template <bool> friend class IteratorImpl; template <bool> friend class TIteratorImpl;
friend TBitset; friend TBitset;

View File

@ -19,7 +19,7 @@ template <typename T> using WithReference = T&;
template <typename I> struct TIteratorElementType { using Type = typename I::ElementType; }; template <typename I> struct TIteratorElementType { using Type = typename I::ElementType; };
template <typename T> struct TIteratorElementType<T*> { using Type = T; }; template <typename T> struct TIteratorElementType<T*> { using Type = TRemoveCV<T>; };
template <typename I> struct TIteratorPointerType { using Type = void; }; template <typename I> struct TIteratorPointerType { using Type = void; };
@ -58,6 +58,7 @@ concept CIndirectlyReadable =
{ *Iter } -> CSameAs<TIteratorReferenceType<I>>; { *Iter } -> CSameAs<TIteratorReferenceType<I>>;
{ MoveTemp(*Iter) } -> CSameAs<TIteratorRValueReferenceType<I>>; { MoveTemp(*Iter) } -> CSameAs<TIteratorRValueReferenceType<I>>;
} }
&& CSameAs<TIteratorElementType<I>, TRemoveCVRef<TIteratorElementType<I>>>
&& CCommonReference<TIteratorReferenceType<I>&&, TIteratorElementType<I>&> && CCommonReference<TIteratorReferenceType<I>&&, TIteratorElementType<I>&>
&& CCommonReference<TIteratorReferenceType<I>&&, TIteratorRValueReferenceType<I>&&> && CCommonReference<TIteratorReferenceType<I>&&, TIteratorRValueReferenceType<I>&&>
&& CCommonReference<TIteratorRValueReferenceType<I>&&, const TIteratorElementType<I>&>; && CCommonReference<TIteratorRValueReferenceType<I>&&, const TIteratorElementType<I>&>;
@ -124,10 +125,9 @@ concept CRandomAccessIterator = CBidirectionalIterator<I> && CTotallyOrdered<I>
template <typename I> template <typename I>
concept CContiguousIterator = CRandomAccessIterator<I> && CLValueReference<TIteratorReferenceType<I>> concept CContiguousIterator = CRandomAccessIterator<I> && CLValueReference<TIteratorReferenceType<I>>
&& CSameAs<TIteratorElementType<I>, TRemoveReference<TIteratorReferenceType<I>>> && CSameAs<TIteratorElementType<I>, TRemoveCVRef<TIteratorReferenceType<I>>>
&& requires(I& Iter) && requires(I& Iter)
{ {
static_cast<TObserverPtr<TIteratorElementType<I>[]>>(Iter);
{ AddressOf(*Iter) } -> CSameAs<TAddPointer<TIteratorReferenceType<I>>>; { AddressOf(*Iter) } -> CSameAs<TAddPointer<TIteratorReferenceType<I>>>;
}; };

View File

@ -24,8 +24,8 @@ private:
struct FNode; struct FNode;
template <bool bConst> template <bool bConst, typename = TConditional<bConst, const T, T>>
class IteratorImpl; class TIteratorImpl;
public: public:
@ -35,8 +35,8 @@ public:
using Reference = T&; using Reference = T&;
using ConstReference = const T&; using ConstReference = const T&;
using Iterator = IteratorImpl<false>; using Iterator = TIteratorImpl<false>;
using ConstIterator = IteratorImpl<true >; using ConstIterator = TIteratorImpl<true >;
using ReverseIterator = TReverseIterator< Iterator>; using ReverseIterator = TReverseIterator< Iterator>;
using ConstReverseIterator = TReverseIterator<ConstIterator>; using ConstReverseIterator = TReverseIterator<ConstIterator>;
@ -553,44 +553,44 @@ private:
} }
ALLOCATOR_WRAPPER_END(AllocatorType, FNode, Impl) ALLOCATOR_WRAPPER_END(AllocatorType, FNode, Impl)
template <bool bConst> template <bool bConst, typename U>
class IteratorImpl class TIteratorImpl
{ {
public: public:
using ElementType = TConditional<bConst, const T, T>; using ElementType = TRemoveCV<T>;
FORCEINLINE IteratorImpl() = default; FORCEINLINE TIteratorImpl() = default;
FORCEINLINE IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Pointer(InValue.Pointer) : Pointer(InValue.Pointer)
{ } { }
FORCEINLINE IteratorImpl(const IteratorImpl&) = default; FORCEINLINE TIteratorImpl(const TIteratorImpl&) = default;
FORCEINLINE IteratorImpl(IteratorImpl&&) = default; FORCEINLINE TIteratorImpl(TIteratorImpl&&) = default;
FORCEINLINE IteratorImpl& operator=(const IteratorImpl&) = default; FORCEINLINE TIteratorImpl& operator=(const TIteratorImpl&) = default;
FORCEINLINE IteratorImpl& operator=(IteratorImpl&&) = default; FORCEINLINE TIteratorImpl& operator=(TIteratorImpl&&) = default;
NODISCARD friend FORCEINLINE bool operator==(const IteratorImpl& LHS, const IteratorImpl& RHS) { return LHS.Pointer == RHS.Pointer; } NODISCARD friend FORCEINLINE bool operator==(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { return LHS.Pointer == RHS.Pointer; }
NODISCARD FORCEINLINE ElementType& operator*() const { return Pointer->Value; } NODISCARD FORCEINLINE U& operator*() const { return Pointer->Value; }
NODISCARD FORCEINLINE ElementType* operator->() const { return &Pointer->Value; } NODISCARD FORCEINLINE U* operator->() const { return &Pointer->Value; }
FORCEINLINE IteratorImpl& operator++() { Pointer = Pointer->NextNode; return *this; } FORCEINLINE TIteratorImpl& operator++() { Pointer = Pointer->NextNode; return *this; }
FORCEINLINE IteratorImpl& operator--() { Pointer = Pointer->PrevNode; return *this; } FORCEINLINE TIteratorImpl& operator--() { Pointer = Pointer->PrevNode; return *this; }
FORCEINLINE IteratorImpl operator++(int) { IteratorImpl Temp = *this; ++*this; return Temp; } FORCEINLINE TIteratorImpl operator++(int) { TIteratorImpl Temp = *this; ++*this; return Temp; }
FORCEINLINE IteratorImpl operator--(int) { IteratorImpl Temp = *this; --*this; return Temp; } FORCEINLINE TIteratorImpl operator--(int) { TIteratorImpl Temp = *this; --*this; return Temp; }
private: private:
FNode* Pointer = nullptr; FNode* Pointer = nullptr;
FORCEINLINE IteratorImpl(FNode* InPointer) FORCEINLINE TIteratorImpl(FNode* InPointer)
: Pointer(InPointer) : Pointer(InPointer)
{ } { }
template <bool> friend class IteratorImpl; template <bool, typename> friend class TIteratorImpl;
friend TList; friend TList;

View File

@ -21,8 +21,8 @@ struct TStaticArray final
{ {
private: private:
template <bool bConst> template <bool bConst, typename = TConditional<bConst, const T, T>>
class IteratorImpl; class TIteratorImpl;
public: public:
@ -31,8 +31,8 @@ public:
using Reference = T&; using Reference = T&;
using ConstReference = const T&; using ConstReference = const T&;
using Iterator = IteratorImpl<false>; using Iterator = TIteratorImpl<false>;
using ConstIterator = IteratorImpl<true >; using ConstIterator = TIteratorImpl<true >;
using ReverseIterator = TReverseIterator< Iterator>; using ReverseIterator = TReverseIterator< Iterator>;
using ConstReverseIterator = TReverseIterator<ConstIterator>; using ConstReverseIterator = TReverseIterator<ConstIterator>;
@ -123,56 +123,56 @@ public:
private: private:
template <bool bConst> template <bool bConst, typename U>
class IteratorImpl class TIteratorImpl
{ {
public: public:
using ElementType = TConditional<bConst, const T, T>; using ElementType = TRemoveCV<T>;
FORCEINLINE constexpr IteratorImpl() = default; FORCEINLINE constexpr TIteratorImpl() = default;
# if DO_CHECK # if DO_CHECK
FORCEINLINE IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Owner(InValue.Owner), Pointer(InValue.Pointer) : Owner(InValue.Owner), Pointer(InValue.Pointer)
{ } { }
# else # else
FORCEINLINE IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Pointer(InValue.Pointer) : Pointer(InValue.Pointer)
{ } { }
# endif # endif
FORCEINLINE constexpr IteratorImpl(const IteratorImpl&) = default; FORCEINLINE constexpr TIteratorImpl(const TIteratorImpl&) = default;
FORCEINLINE constexpr IteratorImpl(IteratorImpl&&) = default; FORCEINLINE constexpr TIteratorImpl(TIteratorImpl&&) = default;
FORCEINLINE constexpr IteratorImpl& operator=(const IteratorImpl&) = default; FORCEINLINE constexpr TIteratorImpl& operator=(const TIteratorImpl&) = default;
FORCEINLINE constexpr IteratorImpl& operator=(IteratorImpl&&) = default; FORCEINLINE constexpr TIteratorImpl& operator=(TIteratorImpl&&) = default;
NODISCARD friend FORCEINLINE constexpr bool operator==(const IteratorImpl& LHS, const IteratorImpl& RHS) { return LHS.Pointer == RHS.Pointer; } NODISCARD friend FORCEINLINE constexpr bool operator==(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { return LHS.Pointer == RHS.Pointer; }
NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const IteratorImpl& LHS, const IteratorImpl& RHS) { return LHS.Pointer <=> RHS.Pointer; } NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { return LHS.Pointer <=> RHS.Pointer; }
NODISCARD FORCEINLINE constexpr ElementType& operator*() const { CheckThis(true); return *Pointer; } NODISCARD FORCEINLINE constexpr U& operator*() const { CheckThis(true); return *Pointer; }
NODISCARD FORCEINLINE constexpr ElementType* operator->() const { CheckThis(true); return Pointer; } NODISCARD FORCEINLINE constexpr U* operator->() const { CheckThis(true); return Pointer; }
NODISCARD FORCEINLINE constexpr ElementType& operator[](ptrdiff Index) const { IteratorImpl Temp = *this + Index; return *Temp; } NODISCARD FORCEINLINE constexpr U& operator[](ptrdiff Index) const { TIteratorImpl Temp = *this + Index; return *Temp; }
FORCEINLINE constexpr IteratorImpl& operator++() { ++Pointer; CheckThis(); return *this; } FORCEINLINE constexpr TIteratorImpl& operator++() { ++Pointer; CheckThis(); return *this; }
FORCEINLINE constexpr IteratorImpl& operator--() { --Pointer; CheckThis(); return *this; } FORCEINLINE constexpr TIteratorImpl& operator--() { --Pointer; CheckThis(); return *this; }
FORCEINLINE constexpr IteratorImpl operator++(int) { IteratorImpl Temp = *this; ++*this; return Temp; } FORCEINLINE constexpr TIteratorImpl operator++(int) { TIteratorImpl Temp = *this; ++*this; return Temp; }
FORCEINLINE constexpr IteratorImpl operator--(int) { IteratorImpl Temp = *this; --*this; return Temp; } FORCEINLINE constexpr TIteratorImpl operator--(int) { TIteratorImpl Temp = *this; --*this; return Temp; }
FORCEINLINE constexpr IteratorImpl& operator+=(ptrdiff Offset) { Pointer += Offset; CheckThis(); return *this; } FORCEINLINE constexpr TIteratorImpl& operator+=(ptrdiff Offset) { Pointer += Offset; CheckThis(); return *this; }
FORCEINLINE constexpr IteratorImpl& operator-=(ptrdiff Offset) { Pointer -= Offset; CheckThis(); return *this; } FORCEINLINE constexpr TIteratorImpl& operator-=(ptrdiff Offset) { Pointer -= Offset; CheckThis(); return *this; }
NODISCARD friend FORCEINLINE constexpr IteratorImpl operator+(IteratorImpl Iter, ptrdiff Offset) { IteratorImpl Temp = Iter; Temp += Offset; return Temp; } NODISCARD friend FORCEINLINE constexpr TIteratorImpl operator+(TIteratorImpl Iter, ptrdiff Offset) { TIteratorImpl Temp = Iter; Temp += Offset; return Temp; }
NODISCARD friend FORCEINLINE constexpr IteratorImpl operator+(ptrdiff Offset, IteratorImpl Iter) { IteratorImpl Temp = Iter; Temp += Offset; return Temp; } NODISCARD friend FORCEINLINE constexpr TIteratorImpl operator+(ptrdiff Offset, TIteratorImpl Iter) { TIteratorImpl Temp = Iter; Temp += Offset; return Temp; }
NODISCARD FORCEINLINE constexpr IteratorImpl operator-(ptrdiff Offset) const { IteratorImpl Temp = *this; Temp -= Offset; return Temp; } NODISCARD FORCEINLINE constexpr TIteratorImpl operator-(ptrdiff Offset) const { TIteratorImpl Temp = *this; Temp -= Offset; return Temp; }
NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const IteratorImpl& LHS, const IteratorImpl& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Pointer - RHS.Pointer; } NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Pointer - RHS.Pointer; }
NODISCARD FORCEINLINE constexpr explicit operator TObserverPtr<ElementType[]>() const { CheckThis(); return TObserverPtr<ElementType[]>(Pointer); } NODISCARD FORCEINLINE constexpr explicit operator TObserverPtr<U[]>() const { CheckThis(); return TObserverPtr<U[]>(Pointer); }
private: private:
@ -180,14 +180,14 @@ private:
const TStaticArray* Owner = nullptr; const TStaticArray* Owner = nullptr;
# endif # endif
ElementType* Pointer = nullptr; U* Pointer = nullptr;
# if DO_CHECK # if DO_CHECK
FORCEINLINE constexpr IteratorImpl(const TStaticArray* InContainer, ElementType* InPointer) FORCEINLINE constexpr TIteratorImpl(const TStaticArray* InContainer, U* InPointer)
: Owner(InContainer), Pointer(InPointer) : Owner(InContainer), Pointer(InPointer)
{ } { }
# else # else
FORCEINLINE constexpr IteratorImpl(const TStaticArray* InContainer, ElementType* InPointer) FORCEINLINE constexpr TIteratorImpl(const TStaticArray* InContainer, U* InPointer)
: Pointer(InPointer) : Pointer(InPointer)
{ } { }
# endif # endif
@ -198,7 +198,7 @@ private:
checkf(!(bExceptEnd && Owner->End() == *this), TEXT("Read access violation. Please check IsValidIterator().")); checkf(!(bExceptEnd && Owner->End() == *this), TEXT("Read access violation. Please check IsValidIterator()."));
} }
template <bool> friend class IteratorImpl; template <bool, typename> friend class TIteratorImpl;
friend TStaticArray; friend TStaticArray;

View File

@ -33,7 +33,7 @@ class TStaticBitset final
private: private:
template <bool bConst> template <bool bConst>
class IteratorImpl; class TIteratorImpl;
public: public:
@ -43,8 +43,8 @@ public:
class Reference; class Reference;
using ConstReference = bool; using ConstReference = bool;
using Iterator = IteratorImpl<false>; using Iterator = TIteratorImpl<false>;
using ConstIterator = IteratorImpl<true >; using ConstIterator = TIteratorImpl<true >;
using ReverseIterator = TReverseIterator< Iterator>; using ReverseIterator = TReverseIterator< Iterator>;
using ConstReverseIterator = TReverseIterator<ConstIterator>; using ConstReverseIterator = TReverseIterator<ConstIterator>;
@ -115,7 +115,7 @@ public:
/** Move assignment operator. After the move, 'InValue' is guaranteed to be empty. */ /** Move assignment operator. After the move, 'InValue' is guaranteed to be empty. */
FORCEINLINE constexpr TStaticBitset& operator=(TStaticBitset&&) = default; FORCEINLINE constexpr TStaticBitset& operator=(TStaticBitset&&) = default;
/** Compares the bits of two bitsets. */ /** Compares the bits of two bitsets. */
NODISCARD friend constexpr bool operator==(const TStaticBitset& LHS, const TStaticBitset& RHS) NODISCARD friend constexpr bool operator==(const TStaticBitset& LHS, const TStaticBitset& RHS)
{ {
@ -399,7 +399,7 @@ public:
uint64 Result = 0; uint64 Result = 0;
static_assert(sizeof(BlockType) <= sizeof(uint64), "The block width of TStaticBitset is unexpected"); static_assert(sizeof(BlockType) <= sizeof(uint64), "The block width of TStaticBitset is unexpected");
if constexpr (sizeof(BlockType) == sizeof(uint8)) if constexpr (sizeof(BlockType) == sizeof(uint8))
{ {
if constexpr (N > 0) Result |= static_cast<uint64>(Impl[0]) << 0; if constexpr (N > 0) Result |= static_cast<uint64>(Impl[0]) << 0;
@ -506,7 +506,7 @@ public:
FORCEINLINE constexpr Reference& operator=(bool InValue) { Data = (Data & ~Mask) | (InValue ? Mask : 0); return *this; } FORCEINLINE constexpr Reference& operator=(bool InValue) { Data = (Data & ~Mask) | (InValue ? Mask : 0); return *this; }
FORCEINLINE constexpr Reference& operator=(const Reference& InValue) { return *this = static_cast<bool>(InValue); } FORCEINLINE constexpr Reference& operator=(const Reference& InValue) { *this = static_cast<bool>(InValue); return *this; }
FORCEINLINE constexpr Reference& operator&=(bool InValue) { Data &= InValue ? -1 : ~Mask; return *this; } FORCEINLINE constexpr Reference& operator&=(bool InValue) { Data &= InValue ? -1 : ~Mask; return *this; }
FORCEINLINE constexpr Reference& operator|=(bool InValue) { Data |= InValue ? Mask : 0; return *this; } FORCEINLINE constexpr Reference& operator|=(bool InValue) { Data |= InValue ? Mask : 0; return *this; }
@ -532,55 +532,55 @@ public:
private: private:
template <bool bConst> template <bool bConst>
class IteratorImpl class TIteratorImpl
{ {
private: private:
public: public:
using ElementType = TConditional<bConst, const bool, bool>; using ElementType = bool;
FORCEINLINE constexpr IteratorImpl() = default; FORCEINLINE constexpr TIteratorImpl() = default;
# if DO_CHECK # if DO_CHECK
FORCEINLINE constexpr IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE constexpr TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Owner(InValue.Owner), Pointer(InValue.Pointer), Offset(InValue.Offset) : Owner(InValue.Owner), Pointer(InValue.Pointer), BitOffset(InValue.BitOffset)
{ } { }
# else # else
FORCEINLINE constexpr IteratorImpl(const IteratorImpl<false>& InValue) requires (bConst) FORCEINLINE constexpr TIteratorImpl(const TIteratorImpl<false>& InValue) requires (bConst)
: Pointer(InValue.Pointer), Offset(InValue.Offset) : Pointer(InValue.Pointer), BitOffset(InValue.BitOffset)
{ } { }
# endif # endif
FORCEINLINE constexpr IteratorImpl(const IteratorImpl&) = default; FORCEINLINE constexpr TIteratorImpl(const TIteratorImpl&) = default;
FORCEINLINE constexpr IteratorImpl(IteratorImpl&&) = default; FORCEINLINE constexpr TIteratorImpl(TIteratorImpl&&) = default;
FORCEINLINE constexpr IteratorImpl& operator=(const IteratorImpl&) = default; FORCEINLINE constexpr TIteratorImpl& operator=(const TIteratorImpl&) = default;
FORCEINLINE constexpr IteratorImpl& operator=(IteratorImpl&&) = default; FORCEINLINE constexpr TIteratorImpl& operator=(TIteratorImpl&&) = default;
NODISCARD friend FORCEINLINE constexpr bool operator==(const IteratorImpl& LHS, const IteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.Offset == RHS.Offset; } NODISCARD friend FORCEINLINE constexpr bool operator==(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.BitOffset == RHS.BitOffset; }
NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const IteratorImpl& LHS, const IteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.Offset <=> RHS.Offset; } NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.BitOffset <=> RHS.BitOffset; }
NODISCARD FORCEINLINE constexpr Reference operator*() const requires (!bConst) { CheckThis(true); return Reference(*(Pointer + Offset / BlockWidth), 1ull << Offset % BlockWidth); } NODISCARD FORCEINLINE constexpr Reference operator*() const requires (!bConst) { CheckThis(true); return Reference(*(Pointer + BitOffset / BlockWidth), 1ull << BitOffset % BlockWidth); }
NODISCARD FORCEINLINE constexpr ConstReference operator*() const requires ( bConst) { CheckThis(true); return (*(Pointer + Offset / BlockWidth) & (1ull << Offset % BlockWidth)); } NODISCARD FORCEINLINE constexpr ConstReference operator*() const requires ( bConst) { CheckThis(true); return (*(Pointer + BitOffset / BlockWidth) & (1ull << BitOffset % BlockWidth)); }
NODISCARD FORCEINLINE constexpr auto operator[](ptrdiff Index) const { IteratorImpl Temp = *this + Index; return *Temp; } NODISCARD FORCEINLINE constexpr auto operator[](ptrdiff Index) const { TIteratorImpl Temp = *this + Index; return *Temp; }
FORCEINLINE constexpr IteratorImpl& operator++() { ++Offset; CheckThis(); return *this; } FORCEINLINE constexpr TIteratorImpl& operator++() { ++BitOffset; CheckThis(); return *this; }
FORCEINLINE constexpr IteratorImpl& operator--() { --Offset; CheckThis(); return *this; } FORCEINLINE constexpr TIteratorImpl& operator--() { --BitOffset; CheckThis(); return *this; }
FORCEINLINE constexpr IteratorImpl operator++(int) { IteratorImpl Temp = *this; ++*this; return Temp; } FORCEINLINE constexpr TIteratorImpl operator++(int) { TIteratorImpl Temp = *this; ++*this; return Temp; }
FORCEINLINE constexpr IteratorImpl operator--(int) { IteratorImpl Temp = *this; --*this; return Temp; } FORCEINLINE constexpr TIteratorImpl operator--(int) { TIteratorImpl Temp = *this; --*this; return Temp; }
FORCEINLINE constexpr IteratorImpl& operator+=(ptrdiff Offset) { this->Offset += Offset; CheckThis(); return *this; } FORCEINLINE constexpr TIteratorImpl& operator+=(ptrdiff Offset) { BitOffset += Offset; CheckThis(); return *this; }
FORCEINLINE constexpr IteratorImpl& operator-=(ptrdiff Offset) { this->Offset -= Offset; CheckThis(); return *this; } FORCEINLINE constexpr TIteratorImpl& operator-=(ptrdiff Offset) { BitOffset -= Offset; CheckThis(); return *this; }
NODISCARD friend FORCEINLINE constexpr IteratorImpl operator+(IteratorImpl Iter, ptrdiff Offset) { IteratorImpl Temp = Iter; Temp += Offset; return Temp; } NODISCARD friend FORCEINLINE constexpr TIteratorImpl operator+(TIteratorImpl Iter, ptrdiff Offset) { TIteratorImpl Temp = Iter; Temp += Offset; return Temp; }
NODISCARD friend FORCEINLINE constexpr IteratorImpl operator+(ptrdiff Offset, IteratorImpl Iter) { IteratorImpl Temp = Iter; Temp += Offset; return Temp; } NODISCARD friend FORCEINLINE constexpr TIteratorImpl operator+(ptrdiff Offset, TIteratorImpl Iter) { TIteratorImpl Temp = Iter; Temp += Offset; return Temp; }
NODISCARD FORCEINLINE constexpr IteratorImpl operator-(ptrdiff Offset) const { IteratorImpl Temp = *this; Temp -= Offset; return Temp; } NODISCARD FORCEINLINE constexpr TIteratorImpl operator-(ptrdiff Offset) const { TIteratorImpl Temp = *this; Temp -= Offset; return Temp; }
NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const IteratorImpl& LHS, const IteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.Offset - RHS.Offset; } NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.BitOffset - RHS.BitOffset; }
private: private:
@ -590,16 +590,16 @@ private:
using BlockPtr = TConditional<bConst, const BlockType*, BlockType*>; using BlockPtr = TConditional<bConst, const BlockType*, BlockType*>;
BlockPtr Pointer = nullptr; BlockPtr Pointer = nullptr;
size_t Offset = 0; size_t BitOffset = 0;
# if DO_CHECK # if DO_CHECK
FORCEINLINE constexpr IteratorImpl(const TStaticBitset* InContainer, BlockPtr InPointer, size_t InOffset) FORCEINLINE constexpr TIteratorImpl(const TStaticBitset* InContainer, BlockPtr InPointer, size_t Offset)
: Owner(InContainer), Pointer(InPointer), Offset(InOffset) : Owner(InContainer), Pointer(InPointer), BitOffset(Offset)
{ } { }
# else # else
FORCEINLINE constexpr IteratorImpl(const TStaticBitset* InContainer, BlockPtr InPointer, size_t InOffset) FORCEINLINE constexpr TIteratorImpl(const TStaticBitset* InContainer, BlockPtr InPointer, size_t Offset)
: Pointer(InPointer), Offset(InOffset) : Pointer(InPointer), BitOffset(Offset)
{ } { }
# endif # endif
@ -609,7 +609,7 @@ private:
checkf(!(bExceptEnd && Owner->End() == *this), TEXT("Read access violation. Please check IsValidIterator().")); checkf(!(bExceptEnd && Owner->End() == *this), TEXT("Read access violation. Please check IsValidIterator()."));
} }
template <bool> friend class IteratorImpl; template <bool> friend class TIteratorImpl;
friend TStaticBitset; friend TStaticBitset;

View File

@ -16,7 +16,7 @@ class TConstantIterator final
{ {
public: public:
using ElementType = T; using ElementType = TRemoveCV<T>;
FORCEINLINE constexpr TConstantIterator() = default; FORCEINLINE constexpr TConstantIterator() = default;
@ -68,7 +68,7 @@ class TConstantIterator<T&> final
{ {
public: public:
using ElementType = T; using ElementType = TRemoveCV<T>;
FORCEINLINE constexpr TConstantIterator() = default; FORCEINLINE constexpr TConstantIterator() = default;

View File

@ -1048,16 +1048,13 @@ private:
}; };
template<typename T>
TString(size_t, T) -> TString<T>;
template<typename T> template<typename T>
TString(const T*) -> TString<T>; TString(const T*) -> TString<T>;
template<typename T> template<typename T>
TString(TStringView<T>) -> TString<T>; TString(TStringView<T>) -> TString<T>;
template<typename I, typename S> template<CForwardIterator I, typename S>
TString(I, S) -> TString<TIteratorElementType<I>>; TString(I, S) -> TString<TIteratorElementType<I>>;
template <typename T> template <typename T>