14#include "CoreMinimal.h"
23#ifndef MCRO_RANGE_ALLOW_BASIC_ITERATOR_FEATURE_EMULATION
32#define MCRO_RANGE_ALLOW_BASIC_ITERATOR_FEATURE_EMULATION 1
44 template <CIsIteratorStep<EIteratorStep::Single> T>
47#if MCRO_RANGE_ALLOW_BASIC_ITERATOR_FEATURE_EMULATION
48 T& operator () (T& iterator,
size_t steps)
const
50 ensureAlwaysMsgf(
false,
TEXT_
51 "Given iterator %s can only be incremented in single steps, and therefore can only be incremented in"
55 for (
size_t i=0; i<steps; ++i)
62 template <CIsIteratorStep<EIteratorStep::Jump> T>
65 T& operator () (T& iterator,
size_t steps)
const
67 return iterator += steps;
65 T& operator () (T& iterator,
size_t steps)
const {
…}
77 template <CIteratorFeature<EIteratorDirection::B
idirectional, EIteratorStep::Single> T>
80#if MCRO_RANGE_ALLOW_BASIC_ITERATOR_FEATURE_EMULATION
81 T& operator () (T& iterator,
size_t steps)
const
83 ensureAlwaysMsgf(
false,
TEXT_
84 "Given iterator %s can only be decremented in single steps, and therefore can only be decremented in"
88 for (
size_t i=0; i<steps; ++i)
95 template <CIteratorFeature<EIteratorDirection::B
idirectional, EIteratorStep::Jump> T>
98 T& operator () (T& iterator,
size_t steps)
const
100 return iterator -= steps;
98 T& operator () (T& iterator,
size_t steps)
const {
…}
104 template <
typename T>
107 template <
typename T>
113 template <CBasicForwardIterator T>
140 template <
typename T>
143 template <
typename T>
146 template <CBasicForwardIterator T>
147 requires CTotallyOrdered<T>
150 auto operator () (T
const& l, T
const& r)
const
150 auto operator () (T
const& l, T
const& r)
const {
…}
156 template <CBasicForwardIterator T>
157 requires CHasElementIndex<T>
160 auto operator () (T
const& l, T
const& r)
const
162 return l.ElementIndex <=> r.ElementIndex;
160 auto operator () (T
const& l, T
const& r)
const {
…}
166 template <CBasicForwardIterator T>
167 requires CHasGetIndex<T>
170 auto operator () (T
const& l, T
const& r)
const
172 return l.GetIndex() <=> r.GetIndex();
170 auto operator () (T
const& l, T
const& r)
const {
…}
176 template <
typename T>
179 template <
typename T>
182 template <CBasicForwardIterator T>
185#if MCRO_RANGE_ALLOW_BASIC_ITERATOR_FEATURE_EMULATION
186 int64 operator () (T
const& l, T
const& r)
const
188 ensureAlwaysMsgf(
false,
TEXT_
189 "Given iterator %s doesn't expose public state about its logical position within the range. Computing"
190 " the distance between two may take O(N) time, where N is the singular steps between the two actual"
195 ensureAlwaysMsgf(CTotallyOrdered<T>,
TEXT_
196 "Given iterator %s wasn't relationally comparable. It is assumed that the right iterator is bigger than"
197 " the left one. The program may freeze otherwise!",
203 if constexpr (CTotallyOrdered<T>)
if (l > r)
213 ensureAlwaysMsgf(i < 1000000,
TEXT_
214 "Computing distance between two minimal iterators %s took longer than a million steps."
215 " Maybe use a different container type which can provide iterator distance in O(1) time, or heed"
216 " the above warnings and make sure the right iterator is bigger than the left one.",
225 template <CStdDistanceCompatible T>
228 auto operator () (T
const& l, T
const& r)
const
230 return std::distance(l, r);
228 auto operator () (T
const& l, T
const& r)
const {
…}
234 template <CHasElementIndex T>
237 auto operator () (T
const& l, T
const& r)
const
239 return r.ElementIndex - l.ElementIndex;
237 auto operator () (T
const& l, T
const& r)
const {
…}
243 template <CHasGetIndex T>
246 auto operator () (T
const& l, T
const& r)
const
248 return r.GetIndex() - l.GetIndex();
246 auto operator () (T
const& l, T
const& r)
const {
…}
252 template <
typename T>
280 , std::conditional_t<CConstType<Iterator>, FVoid, std::output_iterator_tag>
290 template <CConvertibleToDecayed<Iterator> InputIterator>
294 : BaseIterator(other.BaseIterator) {}
297 : BaseIterator(MoveTemp(other.BaseIterator)) {}
319 template <CBasicB
idirectionalIterator = Iterator>
326 template <CBasicB
idirectionalIterator = Iterator>
334 template <CHasMemberAccessOperator = Iterator>
337 template <CHasMemberAccessOperator = Iterator>
342 if constexpr (Policy.DereferencePointerToPointer)
343 return *
static_cast<value_type*
>(*BaseIterator);
344 return *BaseIterator;
349 if constexpr (Policy.DereferencePointerToPointer)
350 return *
static_cast<const value_type*
>(*BaseIterator);
351 return *BaseIterator;
366 template <CBasicB
idirectionalIterator = Iterator>
372 template <CBasicB
idirectionalIterator = Iterator>
395 template <CIteratorComparable = Iterator>
402 Iterator BaseIterator;
422 : String(other.String)
423 , Current(other.Current)
427 : String(MoveTemp(other.String))
428 , Current(other.Current)
435 auto operator * () -> TCHAR
const&;
436 auto operator * () const -> TCHAR const&;
445 return l.Current <=> r.Current;
450 const TCHAR* Current;
This header exists because STL headers in Android doesn't define STL concepts (other than same_as whi...
auto end(TArray< T, A > &r) -> T *
Use leading TEXT_ without parenthesis for Unreal compatible text literals.
#define TEXT_
A convenience alternative to Unreal's own TEXT macro but this one doesn't require parenthesis around ...
These two are the most useful types in the arsenal of the C++ developer. Use these for dummy types or...
typename TIteratorDifference_Struct< T >::Type TIteratorDifference
return a difference type for given iterator.
std::decay_t< decltype(*DeclVal< T >())> TIteratorElementType
return the iterator's associated content type when they're dereferenced.
bool IteratorEquals(L const &l, R const &r)
constexpr TIteratorCompare_Struct< T > TIteratorCompare
constexpr TIteratorJumpForward_Struct< T > TIteratorJumpForward
constexpr TIteratorJumpBackward_Struct< T > TIteratorJumpBackward
std::conditional_t< CRandomAccessIterator< T >, std::random_access_iterator_tag, std::conditional_t< CBasicBidirectionalIterator< T >, std::bidirectional_iterator_tag, std::conditional_t< CBasicForwardIterator< T >, std::forward_iterator_tag, std::input_iterator_tag > > > TIteratorCategory
Assume an STL iterator category from input iterator.
constexpr TIteratorComputeDistance_Struct< T > TIteratorComputeDistance
Utilities for TSharedPtr/Ref and related.
TSharedPtr< TSharedStorage< T > > TSharedStoragePtr
constexpr FStringView TTypeName
Get a friendly string of an input type without using typeid(T).name().
Extra settings for TExtendedIterator wrapper.
bool DereferencePointerToPointer
This is originally meant for TIndirectArray where the given operator is extremely minimal but it stil...
Allows range-v3 and std::ranges to iterate over temporary string objects and keep the string alive du...
std::ptrdiff_t difference_type
FTempStringIterator(FTempStringIterator &&other) noexcept
FTempStringIterator(FString &&string, bool end)
FTempStringIterator(FTempStringIterator const &other)
std::random_access_iterator_tag iterator_category
Unreal's own iterators are not STL compliant (they are only compatible with range-for loops) so they ...
auto operator*() -> value_type const &
auto operator+(int steps) const -> TExtendedIterator
TIteratorDifference< Iterator > difference_type
friend auto operator<=>(TExtendedIterator const &l, TExtendedIterator const &r)
auto operator+=(int steps) -> TExtendedIterator &
TExtendedIterator(TExtendedIterator const &other)
auto operator++() -> TExtendedIterator &
auto operator--() -> TExtendedIterator &
friend auto operator-(TExtendedIterator const &l, TExtendedIterator const &r) -> difference_type
auto operator-=(int steps) -> TExtendedIterator &
friend bool operator!=(TExtendedIterator const &l, TExtendedIterator const &r)
TIteratorElementType< Iterator > value_type
auto operator=(TExtendedIterator other) -> TExtendedIterator &
TIteratorCategory< Iterator > iterator_category
friend bool operator==(TExtendedIterator const &l, TExtendedIterator const &r)
TExtendedIterator(InputIterator &&input)
TExtendedIterator(TExtendedIterator &&other) noexcept