From 8113d3b39bd38e277a6db3a2e7b0e4b3eb69e31a Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Sun, 8 Dec 2024 20:40:52 +0800 Subject: [PATCH] feat(miscellaneous): add IndirectlySwap family functions for iterators --- .../Source/Public/Miscellaneous/Iterator.h | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Iterator.h b/Redcraft.Utility/Source/Public/Miscellaneous/Iterator.h index f43c5a7..b750b46 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Iterator.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Iterator.h @@ -192,6 +192,40 @@ FORCEINLINE constexpr I Prev(I Iter, TMakeUnsigned N = 1) NAMESPACE_END(Iteration) +template > I> +FORCEINLINE void IndirectlyCopy(I&& Iter, J&& Jter) +{ + *Iter = *Jter; +} + +template > I> +FORCEINLINE void IndirectlyMove(I&& Iter, J&& Jter) +{ + *Iter = MoveTemp(*Jter); +} + +template requires (CSwappable, TIteratorReferenceType>) +FORCEINLINE void IndirectlySwap(I&& Iter, J&& Jter) +{ + Swap(*Iter, *Jter); +} + +template +concept CIndirectlyCopyable = requires(const I Iter, const J Jter) { IndirectlyCopy(Iter, Jter); }; + +template +concept CIndirectlyMovable = requires(const I Iter, const J Jter) { IndirectlyMove(Iter, Jter); }; + +template +concept CIndirectlySwappable = CIndirectlyReadable && CIndirectlyReadable + && requires(const I Iter, const J Jter) + { + IndirectlySwap(Iter, Iter); + IndirectlySwap(Jter, Jter); + IndirectlySwap(Iter, Jter); + IndirectlySwap(Jter, Iter); + }; + /** A iterator adaptor for reverse-order traversal. */ template class TReverseIterator final