diff --git a/Redcraft.Utility/Source/Public/Containers/Iterator.h b/Redcraft.Utility/Source/Public/Containers/Iterator.h index 5ecd7f4..fca801c 100644 --- a/Redcraft.Utility/Source/Public/Containers/Iterator.h +++ b/Redcraft.Utility/Source/Public/Containers/Iterator.h @@ -149,12 +149,18 @@ public: FORCEINLINE constexpr explicit TReverseIterator(IteratorType InValue) : Current(InValue) { } - template requires (!CSameAs && CConvertibleTo) - FORCEINLINE constexpr TReverseIterator(const TReverseIterator& InValue) : Current(InValue.GetBase()) { } + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TReverseIterator(const TReverseIterator& InValue) : Current(InValue.GetBase()) { } + + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TReverseIterator(TReverseIterator&& InValue) : Current(MoveTemp(InValue).GetBase()) { } template requires (!CSameAs && CConvertibleTo && CAssignableFrom) FORCEINLINE constexpr TReverseIterator& operator=(const TReverseIterator& InValue) { Current = InValue.GetBase(); return *this; } + template requires (!CSameAs && CConvertibleTo && CAssignableFrom) + FORCEINLINE constexpr TReverseIterator& operator=(TReverseIterator&& InValue) { Current = MoveTemp(InValue).GetBase(); return *this; } + template requires (CSentinelFor) NODISCARD friend FORCEINLINE constexpr bool operator==(const TReverseIterator& LHS, const TReverseIterator& RHS) { return LHS.GetBase() == RHS.GetBase(); } @@ -218,12 +224,18 @@ public: FORCEINLINE constexpr explicit TMoveIterator(IteratorType InValue) : Current(InValue) { } - template requires (!CSameAs && CConvertibleTo) - FORCEINLINE constexpr TMoveIterator(const TMoveIterator& InValue) : Current(InValue.GetBase()) { } + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TMoveIterator(const TMoveIterator& InValue) : Current(InValue.GetBase()) { } + + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TMoveIterator(TMoveIterator&& InValue) : Current(MoveTemp(InValue).GetBase()) { } template requires (!CSameAs && CConvertibleTo && CAssignableFrom) FORCEINLINE constexpr TMoveIterator& operator=(const TMoveIterator& InValue) { Current = InValue.GetBase(); return *this; } + template requires (!CSameAs && CConvertibleTo && CAssignableFrom) + FORCEINLINE constexpr TMoveIterator& operator=(TMoveIterator&& InValue) { Current = MoveTemp(InValue).GetBase(); return *this; } + template requires (CSentinelFor) NODISCARD friend FORCEINLINE constexpr bool operator==(const TMoveIterator& LHS, const TMoveIterator& RHS) { return LHS.GetBase() == RHS.GetBase(); } @@ -283,12 +295,18 @@ public: FORCEINLINE constexpr explicit TMoveSentinel(SentinelType InValue) : Last(InValue) { } - template requires (!CSameAs && CConvertibleTo) - FORCEINLINE constexpr TMoveSentinel(const TMoveSentinel& InValue) : Last(InValue.GetBase()) { } + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TMoveSentinel(const TMoveSentinel& InValue) : Last(InValue.GetBase()) { } + + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TMoveSentinel(TMoveSentinel&& InValue) : Last(MoveTemp(InValue).GetBase()) { } template requires (!CSameAs && CConvertibleTo && CAssignableFrom) FORCEINLINE constexpr TMoveSentinel& operator=(const TMoveSentinel& InValue) { Last = InValue.GetBase(); return *this; } + template requires (!CSameAs && CConvertibleTo && CAssignableFrom) + FORCEINLINE constexpr TMoveSentinel& operator=(TMoveSentinel&& InValue) { Last = MoveTemp(InValue).GetBase(); return *this; } + template requires (CSentinelFor) NODISCARD FORCEINLINE constexpr bool operator==(const TMoveIterator& InValue) const& { return GetBase() == InValue.GetBase(); } @@ -352,11 +370,17 @@ public: FORCEINLINE constexpr explicit TCountedIterator(IteratorType InValue, ptrdiff N) : Current(InValue), Length(N) { check_code({ MaxLength = N; }); } - template requires (!CSameAs && CConvertibleTo) - FORCEINLINE constexpr TCountedIterator(const TCountedIterator& InValue) : Current(InValue.GetBase()), Length(InValue.Num()) { check_code({ MaxLength = InValue.Max(); }); } + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TCountedIterator(const TCountedIterator& InValue) : Current(InValue.GetBase()), Length(InValue.Num()) { check_code({ MaxLength = InValue.MaxLength; }); } + + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TCountedIterator(TCountedIterator&& InValue) : Current(MoveTemp(InValue).GetBase()), Length(InValue.Num()) { check_code({ MaxLength = InValue.MaxLength; }); } template requires (!CSameAs && CConvertibleTo && CAssignableFrom) - FORCEINLINE constexpr TCountedIterator& operator=(const TCountedIterator& InValue) { Current = InValue.GetBase(); Length = InValue.Num(); check_code({ MaxLength = InValue.Max(); }); return *this; } + FORCEINLINE constexpr TCountedIterator& operator=(const TCountedIterator& InValue) { Current = InValue.GetBase(); Length = InValue.Num(); check_code({ MaxLength = InValue.MaxLength; }); return *this; } + + template requires (!CSameAs && CConvertibleTo && CAssignableFrom) + FORCEINLINE constexpr TCountedIterator& operator=(TCountedIterator&& InValue) { Current = MoveTemp(InValue).GetBase(); Length = InValue.Num(); check_code({ MaxLength = InValue.MaxLength; }); return *this; } template requires (CSentinelFor) NODISCARD friend FORCEINLINE constexpr bool operator==(const TCountedIterator& LHS, const TCountedIterator& RHS) { return LHS.GetBase() == RHS.GetBase(); }