diff --git a/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h b/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h index 6760681..e467639 100644 --- a/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h @@ -67,12 +67,12 @@ public: } template requires (CCommonType) - NODISCARD friend FORCEINLINE constexpr bool operator==(const TCountedIterator& LHS, const TCountedIterator& RHS) { return LHS.Length == RHS.Length; } + NODISCARD friend FORCEINLINE constexpr bool operator==(const TCountedIterator& LHS, const TCountedIterator& RHS) { return LHS.Num() == RHS.Num(); } template requires (CCommonType) - NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const TCountedIterator& LHS, const TCountedIterator& RHS) { return LHS.Length <=> RHS.Length; } + NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const TCountedIterator& LHS, const TCountedIterator& RHS) { return LHS.Num() <=> RHS.Num(); } - NODISCARD FORCEINLINE constexpr bool operator==(FDefaultSentinel) const& { return Length == static_cast(0); } + NODISCARD FORCEINLINE constexpr bool operator==(FDefaultSentinel) const& { return Num() == static_cast(0); } NODISCARD FORCEINLINE constexpr TIteratorReference operator*() { CheckThis(true); return *GetBase(); } NODISCARD FORCEINLINE constexpr TIteratorReference operator*() const requires (CDereferenceable) { CheckThis(true); return *GetBase(); } @@ -97,7 +97,7 @@ public: NODISCARD friend FORCEINLINE constexpr TCountedIterator operator+(ptrdiff Offset, TCountedIterator Iter) requires (CRandomAccessIterator) { return Iter + Offset; } template requires (CCommonType) - NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TCountedIterator& LHS, const TCountedIterator& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Length - RHS.Length; } + NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TCountedIterator& LHS, const TCountedIterator& RHS) { return RHS.Num() - LHS.Num(); } NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TCountedIterator& LHS, FDefaultSentinel) { LHS.CheckThis(); return -LHS.Num(); } NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(FDefaultSentinel, const TCountedIterator& RHS) { RHS.CheckThis(); return RHS.Num(); } @@ -121,9 +121,6 @@ private: checkf(!(bExceptEnd && Length == static_cast(0)), TEXT("Read access violation. Please check Num().")); } - template - friend class TCountedIterator; - }; static_assert( CInputIterator>>); diff --git a/Redcraft.Utility/Source/Public/Iterator/InsertIterator.h b/Redcraft.Utility/Source/Public/Iterator/InsertIterator.h index 12c8657..3c2f0cd 100644 --- a/Redcraft.Utility/Source/Public/Iterator/InsertIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/InsertIterator.h @@ -1,10 +1,12 @@ #pragma once #include "CoreTypes.h" -#include "Iterator/Utility.h" #include "TypeTraits/TypeTraits.h" -#include "Templates/Noncopyable.h" +#include "Iterator/Utility.h" #include "Templates/Utility.h" +#include "Templates/Noncopyable.h" +#include "Templates/Invoke.h" +#include "Miscellaneous/AssertionMacros.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) @@ -142,7 +144,7 @@ NODISCARD FORCEINLINE constexpr auto MakeBackInserter(C& Container) template NODISCARD FORCEINLINE constexpr auto MakeInserter(C& Container, const typename C::FConstIterator& InIter) { - return NAMESPACE_PRIVATE::TInsertIterator([&Container, Iter = InIter](T&& A) mutable { Iter = Container.Insert(Iter, Forward(A)); }); + return NAMESPACE_PRIVATE::TInsertIterator([&Container, Iter = InIter](T&& A) mutable { Iter = Container.Insert(Iter, Forward(A)); ++Iter; }); } NAMESPACE_MODULE_END(Utility)