From a55f03fea0acd5cd6dfcc797e3fcc9c6f60de8d3 Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Sat, 14 Dec 2024 16:09:35 +0800 Subject: [PATCH] fix(iterator): fix behavior when TIteratorElement or TIteratorPointer is invalid --- Redcraft.Utility/Source/Public/Iterator/Utility.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Iterator/Utility.h b/Redcraft.Utility/Source/Public/Iterator/Utility.h index 9c579ad..3a949bd 100644 --- a/Redcraft.Utility/Source/Public/Iterator/Utility.h +++ b/Redcraft.Utility/Source/Public/Iterator/Utility.h @@ -12,11 +12,14 @@ NAMESPACE_PRIVATE_BEGIN template using TWithReference = T&; -template struct TIteratorElementImpl { using Type = typename I::ElementType; }; -template struct TIteratorElementImpl { using Type = TRemoveCV; }; +template struct TIteratorElementImpl { }; +template struct TIteratorElementImpl { using Type = TRemoveCV; }; -template struct TIteratorPointerImpl { using Type = void; }; -template struct TIteratorPointerImpl { using Type = T*; }; +template requires (requires { typename I::ElementType; }) +struct TIteratorElementImpl { using Type = typename I::ElementType; }; + +template struct TIteratorPointerImpl { }; +template struct TIteratorPointerImpl { using Type = T*; }; template requires (requires(I& Iter) { { Iter.operator->() } -> CPointer; }) struct TIteratorPointerImpl { using Type = decltype(DeclVal().operator->()); };