refactor(miscellaneous): fix iterator concepts and helper function return value types
This commit is contained in:
parent
7525c9a5dd
commit
8d02b0e0a9
@ -92,8 +92,13 @@ template <typename S, typename I>
|
|||||||
inline constexpr bool bDisableSizedSentinelFor = false;
|
inline constexpr bool bDisableSizedSentinelFor = false;
|
||||||
|
|
||||||
template <typename S, typename I>
|
template <typename S, typename I>
|
||||||
concept CSizedSentinelFor = CSentinelFor<S, I> && CPartiallyOrdered<S, I> && !bDisableSizedSentinelFor<TRemoveCV<S>, TRemoveCV<I>>
|
concept CSizedSentinelFor = CSentinelFor<S, I> && CPartiallyOrdered<S, I>
|
||||||
&& requires(const I& Iter, const S& Sentinel) { Sentinel - Iter; Iter - Sentinel; };
|
&& !bDisableSizedSentinelFor<TRemoveCV<S>, TRemoveCV<I>>
|
||||||
|
&& requires(const I& Iter, const S& Sentinel)
|
||||||
|
{
|
||||||
|
{ Sentinel - Iter } -> CSameAs<ptrdiff>;
|
||||||
|
{ Iter - Sentinel } -> CSameAs<ptrdiff>;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename I>
|
template <typename I>
|
||||||
concept CInputIterator = CInputOrOutputIterator<I> && CIndirectlyReadable<I>;
|
concept CInputIterator = CInputOrOutputIterator<I> && CIndirectlyReadable<I>;
|
||||||
@ -409,7 +414,7 @@ public:
|
|||||||
FORCEINLINE constexpr TCountedIterator& operator++() { ++Current; --Length; CheckThis(); return *this; }
|
FORCEINLINE constexpr TCountedIterator& operator++() { ++Current; --Length; CheckThis(); return *this; }
|
||||||
FORCEINLINE constexpr TCountedIterator& operator--() requires (CBidirectionalIterator<IteratorType>) { --Current; ++Length; CheckThis(); return *this; }
|
FORCEINLINE constexpr TCountedIterator& operator--() requires (CBidirectionalIterator<IteratorType>) { --Current; ++Length; CheckThis(); return *this; }
|
||||||
|
|
||||||
FORCEINLINE constexpr decltype(auto) operator++(int) { --Length; CheckThis(); return Current++; }
|
FORCEINLINE constexpr auto operator++(int) { --Length; CheckThis(); return Current++; }
|
||||||
FORCEINLINE constexpr TCountedIterator operator++(int) requires (CForwardIterator<IteratorType>) { TCountedIterator Temp = *this; ++Current; --Length; CheckThis(); return Temp; }
|
FORCEINLINE constexpr TCountedIterator operator++(int) requires (CForwardIterator<IteratorType>) { TCountedIterator Temp = *this; ++Current; --Length; CheckThis(); return Temp; }
|
||||||
FORCEINLINE constexpr TCountedIterator operator--(int) requires (CBidirectionalIterator<IteratorType>) { TCountedIterator Temp = *this; --Current; ++Length; CheckThis(); return Temp; }
|
FORCEINLINE constexpr TCountedIterator operator--(int) requires (CBidirectionalIterator<IteratorType>) { TCountedIterator Temp = *this; --Current; ++Length; CheckThis(); return Temp; }
|
||||||
|
|
||||||
@ -674,7 +679,7 @@ FORCEINLINE constexpr I Prev(I Iter, TMakeUnsigned<ptrdiff> N = 1)
|
|||||||
|
|
||||||
/** @return The iterator to the beginning of a container. */
|
/** @return The iterator to the beginning of a container. */
|
||||||
template <typename T> requires (requires(T&& Container) { { Container.Begin() } -> CForwardIterator; })
|
template <typename T> requires (requires(T&& Container) { { Container.Begin() } -> CForwardIterator; })
|
||||||
FORCEINLINE constexpr decltype(auto) Begin(T&& Container)
|
FORCEINLINE constexpr auto Begin(T&& Container)
|
||||||
{
|
{
|
||||||
return Container.Begin();
|
return Container.Begin();
|
||||||
}
|
}
|
||||||
@ -687,14 +692,14 @@ template <typename T, size_t N> FORCEINLINE constexpr const T* Begin(const T(&&
|
|||||||
|
|
||||||
/** Overloads the Begin algorithm for initializer_list. */
|
/** Overloads the Begin algorithm for initializer_list. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FORCEINLINE constexpr decltype(auto) Begin(initializer_list<T> Container)
|
FORCEINLINE constexpr auto Begin(initializer_list<T> Container)
|
||||||
{
|
{
|
||||||
return Container.begin();
|
return Container.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return The iterator to the end of a container. */
|
/** @return The iterator to the end of a container. */
|
||||||
template <typename T> requires (requires(T&& Container) { { Container.End() } -> CForwardIterator; })
|
template <typename T> requires (requires(T&& Container) { { Container.End() } -> CForwardIterator; })
|
||||||
FORCEINLINE constexpr decltype(auto) End(T&& Container)
|
FORCEINLINE constexpr auto End(T&& Container)
|
||||||
{
|
{
|
||||||
return Container.End();
|
return Container.End();
|
||||||
}
|
}
|
||||||
@ -707,47 +712,47 @@ template <typename T, size_t N> FORCEINLINE constexpr const T* End(const T(&& Co
|
|||||||
|
|
||||||
/** Overloads the End algorithm for initializer_list. */
|
/** Overloads the End algorithm for initializer_list. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FORCEINLINE constexpr decltype(auto) End(initializer_list<T> Container)
|
FORCEINLINE constexpr auto End(initializer_list<T> Container)
|
||||||
{
|
{
|
||||||
return Container.end();
|
return Container.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return The reverse iterator to the beginning of a container. */
|
/** @return The reverse iterator to the beginning of a container. */
|
||||||
template <typename T> requires (requires(T&& Container) { { Container.RBegin() } -> CForwardIterator; })
|
template <typename T> requires (requires(T&& Container) { { Container.RBegin() } -> CForwardIterator; })
|
||||||
FORCEINLINE constexpr decltype(auto) RBegin(T&& Container)
|
FORCEINLINE constexpr auto RBegin(T&& Container)
|
||||||
{
|
{
|
||||||
return Container.RBegin();
|
return Container.RBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Overloads the RBegin algorithm for arrays. */
|
/** Overloads the RBegin algorithm for arrays. */
|
||||||
template <typename T, size_t N> FORCEINLINE constexpr decltype(auto) RBegin( T(& Container)[N]) { return TReverseIterator(End(Container)); }
|
template <typename T, size_t N> FORCEINLINE constexpr auto RBegin( T(& Container)[N]) { return TReverseIterator(End(Container)); }
|
||||||
template <typename T, size_t N> FORCEINLINE constexpr decltype(auto) RBegin( T(&& Container)[N]) { return TReverseIterator(End(Container)); }
|
template <typename T, size_t N> FORCEINLINE constexpr auto RBegin( T(&& Container)[N]) { return TReverseIterator(End(Container)); }
|
||||||
template <typename T, size_t N> FORCEINLINE constexpr decltype(auto) RBegin(const T(& Container)[N]) { return TReverseIterator(End(Container)); }
|
template <typename T, size_t N> FORCEINLINE constexpr auto RBegin(const T(& Container)[N]) { return TReverseIterator(End(Container)); }
|
||||||
template <typename T, size_t N> FORCEINLINE constexpr decltype(auto) RBegin(const T(&& Container)[N]) { return TReverseIterator(End(Container)); }
|
template <typename T, size_t N> FORCEINLINE constexpr auto RBegin(const T(&& Container)[N]) { return TReverseIterator(End(Container)); }
|
||||||
|
|
||||||
/** Overloads the RBegin algorithm for initializer_list. */
|
/** Overloads the RBegin algorithm for initializer_list. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FORCEINLINE constexpr decltype(auto) RBegin(initializer_list<T> Container)
|
FORCEINLINE constexpr auto RBegin(initializer_list<T> Container)
|
||||||
{
|
{
|
||||||
return TReverseIterator(Container.end());
|
return TReverseIterator(Container.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return The reverse iterator to the end of a container. */
|
/** @return The reverse iterator to the end of a container. */
|
||||||
template <typename T> requires (requires(T&& Container) { { Container.REnd() } -> CForwardIterator; })
|
template <typename T> requires (requires(T&& Container) { { Container.REnd() } -> CForwardIterator; })
|
||||||
FORCEINLINE constexpr decltype(auto) REnd(T&& Container)
|
FORCEINLINE constexpr auto REnd(T&& Container)
|
||||||
{
|
{
|
||||||
return Container.REnd();
|
return Container.REnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Overloads the REnd algorithm for arrays. */
|
/** Overloads the REnd algorithm for arrays. */
|
||||||
template <typename T, size_t N> FORCEINLINE constexpr decltype(auto) REnd( T(& Container)[N]) { return TReverseIterator(Begin(Container)); }
|
template <typename T, size_t N> FORCEINLINE constexpr auto REnd( T(& Container)[N]) { return TReverseIterator(Begin(Container)); }
|
||||||
template <typename T, size_t N> FORCEINLINE constexpr decltype(auto) REnd( T(&& Container)[N]) { return TReverseIterator(Begin(Container)); }
|
template <typename T, size_t N> FORCEINLINE constexpr auto REnd( T(&& Container)[N]) { return TReverseIterator(Begin(Container)); }
|
||||||
template <typename T, size_t N> FORCEINLINE constexpr decltype(auto) REnd(const T(& Container)[N]) { return TReverseIterator(Begin(Container)); }
|
template <typename T, size_t N> FORCEINLINE constexpr auto REnd(const T(& Container)[N]) { return TReverseIterator(Begin(Container)); }
|
||||||
template <typename T, size_t N> FORCEINLINE constexpr decltype(auto) REnd(const T(&& Container)[N]) { return TReverseIterator(Begin(Container)); }
|
template <typename T, size_t N> FORCEINLINE constexpr auto REnd(const T(&& Container)[N]) { return TReverseIterator(Begin(Container)); }
|
||||||
|
|
||||||
/** Overloads the REnd algorithm for initializer_list. */
|
/** Overloads the REnd algorithm for initializer_list. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FORCEINLINE constexpr decltype(auto) REnd(initializer_list<T> Container)
|
FORCEINLINE constexpr auto REnd(initializer_list<T> Container)
|
||||||
{
|
{
|
||||||
return TReverseIterator(Container.begin());
|
return TReverseIterator(Container.begin());
|
||||||
}
|
}
|
||||||
@ -755,10 +760,10 @@ FORCEINLINE constexpr decltype(auto) REnd(initializer_list<T> Container)
|
|||||||
NAMESPACE_END(Iteration)
|
NAMESPACE_END(Iteration)
|
||||||
|
|
||||||
#define ENABLE_RANGE_BASED_FOR_LOOP_SUPPORT public: \
|
#define ENABLE_RANGE_BASED_FOR_LOOP_SUPPORT public: \
|
||||||
NODISCARD FORCEINLINE constexpr decltype(auto) begin() { return Begin(); } \
|
NODISCARD FORCEINLINE constexpr auto begin() { return Begin(); } \
|
||||||
NODISCARD FORCEINLINE constexpr decltype(auto) begin() const { return Begin(); } \
|
NODISCARD FORCEINLINE constexpr auto begin() const { return Begin(); } \
|
||||||
NODISCARD FORCEINLINE constexpr decltype(auto) end() { return End(); } \
|
NODISCARD FORCEINLINE constexpr auto end() { return End(); } \
|
||||||
NODISCARD FORCEINLINE constexpr decltype(auto) end() const { return End(); }
|
NODISCARD FORCEINLINE constexpr auto end() const { return End(); }
|
||||||
|
|
||||||
NAMESPACE_MODULE_END(Utility)
|
NAMESPACE_MODULE_END(Utility)
|
||||||
NAMESPACE_MODULE_END(Redcraft)
|
NAMESPACE_MODULE_END(Redcraft)
|
||||||
|
Loading…
Reference in New Issue
Block a user