Compare commits
No commits in common. "85199119b393a22223e6254e2ead71d5fc9279c9" and "f54386d1021a919094b767d2d2c3c3a4db247109" have entirely different histories.
85199119b3
...
f54386d102
@ -1,18 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Range/Range.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Factory.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
@ -49,7 +45,7 @@ public:
|
||||
FORCEINLINE TArray() : TArray(0) { }
|
||||
|
||||
/** Constructs the container with 'Count' default instances of T. */
|
||||
explicit TArray(size_t Count) requires (CDefaultConstructible<T>)
|
||||
explicit TArray(size_t Count) requires (CDefaultConstructible<FElementType>)
|
||||
{
|
||||
Impl.ArrayNum = Count;
|
||||
Impl.ArrayMax = Impl->CalculateSlackReserve(Num());
|
||||
@ -59,13 +55,13 @@ public:
|
||||
}
|
||||
|
||||
/** Constructs the container with 'Count' copies of elements with 'InValue'. */
|
||||
FORCEINLINE explicit TArray(size_t Count, const FElementType& InValue) requires (CCopyConstructible<T>)
|
||||
TArray(size_t Count, const FElementType& InValue) requires (CCopyConstructible<FElementType>)
|
||||
: TArray(Range::Repeat(InValue, Count))
|
||||
{ }
|
||||
|
||||
/** Constructs the container with the contents of the range ['First', 'Last'). */
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<T, TIteratorReference<I>> && CMovable<T>)
|
||||
explicit TArray(I First, S Last)
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<FElementType, TIteratorReference<I>> && CMovable<FElementType>)
|
||||
TArray(I First, S Last)
|
||||
{
|
||||
if constexpr (CForwardIterator<I>)
|
||||
{
|
||||
@ -103,11 +99,11 @@ public:
|
||||
}
|
||||
|
||||
/** Constructs the container with the contents of the range. */
|
||||
template <CInputRange R> requires (!CSameAs<TRemoveCVRef<R>, TArray> && CConstructibleFrom<T, TRangeReference<R>> && CMovable<T>)
|
||||
template <CInputRange R> requires (!CSameAs<TRemoveCVRef<R>, TArray> && CConstructibleFrom<FElementType, TRangeReference<R>> && CMovable<FElementType>)
|
||||
FORCEINLINE explicit TArray(R&& Range) : TArray(Range::Begin(Range), Range::End(Range)) { }
|
||||
|
||||
/** Copy constructor. Constructs the container with the copy of the contents of 'InValue'. */
|
||||
TArray(const TArray& InValue) requires (CCopyConstructible<T>)
|
||||
TArray(const TArray& InValue) requires (CCopyConstructible<FElementType>)
|
||||
{
|
||||
Impl.ArrayNum = InValue.Num();
|
||||
Impl.ArrayMax = Impl->CalculateSlackReserve(Num());
|
||||
@ -117,7 +113,7 @@ public:
|
||||
}
|
||||
|
||||
/** Move constructor. After the move, 'InValue' is guaranteed to be empty. */
|
||||
TArray(TArray&& InValue) requires (CMoveConstructible<T>)
|
||||
TArray(TArray&& InValue) requires (CMoveConstructible<FElementType>)
|
||||
{
|
||||
Impl.ArrayNum = InValue.Num();
|
||||
|
||||
@ -142,7 +138,7 @@ public:
|
||||
}
|
||||
|
||||
/** Constructs the container with the contents of the initializer list. */
|
||||
FORCEINLINE TArray(initializer_list<FElementType> IL) requires (CCopyConstructible<T>) : TArray(Range::Begin(IL), Range::End(IL)) { }
|
||||
FORCEINLINE TArray(initializer_list<FElementType> IL) requires (CCopyConstructible<FElementType>) : TArray(Range::Begin(IL), Range::End(IL)) { }
|
||||
|
||||
/** Destructs the array. The destructors of the elements are called and the used storage is deallocated. */
|
||||
~TArray()
|
||||
@ -152,7 +148,7 @@ public:
|
||||
}
|
||||
|
||||
/** Copy assignment operator. Replaces the contents with a copy of the contents of 'InValue'. */
|
||||
TArray& operator=(const TArray& InValue) requires (CCopyable<T>)
|
||||
TArray& operator=(const TArray& InValue) requires (CCopyable<FElementType>)
|
||||
{
|
||||
if (&InValue == this) UNLIKELY return *this;
|
||||
|
||||
@ -193,7 +189,7 @@ public:
|
||||
}
|
||||
|
||||
/** Move assignment operator. After the move, 'InValue' is guaranteed to be empty. */
|
||||
TArray& operator=(TArray&& InValue) requires (CMovable<T>)
|
||||
TArray& operator=(TArray&& InValue) requires (CMovable<FElementType>)
|
||||
{
|
||||
if (&InValue == this) UNLIKELY return *this;
|
||||
|
||||
@ -254,7 +250,7 @@ public:
|
||||
}
|
||||
|
||||
/** Replaces the contents with those identified by initializer list. */
|
||||
TArray& operator=(initializer_list<FElementType> IL) requires (CCopyable<T>)
|
||||
TArray& operator=(initializer_list<FElementType> IL) requires (CCopyable<FElementType>)
|
||||
{
|
||||
size_t NumToAllocate = Range::Num(IL);
|
||||
|
||||
@ -293,7 +289,7 @@ public:
|
||||
}
|
||||
|
||||
/** Compares the contents of two arrays. */
|
||||
NODISCARD friend bool operator==(const TArray& LHS, const TArray& RHS) requires (CWeaklyEqualityComparable<T>)
|
||||
NODISCARD friend bool operator==(const TArray& LHS, const TArray& RHS) requires (CWeaklyEqualityComparable<FElementType>)
|
||||
{
|
||||
if (LHS.Num() != RHS.Num()) return false;
|
||||
|
||||
@ -306,7 +302,7 @@ public:
|
||||
}
|
||||
|
||||
/** Compares the contents of 'LHS' and 'RHS' lexicographically. */
|
||||
NODISCARD friend auto operator<=>(const TArray& LHS, const TArray& RHS) requires (CSynthThreeWayComparable<T>)
|
||||
NODISCARD friend auto operator<=>(const TArray& LHS, const TArray& RHS) requires (CSynthThreeWayComparable<FElementType>)
|
||||
{
|
||||
const size_t NumToCompare = LHS.Num() < RHS.Num() ? LHS.Num() : RHS.Num();
|
||||
|
||||
@ -319,7 +315,7 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts 'InValue' before 'Iter' in the container. */
|
||||
FIterator Insert(FConstIterator Iter, const FElementType& InValue) requires (CCopyable<T>)
|
||||
FIterator Insert(FConstIterator Iter, const FElementType& InValue) requires (CCopyable<FElementType>)
|
||||
{
|
||||
checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -367,7 +363,7 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts 'InValue' before 'Iter' in the container. */
|
||||
FIterator Insert(FConstIterator Iter, FElementType&& InValue) requires (CMovable<T>)
|
||||
FIterator Insert(FConstIterator Iter, FElementType&& InValue) requires (CMovable<FElementType>)
|
||||
{
|
||||
checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -415,7 +411,7 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts 'Count' copies of the 'InValue' before 'Iter' in the container. */
|
||||
FIterator Insert(FConstIterator Iter, size_t Count, const FElementType& InValue) requires (CCopyable<T>)
|
||||
FIterator Insert(FConstIterator Iter, size_t Count, const FElementType& InValue) requires (CCopyable<FElementType>)
|
||||
{
|
||||
checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -423,7 +419,8 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts elements from range ['First', 'Last') before 'Iter'. */
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<T, TIteratorReference<I>> && CAssignableFrom<T&, TIteratorReference<I>> && CMovable<T>)
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<FElementType, TIteratorReference<I>>
|
||||
&& CAssignableFrom<FElementType&, TIteratorReference<I>> && CMovable<FElementType>)
|
||||
FIterator Insert(FConstIterator Iter, I First, S Last)
|
||||
{
|
||||
checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
@ -543,20 +540,21 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts elements from range before 'Iter'. */
|
||||
template <CInputRange R> requires (CConstructibleFrom<T, TRangeReference<R>> && CAssignableFrom<T&, TRangeReference<R>> && CMovable<T>)
|
||||
template <CInputRange R> requires (CConstructibleFrom<FElementType, TRangeReference<R>>
|
||||
&& CAssignableFrom<FElementType&, TRangeReference<R>> && CMovable<FElementType>)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, R&& Range)
|
||||
{
|
||||
return Insert(Iter, Range::Begin(Range), Range::End(Range));
|
||||
}
|
||||
|
||||
/** Inserts elements from initializer list before 'Iter' in the container. */
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list<FElementType> IL) requires (CCopyable<T>)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list<FElementType> IL) requires (CCopyable<FElementType>)
|
||||
{
|
||||
return Insert(Iter, Range::Begin(IL), Range::End(IL));
|
||||
}
|
||||
|
||||
/** Inserts a new element into the container directly before 'Iter'. */
|
||||
template <typename... Ts> requires (CConstructibleFrom<T, Ts...> && CMovable<T>)
|
||||
template <typename... Ts> requires (CConstructibleFrom<FElementType, Ts...> && CMovable<FElementType>)
|
||||
FIterator Emplace(FConstIterator Iter, Ts&&... Args)
|
||||
{
|
||||
checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
@ -605,7 +603,7 @@ public:
|
||||
}
|
||||
|
||||
/** Removes the element at 'Iter' in the container. Without changing the order of elements. */
|
||||
FORCEINLINE FIterator StableErase(FConstIterator Iter, bool bAllowShrinking = true) requires (CMovable<T>)
|
||||
FORCEINLINE FIterator StableErase(FConstIterator Iter, bool bAllowShrinking = true) requires (CMovable<FElementType>)
|
||||
{
|
||||
checkf(IsValidIterator(Iter) && Iter != End(), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -613,7 +611,7 @@ public:
|
||||
}
|
||||
|
||||
/** Removes the elements in the range ['First', 'Last') in the container. Without changing the order of elements. */
|
||||
FIterator StableErase(FConstIterator First, FConstIterator Last, bool bAllowShrinking = true) requires (CMovable<T>)
|
||||
FIterator StableErase(FConstIterator First, FConstIterator Last, bool bAllowShrinking = true) requires (CMovable<FElementType>)
|
||||
{
|
||||
checkf(IsValidIterator(First) && IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -655,7 +653,7 @@ public:
|
||||
}
|
||||
|
||||
/** Removes the element at 'Iter' in the container. But it may change the order of elements. */
|
||||
FORCEINLINE FIterator Erase(FConstIterator Iter, bool bAllowShrinking = true) requires (CMovable<T>)
|
||||
FORCEINLINE FIterator Erase(FConstIterator Iter, bool bAllowShrinking = true) requires (CMovable<FElementType>)
|
||||
{
|
||||
checkf(IsValidIterator(Iter) && Iter != End(), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -663,7 +661,7 @@ public:
|
||||
}
|
||||
|
||||
/** Removes the elements in the range ['First', 'Last') in the container. But it may change the order of elements. */
|
||||
FIterator Erase(FConstIterator First, FConstIterator Last, bool bAllowShrinking = true) requires (CMovable<T>)
|
||||
FIterator Erase(FConstIterator First, FConstIterator Last, bool bAllowShrinking = true) requires (CMovable<FElementType>)
|
||||
{
|
||||
checkf(IsValidIterator(First) && IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -707,19 +705,19 @@ public:
|
||||
}
|
||||
|
||||
/** Appends the given element value to the end of the container. */
|
||||
FORCEINLINE void PushBack(const FElementType& InValue) requires (CCopyable<T>)
|
||||
FORCEINLINE void PushBack(const FElementType& InValue) requires (CCopyable<FElementType>)
|
||||
{
|
||||
EmplaceBack(InValue);
|
||||
}
|
||||
|
||||
/** Appends the given element value to the end of the container. */
|
||||
FORCEINLINE void PushBack(FElementType&& InValue) requires (CMovable<T>)
|
||||
FORCEINLINE void PushBack(FElementType&& InValue) requires (CMovable<FElementType>)
|
||||
{
|
||||
EmplaceBack(MoveTemp(InValue));
|
||||
}
|
||||
|
||||
/** Appends a new element to the end of the container. */
|
||||
template <typename... Ts> requires (CConstructibleFrom<T, Ts...> && CMovable<T>)
|
||||
template <typename... Ts> requires (CConstructibleFrom<FElementType, Ts...> && CMovable<FElementType>)
|
||||
FElementType& EmplaceBack(Ts&&... Args)
|
||||
{
|
||||
const size_t NumToAllocate = Num() + 1 > Max() ? Impl->CalculateSlackGrow(Num() + 1, Max()) : Max();
|
||||
@ -752,13 +750,13 @@ public:
|
||||
}
|
||||
|
||||
/** Removes the last element of the container. The array cannot be empty. */
|
||||
FORCEINLINE void PopBack(bool bAllowShrinking = true) requires (CMovable<T>)
|
||||
FORCEINLINE void PopBack(bool bAllowShrinking = true) requires (CMovable<FElementType>)
|
||||
{
|
||||
Erase(End() - 1, bAllowShrinking);
|
||||
}
|
||||
|
||||
/** Resizes the container to contain 'Count' elements. Additional default elements are appended. */
|
||||
void SetNum(size_t Count, bool bAllowShrinking = true) requires (CDefaultConstructible<T> && CMovable<T>)
|
||||
void SetNum(size_t Count, bool bAllowShrinking = true) requires (CDefaultConstructible<FElementType> && CMovable<FElementType>)
|
||||
{
|
||||
size_t NumToAllocate = Count;
|
||||
|
||||
@ -804,7 +802,7 @@ public:
|
||||
}
|
||||
|
||||
/** Resizes the container to contain 'Count' elements. Additional copies of 'InValue' are appended. */
|
||||
void SetNum(size_t Count, const FElementType& InValue, bool bAllowShrinking = true) requires (CCopyConstructible<T> && CMovable<T>)
|
||||
void SetNum(size_t Count, const FElementType& InValue, bool bAllowShrinking = true) requires (CCopyConstructible<FElementType> && CMovable<FElementType>)
|
||||
{
|
||||
size_t NumToAllocate = Count;
|
||||
|
||||
@ -857,7 +855,7 @@ public:
|
||||
}
|
||||
|
||||
/** Increase the max capacity of the array to a value that's greater or equal to 'Count'. */
|
||||
void Reserve(size_t Count) requires (CMovable<T>)
|
||||
void Reserve(size_t Count) requires (CMovable<FElementType>)
|
||||
{
|
||||
if (Count <= Max()) return;
|
||||
|
||||
@ -955,7 +953,7 @@ public:
|
||||
}
|
||||
|
||||
/** Overloads the GetTypeHash algorithm for TArray. */
|
||||
NODISCARD friend FORCEINLINE size_t GetTypeHash(const TArray& A) requires (CHashable<T>)
|
||||
NODISCARD friend FORCEINLINE size_t GetTypeHash(const TArray& A) requires (CHashable<FElementType>)
|
||||
{
|
||||
size_t Result = 0;
|
||||
|
||||
@ -968,7 +966,7 @@ public:
|
||||
}
|
||||
|
||||
/** Overloads the Swap algorithm for TArray. */
|
||||
friend void Swap(TArray& A, TArray& B) requires (CMovable<T>)
|
||||
friend void Swap(TArray& A, TArray& B) requires (CMovable<FElementType>)
|
||||
{
|
||||
const bool bIsTransferable =
|
||||
A.Impl->IsTransferable(A.Impl.Pointer) &&
|
||||
@ -1007,7 +1005,7 @@ private:
|
||||
{
|
||||
public:
|
||||
|
||||
using FElementType = T;
|
||||
using FElementType = TRemoveCV<T>;
|
||||
|
||||
FORCEINLINE TIteratorImpl() = default;
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Range/Range.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "Containers/StaticArray.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Range/Range.h"
|
||||
#include "Memory/Memory.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Templates/Noncopyable.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
@ -21,7 +20,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
||||
template <CUnsignedIntegral InBlockType> requires (!CSameAs<InBlockType, bool>)
|
||||
using TDefaultBitsetAllocator = TInlineAllocator<(40 - 3 * sizeof(size_t)) / sizeof(InBlockType)>;
|
||||
|
||||
template <CUnsignedIntegral InBlockType, CAllocator<InBlockType> Allocator = TDefaultBitsetAllocator<InBlockType>> requires (CAllocatableObject<InBlockType> && !CSameAs<InBlockType, bool>)
|
||||
template <CUnsignedIntegral InBlockType, CAllocator<InBlockType> Allocator = TDefaultBitsetAllocator<InBlockType>> requires (!CSameAs<InBlockType, bool>)
|
||||
class TBitset
|
||||
{
|
||||
private:
|
||||
|
@ -1,18 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Range/Range.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Factory.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
|
@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Range/Range.h"
|
||||
#include "Templates/Meta.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
@ -16,7 +15,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
/** TStaticArray is a container that encapsulates fixed size arrays. */
|
||||
template <CObject T, size_t N> requires (!CConst<T> && !CVolatile<T>)
|
||||
template <CObject T, size_t N>
|
||||
struct TStaticArray
|
||||
{
|
||||
private:
|
||||
|
@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Range/Range.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Templates/Noncopyable.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
@ -25,7 +25,9 @@ using TDefaultBitsetBlockType =
|
||||
|
||||
NAMESPACE_PRIVATE_END
|
||||
|
||||
template <size_t N, CUnsignedIntegral InBlockType = NAMESPACE_PRIVATE::TDefaultBitsetBlockType<N>> requires (!CConst<InBlockType> && !CVolatile<InBlockType> && !CSameAs<InBlockType, bool>)
|
||||
#if 1
|
||||
|
||||
template <size_t N, CUnsignedIntegral InBlockType = NAMESPACE_PRIVATE::TDefaultBitsetBlockType<N>> requires (!CSameAs<InBlockType, bool>)
|
||||
class TStaticBitset
|
||||
{
|
||||
private:
|
||||
@ -615,6 +617,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
||||
|
@ -1,250 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wnon-template-friend"
|
||||
#endif
|
||||
|
||||
/** A concept specifies a type is an input iterator. It is input iterator, incrementable, and sentinel for itself. */
|
||||
template <typename I>
|
||||
concept CForwardIterator = CInputIterator<I> && CIncrementable<I> && CSentinelFor<I, I>;
|
||||
|
||||
/** This is an example of a forward iterator, indicate the traits that define a forward iterator. */
|
||||
template <CReferenceable T>
|
||||
struct IForwardIterator /* : IInputIterator<T>, IIncrementable, ISentinelFor<IForwardIterator> */
|
||||
{
|
||||
// ~Begin CInputIterator.
|
||||
|
||||
using FElementType = TRemoveCVRef<T>;
|
||||
|
||||
// ~End CInputIterator.
|
||||
|
||||
// ~Begin CIncrementable and CSentinelFor<IForwardIterator>.
|
||||
|
||||
IForwardIterator();
|
||||
IForwardIterator(const IForwardIterator&);
|
||||
IForwardIterator(IForwardIterator&&); // Also satisfies IInputIterator.
|
||||
IForwardIterator* operator=(const IForwardIterator&);
|
||||
IForwardIterator* operator=(IForwardIterator&&); // Also satisfies IInputIterator.
|
||||
|
||||
friend bool operator==(const IForwardIterator&, const IForwardIterator&);
|
||||
|
||||
// ~End CIncrementable and CSentinelFor<IForwardIterator>.
|
||||
|
||||
// ~Begin CInputIterator.
|
||||
|
||||
T operator*() const; // Optional satisfies CIndirectlyWritable.
|
||||
|
||||
IForwardIterator& operator++(); // Also satisfies CIncrementable.
|
||||
|
||||
IForwardIterator operator++(int); // Also satisfies CIncrementable.
|
||||
|
||||
// ~End CInputIterator.
|
||||
};
|
||||
|
||||
// Use IForwardIterator<int> represents a forward iterator.
|
||||
static_assert(CForwardIterator<IForwardIterator<int&>>);
|
||||
static_assert( COutputIterator<IForwardIterator<int&>, int>);
|
||||
|
||||
/** A concept specifies a type is a bidirectional iterator. Add the decrement operator to the forward iterator. */
|
||||
template <typename I>
|
||||
concept CBidirectionalIterator = CForwardIterator<I>
|
||||
&& requires(I Iter) {
|
||||
{ --Iter } -> CSameAs<I&>;
|
||||
{ Iter-- } -> CSameAs<I >;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is an example of a bidirectional iterator, indicate the traits that define a bidirectional iterator.
|
||||
* Regardless of the order in which the increment and decrement operators are applied,
|
||||
* the result is always the same if both operations are performed the same number of times.
|
||||
*/
|
||||
template <CReferenceable T>
|
||||
struct IBidirectionalIterator /* : IForwardIterator<T> */
|
||||
{
|
||||
// ~Begin CForwardIterator.
|
||||
|
||||
using FElementType = TRemoveCVRef<T>;
|
||||
|
||||
IBidirectionalIterator();
|
||||
IBidirectionalIterator(const IBidirectionalIterator&);
|
||||
IBidirectionalIterator(IBidirectionalIterator&&);
|
||||
IBidirectionalIterator* operator=(const IBidirectionalIterator&);
|
||||
IBidirectionalIterator* operator=(IBidirectionalIterator&&);
|
||||
|
||||
friend bool operator==(const IBidirectionalIterator&, const IBidirectionalIterator&);
|
||||
|
||||
T operator*() const;
|
||||
|
||||
// ~End CForwardIterator.
|
||||
|
||||
IBidirectionalIterator& operator++(); // Also satisfies CForwardIterator.
|
||||
IBidirectionalIterator& operator--();
|
||||
|
||||
IBidirectionalIterator operator++(int); // Also satisfies CForwardIterator.
|
||||
IBidirectionalIterator operator--(int);
|
||||
};
|
||||
|
||||
// Use IBidirectionalIterator<int> represents a bidirectional iterator.
|
||||
static_assert(CBidirectionalIterator<IBidirectionalIterator<int&>>);
|
||||
static_assert( COutputIterator<IBidirectionalIterator<int&>, int>);
|
||||
|
||||
/**
|
||||
* A concept specifies a type is a random access iterator.
|
||||
* Add the three-way comparison, addition, subtraction and subscript operators to the bidirectional iterator.
|
||||
*/
|
||||
template <typename I>
|
||||
concept CRandomAccessIterator = CBidirectionalIterator<I> && CTotallyOrdered<I> && CSizedSentinelFor<I, I>
|
||||
&& requires(I Iter, const I Jter, const ptrdiff N) {
|
||||
{ Iter += N } -> CSameAs<I&>;
|
||||
{ Jter + N } -> CSameAs<I >;
|
||||
{ N + Jter } -> CSameAs<I >;
|
||||
{ Iter -= N } -> CSameAs<I&>;
|
||||
{ Jter - N } -> CSameAs<I >;
|
||||
{ Jter[N] } -> CSameAs<TIteratorReference<I>>;
|
||||
};
|
||||
|
||||
/** This is an example of a random access iterator, indicate the traits that define a random access iterator. */
|
||||
template <CReferenceable T>
|
||||
struct IRandomAccessIterator /* : IBidirectionalIterator<T>, ISizedSentinelFor<IRandomAccessIterator> */
|
||||
{
|
||||
// ~Begin CBidirectionalIterator.
|
||||
|
||||
using FElementType = TRemoveCVRef<T>;
|
||||
|
||||
// ~End CBidirectionalIterator.
|
||||
|
||||
// ~Begin CBidirectionalIterator and CSizedSentinelFor<IRandomAccessIterator>.
|
||||
|
||||
IRandomAccessIterator();
|
||||
IRandomAccessIterator(const IRandomAccessIterator&);
|
||||
IRandomAccessIterator(IRandomAccessIterator&&);
|
||||
IRandomAccessIterator* operator=(const IRandomAccessIterator&);
|
||||
IRandomAccessIterator* operator=(IRandomAccessIterator&&);
|
||||
|
||||
friend bool operator==(const IRandomAccessIterator&, const IRandomAccessIterator&);
|
||||
|
||||
// ~End CBidirectionalIterator and CSizedSentinelFor<IRandomAccessIterator>.
|
||||
|
||||
friend strong_ordering operator<=>(const IRandomAccessIterator&, const IRandomAccessIterator&);
|
||||
|
||||
T operator*() const; // Also satisfies CBidirectionalIterator.
|
||||
|
||||
T operator[](ptrdiff) const;
|
||||
|
||||
// ~Begin CBidirectionalIterator.
|
||||
|
||||
IRandomAccessIterator& operator++();
|
||||
IRandomAccessIterator& operator--();
|
||||
|
||||
IRandomAccessIterator operator++(int);
|
||||
IRandomAccessIterator operator--(int);
|
||||
|
||||
// ~End CBidirectionalIterator.
|
||||
|
||||
IRandomAccessIterator& operator+=(ptrdiff);
|
||||
IRandomAccessIterator& operator-=(ptrdiff);
|
||||
|
||||
IRandomAccessIterator operator+(ptrdiff) const;
|
||||
IRandomAccessIterator operator-(ptrdiff) const;
|
||||
|
||||
friend IRandomAccessIterator operator+(ptrdiff, const IRandomAccessIterator&);
|
||||
|
||||
friend ptrdiff operator-(const IRandomAccessIterator&, const IRandomAccessIterator&); // Also satisfies CSizedSentinelFor<IRandomAccessIterator>.
|
||||
};
|
||||
|
||||
// Use IRandomAccessIterator<int> represents a random access iterator
|
||||
static_assert(CRandomAccessIterator<IRandomAccessIterator<int&>>);
|
||||
static_assert( COutputIterator<IRandomAccessIterator<int&>, int>);
|
||||
|
||||
/**
|
||||
* A concept specifies a type is a contiguous iterator.
|
||||
* Add the operator-> to the random access iterator and requires the operator* returns a true reference type.
|
||||
*/
|
||||
template <typename I>
|
||||
concept CContiguousIterator = CRandomAccessIterator<I> && CLValueReference<TIteratorReference<I>>
|
||||
&& CSameAs<TIteratorElement<I>, TRemoveCVRef<TIteratorReference<I>>>
|
||||
&& CSameAs<TIteratorPointer<I>, TAddPointer<TIteratorReference<I>>>
|
||||
&& requires(I& Iter)
|
||||
{
|
||||
{ ToAddress(Iter) } -> CSameAs<TAddPointer<TIteratorReference<I>>>;
|
||||
};
|
||||
|
||||
/** This is an example of a contiguous iterator, indicate the traits that define a contiguous iterator. */
|
||||
template <CLValueReference T>
|
||||
struct IContiguousIterator /* : IRandomAccessIterator<T> */
|
||||
{
|
||||
// ~Begin CRandomAccessIterator.
|
||||
|
||||
using FElementType = TRemoveCVRef<T>;
|
||||
|
||||
IContiguousIterator();
|
||||
IContiguousIterator(const IContiguousIterator&);
|
||||
IContiguousIterator(IContiguousIterator&&);
|
||||
IContiguousIterator* operator=(const IContiguousIterator&);
|
||||
IContiguousIterator* operator=(IContiguousIterator&&);
|
||||
|
||||
friend bool operator==(const IContiguousIterator&, const IContiguousIterator&);
|
||||
|
||||
friend strong_ordering operator<=>(const IContiguousIterator&, const IContiguousIterator&);
|
||||
|
||||
// ~End CRandomAccessIterator.
|
||||
|
||||
/**
|
||||
* Dereference operator. See IForwardIterator.
|
||||
* Specify, the return type must be a true reference type and refer to an element of a contiguous sequence, not a proxy class.
|
||||
* Also satisfies CRandomAccessIterator.
|
||||
*/
|
||||
T operator*() const;
|
||||
|
||||
/** Indirection operator. Return the address of the element that the iterator is pointing to. */
|
||||
TAddPointer<T> operator->() const;
|
||||
|
||||
// ~Begin CRandomAccessIterator.
|
||||
|
||||
T operator[](ptrdiff) const;
|
||||
|
||||
IContiguousIterator& operator++();
|
||||
IContiguousIterator& operator--();
|
||||
|
||||
IContiguousIterator operator++(int);
|
||||
IContiguousIterator operator--(int);
|
||||
|
||||
IContiguousIterator& operator+=(ptrdiff);
|
||||
IContiguousIterator& operator-=(ptrdiff);
|
||||
|
||||
IContiguousIterator operator+(ptrdiff) const;
|
||||
IContiguousIterator operator-(ptrdiff) const;
|
||||
|
||||
friend IContiguousIterator operator+(ptrdiff, const IContiguousIterator&);
|
||||
|
||||
friend ptrdiff operator-(const IContiguousIterator&, const IContiguousIterator&);
|
||||
|
||||
// ~End CRandomAccessIterator.
|
||||
};
|
||||
|
||||
// Use IContiguousIterator<int> represents a contiguous iterator
|
||||
static_assert(CContiguousIterator<IContiguousIterator<int&>>);
|
||||
static_assert( COutputIterator<IContiguousIterator<int&>, int>);
|
||||
|
||||
// The int* is the most typical example of a contiguous iterator
|
||||
static_assert(CContiguousIterator<int*>);
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ForwardIterator.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wnon-template-friend"
|
||||
#endif
|
||||
|
||||
/** A concept specifies a type is a bidirectional iterator. Add the decrement operator to the forward iterator. */
|
||||
template <typename I>
|
||||
concept CBidirectionalIterator = CForwardIterator<I>
|
||||
&& requires(I Iter) {
|
||||
{ --Iter } -> CSameAs<I&>;
|
||||
{ Iter-- } -> CSameAs<I >;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is an example of a bidirectional iterator, indicate the traits that define a bidirectional iterator.
|
||||
* Regardless of the order in which the increment and decrement operators are applied,
|
||||
* the result is always the same if both operations are performed the same number of times.
|
||||
*/
|
||||
template <CReferenceable T>
|
||||
struct IBidirectionalIterator /* : IForwardIterator<T> */
|
||||
{
|
||||
// ~Begin CForwardIterator.
|
||||
|
||||
using FElementType = TRemoveCVRef<T>;
|
||||
|
||||
IBidirectionalIterator();
|
||||
IBidirectionalIterator(const IBidirectionalIterator&);
|
||||
IBidirectionalIterator(IBidirectionalIterator&&);
|
||||
IBidirectionalIterator* operator=(const IBidirectionalIterator&);
|
||||
IBidirectionalIterator* operator=(IBidirectionalIterator&&);
|
||||
|
||||
friend bool operator==(const IBidirectionalIterator&, const IBidirectionalIterator&);
|
||||
|
||||
T operator*() const;
|
||||
|
||||
// ~End CForwardIterator.
|
||||
|
||||
IBidirectionalIterator& operator++(); // Also satisfies CForwardIterator.
|
||||
IBidirectionalIterator& operator--();
|
||||
|
||||
IBidirectionalIterator operator++(int); // Also satisfies CForwardIterator.
|
||||
IBidirectionalIterator operator--(int);
|
||||
};
|
||||
|
||||
// Use IBidirectionalIterator<int> represents a bidirectional iterator.
|
||||
static_assert(CBidirectionalIterator<IBidirectionalIterator<int&>>);
|
||||
static_assert( COutputIterator<IBidirectionalIterator<int&>, int>);
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
98
Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h
Normal file
98
Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h
Normal file
@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/RandomAccessIterator.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Memory/Address.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wnon-template-friend"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A concept specifies a type is a contiguous iterator.
|
||||
* Add the operator-> to the random access iterator and requires the operator* returns a true reference type.
|
||||
*/
|
||||
template <typename I>
|
||||
concept CContiguousIterator = CRandomAccessIterator<I> && CLValueReference<TIteratorReference<I>>
|
||||
&& CSameAs<TIteratorElement<I>, TRemoveCVRef<TIteratorReference<I>>>
|
||||
&& CSameAs<TIteratorPointer<I>, TAddPointer<TIteratorReference<I>>>
|
||||
&& requires(I& Iter)
|
||||
{
|
||||
{ ToAddress(Iter) } -> CSameAs<TAddPointer<TIteratorReference<I>>>;
|
||||
};
|
||||
|
||||
/** This is an example of a contiguous iterator, indicate the traits that define a contiguous iterator. */
|
||||
template <CLValueReference T>
|
||||
struct IContiguousIterator /* : IRandomAccessIterator<T> */
|
||||
{
|
||||
// ~Begin CRandomAccessIterator.
|
||||
|
||||
using FElementType = TRemoveCVRef<T>;
|
||||
|
||||
IContiguousIterator();
|
||||
IContiguousIterator(const IContiguousIterator&);
|
||||
IContiguousIterator(IContiguousIterator&&);
|
||||
IContiguousIterator* operator=(const IContiguousIterator&);
|
||||
IContiguousIterator* operator=(IContiguousIterator&&);
|
||||
|
||||
friend bool operator==(const IContiguousIterator&, const IContiguousIterator&);
|
||||
|
||||
friend strong_ordering operator<=>(const IContiguousIterator&, const IContiguousIterator&);
|
||||
|
||||
// ~End CRandomAccessIterator.
|
||||
|
||||
/**
|
||||
* Dereference operator. See IForwardIterator.
|
||||
* Specify, the return type must be a true reference type and refer to an element of a contiguous sequence, not a proxy class.
|
||||
* Also satisfies CRandomAccessIterator.
|
||||
*/
|
||||
T operator*() const;
|
||||
|
||||
/** Indirection operator. Return the address of the element that the iterator is pointing to. */
|
||||
TAddPointer<T> operator->() const;
|
||||
|
||||
// ~Begin CRandomAccessIterator.
|
||||
|
||||
T operator[](ptrdiff) const;
|
||||
|
||||
IContiguousIterator& operator++();
|
||||
IContiguousIterator& operator--();
|
||||
|
||||
IContiguousIterator operator++(int);
|
||||
IContiguousIterator operator--(int);
|
||||
|
||||
IContiguousIterator& operator+=(ptrdiff);
|
||||
IContiguousIterator& operator-=(ptrdiff);
|
||||
|
||||
IContiguousIterator operator+(ptrdiff) const;
|
||||
IContiguousIterator operator-(ptrdiff) const;
|
||||
|
||||
friend IContiguousIterator operator+(ptrdiff, const IContiguousIterator&);
|
||||
|
||||
friend ptrdiff operator-(const IContiguousIterator&, const IContiguousIterator&);
|
||||
|
||||
// ~End CRandomAccessIterator.
|
||||
};
|
||||
|
||||
// Use IContiguousIterator<int> represents a contiguous iterator
|
||||
static_assert(CContiguousIterator<IContiguousIterator<int&>>);
|
||||
static_assert( COutputIterator<IContiguousIterator<int&>, int>);
|
||||
|
||||
// The int* is the most typical example of a contiguous iterator
|
||||
static_assert(CContiguousIterator<int*>);
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -3,7 +3,9 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/BidirectionalIterator.h"
|
||||
#include "Iterator/RandomAccessIterator.h"
|
||||
#include "Iterator/ContiguousIterator.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
@ -46,7 +48,7 @@ public:
|
||||
FORCEINLINE constexpr TCountedIterator& operator=(TCountedIterator&&) = default;
|
||||
FORCEINLINE constexpr ~TCountedIterator() = default;
|
||||
|
||||
FORCEINLINE constexpr explicit TCountedIterator(FIteratorType InValue, ptrdiff N) : Current(MoveTemp(InValue)), Length(N) { check_code({ MaxLength = N; }); }
|
||||
FORCEINLINE constexpr explicit TCountedIterator(FIteratorType InValue, ptrdiff N) : Current(MoveTemp(InValue)) { check_code({ MaxLength = N; }); }
|
||||
|
||||
template <CInputOrOutputIterator J> requires (!CSameAs<I, J> && CConstructibleFrom<I, const J&>)
|
||||
FORCEINLINE constexpr explicit (!CConvertibleTo<const J&, I>) TCountedIterator(const TCountedIterator<J>& InValue)
|
||||
@ -134,7 +136,7 @@ static_assert(CBidirectionalIterator<TCountedIterator<IBidirectionalIterator<int
|
||||
static_assert( CRandomAccessIterator<TCountedIterator< IRandomAccessIterator<int&>>>);
|
||||
static_assert( CContiguousIterator<TCountedIterator< IContiguousIterator<int&>>>);
|
||||
|
||||
static_assert(COutputIterator<TCountedIterator<IOutputIterator<int&>>, int>);
|
||||
//static_assert(COutputIterator<TCountedIterator<IOutputIterator<int&>>, int>);
|
||||
|
||||
static_assert(CSizedSentinelFor<TCountedIterator<IForwardIterator<int>>, TCountedIterator<IForwardIterator<int>>>);
|
||||
|
||||
|
64
Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h
Normal file
64
Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h
Normal file
@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wnon-template-friend"
|
||||
#endif
|
||||
|
||||
/** A concept specifies a type is an input iterator. It is input iterator, incrementable, and sentinel for itself. */
|
||||
template <typename I>
|
||||
concept CForwardIterator = CInputIterator<I> && CIncrementable<I> && CSentinelFor<I, I>;
|
||||
|
||||
/** This is an example of a forward iterator, indicate the traits that define a forward iterator. */
|
||||
template <CReferenceable T>
|
||||
struct IForwardIterator /* : IInputIterator<T>, IIncrementable, ISentinelFor<IForwardIterator> */
|
||||
{
|
||||
// ~Begin CInputIterator.
|
||||
|
||||
using FElementType = TRemoveCVRef<T>;
|
||||
|
||||
// ~End CInputIterator.
|
||||
|
||||
// ~Begin CIncrementable and CSentinelFor<IForwardIterator>.
|
||||
|
||||
IForwardIterator();
|
||||
IForwardIterator(const IForwardIterator&);
|
||||
IForwardIterator(IForwardIterator&&); // Also satisfies IInputIterator.
|
||||
IForwardIterator* operator=(const IForwardIterator&);
|
||||
IForwardIterator* operator=(IForwardIterator&&); // Also satisfies IInputIterator.
|
||||
|
||||
friend bool operator==(const IForwardIterator&, const IForwardIterator&);
|
||||
|
||||
// ~End CIncrementable and CSentinelFor<IForwardIterator>.
|
||||
|
||||
// ~Begin CInputIterator.
|
||||
|
||||
T operator*() const; // Optional satisfies CIndirectlyWritable.
|
||||
|
||||
IForwardIterator& operator++(); // Also satisfies CIncrementable.
|
||||
|
||||
IForwardIterator operator++(int); // Also satisfies CIncrementable.
|
||||
|
||||
// ~End CInputIterator.
|
||||
};
|
||||
|
||||
// Use IForwardIterator<int> represents a forward iterator.
|
||||
static_assert(CForwardIterator<IForwardIterator<int&>>);
|
||||
static_assert( COutputIterator<IForwardIterator<int&>, int>);
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -3,7 +3,10 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ForwardIterator.h"
|
||||
#include "Iterator/BidirectionalIterator.h"
|
||||
#include "Iterator/RandomAccessIterator.h"
|
||||
#include "Iterator/ContiguousIterator.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Iterator/MoveIterator.h"
|
||||
#include "Iterator/CountedIterator.h"
|
||||
|
@ -3,7 +3,10 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ForwardIterator.h"
|
||||
#include "Iterator/BidirectionalIterator.h"
|
||||
#include "Iterator/RandomAccessIterator.h"
|
||||
#include "Iterator/ContiguousIterator.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
|
@ -0,0 +1,93 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BidirectionalIterator.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wnon-template-friend"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A concept specifies a type is a random access iterator.
|
||||
* Add the three-way comparison, addition, subtraction and subscript operators to the bidirectional iterator.
|
||||
*/
|
||||
template <typename I>
|
||||
concept CRandomAccessIterator = CBidirectionalIterator<I> && CTotallyOrdered<I> && CSizedSentinelFor<I, I>
|
||||
&& requires(I Iter, const I Jter, const ptrdiff N) {
|
||||
{ Iter += N } -> CSameAs<I&>;
|
||||
{ Jter + N } -> CSameAs<I >;
|
||||
{ N + Jter } -> CSameAs<I >;
|
||||
{ Iter -= N } -> CSameAs<I&>;
|
||||
{ Jter - N } -> CSameAs<I >;
|
||||
{ Jter[N] } -> CSameAs<TIteratorReference<I>>;
|
||||
};
|
||||
|
||||
/** This is an example of a random access iterator, indicate the traits that define a random access iterator. */
|
||||
template <CReferenceable T>
|
||||
struct IRandomAccessIterator /* : IBidirectionalIterator<T>, ISizedSentinelFor<IRandomAccessIterator> */
|
||||
{
|
||||
// ~Begin CBidirectionalIterator.
|
||||
|
||||
using FElementType = TRemoveCVRef<T>;
|
||||
|
||||
// ~End CBidirectionalIterator.
|
||||
|
||||
// ~Begin CBidirectionalIterator and CSizedSentinelFor<IRandomAccessIterator>.
|
||||
|
||||
IRandomAccessIterator();
|
||||
IRandomAccessIterator(const IRandomAccessIterator&);
|
||||
IRandomAccessIterator(IRandomAccessIterator&&);
|
||||
IRandomAccessIterator* operator=(const IRandomAccessIterator&);
|
||||
IRandomAccessIterator* operator=(IRandomAccessIterator&&);
|
||||
|
||||
friend bool operator==(const IRandomAccessIterator&, const IRandomAccessIterator&);
|
||||
|
||||
// ~End CBidirectionalIterator and CSizedSentinelFor<IRandomAccessIterator>.
|
||||
|
||||
friend strong_ordering operator<=>(const IRandomAccessIterator&, const IRandomAccessIterator&);
|
||||
|
||||
T operator*() const; // Also satisfies CBidirectionalIterator.
|
||||
|
||||
T operator[](ptrdiff) const;
|
||||
|
||||
// ~Begin CBidirectionalIterator.
|
||||
|
||||
IRandomAccessIterator& operator++();
|
||||
IRandomAccessIterator& operator--();
|
||||
|
||||
IRandomAccessIterator operator++(int);
|
||||
IRandomAccessIterator operator--(int);
|
||||
|
||||
// ~End CBidirectionalIterator.
|
||||
|
||||
IRandomAccessIterator& operator+=(ptrdiff);
|
||||
IRandomAccessIterator& operator-=(ptrdiff);
|
||||
|
||||
IRandomAccessIterator operator+(ptrdiff) const;
|
||||
IRandomAccessIterator operator-(ptrdiff) const;
|
||||
|
||||
friend IRandomAccessIterator operator+(ptrdiff, const IRandomAccessIterator&);
|
||||
|
||||
friend ptrdiff operator-(const IRandomAccessIterator&, const IRandomAccessIterator&); // Also satisfies CSizedSentinelFor<IRandomAccessIterator>.
|
||||
};
|
||||
|
||||
// Use IRandomAccessIterator<int> represents a random access iterator
|
||||
static_assert(CRandomAccessIterator<IRandomAccessIterator<int&>>);
|
||||
static_assert( COutputIterator<IRandomAccessIterator<int&>, int>);
|
||||
|
||||
#if PLATFORM_COMPILER_GCC
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -3,7 +3,9 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/BidirectionalIterator.h"
|
||||
#include "Iterator/RandomAccessIterator.h"
|
||||
#include "Iterator/ContiguousIterator.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
|
@ -1,16 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/Invoke.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Templates/Invoke.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
@ -21,7 +20,7 @@ NAMESPACE_BEGIN(Range)
|
||||
/**
|
||||
* A view adapter that consists of the elements of a range that satisfies a predicate.
|
||||
* When based on an input view, the filter view satisfies at least an input view up to a bidirectional view.
|
||||
* When based on a common view, the filter view satisfies a common view.
|
||||
* When based on a common view, the counted iterator satisfies a common view.
|
||||
*/
|
||||
template <CInputRange V, CPredicate<TRangeReference<V>> Pred> requires (CView<V> && CObject<Pred> && CMoveConstructible<Pred>)
|
||||
class TFilterView : public IBasicViewInterface<TFilterView<V, Pred>>
|
||||
@ -136,7 +135,8 @@ private:
|
||||
|
||||
NODISCARD FORCEINLINE constexpr bool operator==(const FIteratorImpl& InValue) const& { return Current == InValue.Current; }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr TRangeSentinel<V> GetBase() const { return Current; }
|
||||
NODISCARD FORCEINLINE constexpr const TRangeSentinel<V>& GetBase() const& { return Current; }
|
||||
NODISCARD FORCEINLINE constexpr TRangeSentinel<V> GetBase() && { return MoveTemp(Current); }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -1,112 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/MoveIterator.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/AllView.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
|
||||
/**
|
||||
* A view adapter which dereferences to a rvalue reference.
|
||||
* When based on an input view, the move view satisfies at least an input view up to a random access view.
|
||||
* When based on a common view, the move view satisfies a common view.
|
||||
*/
|
||||
template <CInputRange V> requires (CView<V>)
|
||||
class TMoveView : public IBasicViewInterface<TMoveView<V>>
|
||||
{
|
||||
public:
|
||||
|
||||
using FElementType = TRangeElement<V>;
|
||||
using FReference = TRangeRValueReference<V>;
|
||||
|
||||
FORCEINLINE constexpr TMoveView() requires (CDefaultConstructible<V>) = default;
|
||||
|
||||
FORCEINLINE constexpr explicit TMoveView(V InBase) : Base(MoveTemp(InBase)) { }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() { return MakeMoveIterator(Range::Begin(Base)); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End()
|
||||
{
|
||||
if constexpr (CCommonRange<V>)
|
||||
{
|
||||
return MakeMoveIterator(Range::End(Base));
|
||||
}
|
||||
else return MakeMoveSentinel(Range::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const V>) { return MakeMoveIterator(Range::Begin(Base)); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const V>)
|
||||
{
|
||||
if constexpr (CCommonRange<V>)
|
||||
{
|
||||
return MakeMoveIterator(Range::End(Base));
|
||||
}
|
||||
else return MakeMoveSentinel(Range::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< V>) { return Range::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const V>) { return Range::Num(Base); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() const& requires (CCopyConstructible<V>) { return Base; }
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() && { return MoveTemp(Base); }
|
||||
|
||||
private:
|
||||
|
||||
NO_UNIQUE_ADDRESS V Base;
|
||||
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
TMoveView(R&&) -> TMoveView<TAllView<R>>;
|
||||
|
||||
static_assert( CInputRange<TMoveView<TAllView<IRange< IInputIterator<int&>>>>>);
|
||||
static_assert( CForwardRange<TMoveView<TAllView<IRange< IForwardIterator<int&>>>>>);
|
||||
static_assert(CBidirectionalRange<TMoveView<TAllView<IRange<IBidirectionalIterator<int&>>>>>);
|
||||
static_assert( CRandomAccessRange<TMoveView<TAllView<IRange< IRandomAccessIterator<int&>>>>>);
|
||||
static_assert( CRandomAccessRange<TMoveView<TAllView<IRange< IContiguousIterator<int&>>>>>);
|
||||
|
||||
static_assert(CCommonRange<TMoveView<TAllView<ICommonRange<IForwardIterator<int>>>>>);
|
||||
static_assert( CView<TMoveView<TAllView< IRange< IInputIterator<int>>>>>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
|
||||
template <typename T>
|
||||
constexpr bool bEnableBorrowedRange<Range::TMoveView<T>> = bEnableBorrowedRange<T>;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
|
||||
/** Creates A view adapter that dereferences to a rvalue reference. */
|
||||
template <CViewableRange R> requires (requires { TMoveView(DeclVal<R>()); })
|
||||
NODISCARD FORCEINLINE constexpr auto Move(R&& Base)
|
||||
{
|
||||
return TMoveView(Forward<R>(Base));
|
||||
}
|
||||
|
||||
/** Creates A view adapter that dereferences to a rvalue reference. */
|
||||
NODISCARD FORCEINLINE constexpr auto Move()
|
||||
{
|
||||
using FClosure = decltype([]<CViewableRange R> requires (requires { Range::Move(DeclVal<R>()); }) (R&& Base)
|
||||
{
|
||||
return Range::Move(Forward<R>(Base));
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure>();
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -7,7 +7,5 @@
|
||||
#include "Range/Factory.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Range/MoveView.h"
|
||||
#include "Range/FilterView.h"
|
||||
#include "Range/TransformView.h"
|
||||
#include "Range/TakeView.h"
|
||||
|
@ -1,186 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/CountedIterator.h"
|
||||
#include "Numeric/Math.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/AllView.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
|
||||
/**
|
||||
* A view adapter that includes a specified number of elements from the beginning of a range.
|
||||
* When based on any view, the take view satisfies the corresponding any view.
|
||||
* When based on a random access and sized view, the take view satisfies a common view.
|
||||
*/
|
||||
template <CView V>
|
||||
class TTakeView : public IBasicViewInterface<TTakeView<V>>
|
||||
{
|
||||
private:
|
||||
|
||||
template <bool bConst> class FSentinelImpl;
|
||||
|
||||
public:
|
||||
|
||||
FORCEINLINE constexpr TTakeView() requires (CDefaultConstructible<V>) = default;
|
||||
|
||||
FORCEINLINE constexpr TTakeView(V InBase, size_t InCount) : Base(MoveTemp(InBase)), Count(InCount) { }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin()
|
||||
{
|
||||
if constexpr (CSizedRange<V>)
|
||||
{
|
||||
if constexpr (CRandomAccessRange<V>)
|
||||
{
|
||||
return Range::Begin(Base);
|
||||
}
|
||||
else return MakeCountedIterator(Range::Begin(Base), Num());
|
||||
}
|
||||
else return MakeCountedIterator(Range::Begin(Base), Count);
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const V>)
|
||||
{
|
||||
if constexpr (CSizedRange<const V>)
|
||||
{
|
||||
if constexpr (CRandomAccessRange<const V>)
|
||||
{
|
||||
return Range::Begin(Base);
|
||||
}
|
||||
else return MakeCountedIterator(Range::Begin(Base), Num());
|
||||
}
|
||||
else return MakeCountedIterator(Range::Begin(Base), Count);
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End()
|
||||
{
|
||||
if constexpr (CSizedRange<V>)
|
||||
{
|
||||
if constexpr (CRandomAccessRange<V>)
|
||||
{
|
||||
return Range::Begin(Base) + Num();
|
||||
}
|
||||
else return DefaultSentinel;
|
||||
}
|
||||
else return FSentinelImpl<false>(Range::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const V>)
|
||||
{
|
||||
if constexpr (CSizedRange<const V>)
|
||||
{
|
||||
if constexpr (CRandomAccessRange<const V>)
|
||||
{
|
||||
return Range::Begin(Base) + Num();
|
||||
}
|
||||
else return DefaultSentinel;
|
||||
}
|
||||
else return FSentinelImpl<true>(Range::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< V>) { return Math::Min(Range::Num(Base), Count); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const V>) { return Math::Min(Range::Num(Base), Count); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() const& requires (CCopyConstructible<V>) { return Base; }
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() && { return MoveTemp(Base); }
|
||||
|
||||
private:
|
||||
|
||||
NO_UNIQUE_ADDRESS V Base;
|
||||
|
||||
size_t Count;
|
||||
|
||||
template <bool bConst>
|
||||
class FSentinelImpl final
|
||||
{
|
||||
private:
|
||||
|
||||
using FBase = TConditional<bConst, const V, V>;
|
||||
|
||||
public:
|
||||
|
||||
FORCEINLINE constexpr FSentinelImpl() = default;
|
||||
|
||||
FORCEINLINE constexpr FSentinelImpl(FSentinelImpl<!bConst> Sentinel) requires (bConst && CConvertibleTo<TRangeSentinel<V>, TRangeSentinel<FBase>>)
|
||||
: Current(Sentinel.Current)
|
||||
{ }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr bool operator==(const TCountedIterator<TRangeIterator<FBase>>& InValue) const&
|
||||
{
|
||||
return InValue.Num() == 0 || InValue.GetBase() == Current;
|
||||
}
|
||||
|
||||
template <bool bOther = !bConst> requires (CSentinelFor<TRangeSentinel<FBase>, TRangeIterator<TConditional<bOther, const V, V>>>)
|
||||
NODISCARD FORCEINLINE constexpr bool operator==(const TCountedIterator<TRangeIterator<TConditional<bOther, const V, V>>>& InValue)
|
||||
{
|
||||
return InValue.Num() == 0 || InValue.GetBase() == Current;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr TRangeSentinel<FBase> GetBase() const { return Current; }
|
||||
|
||||
private:
|
||||
|
||||
NO_UNIQUE_ADDRESS TRangeSentinel<FBase> Current;
|
||||
|
||||
FORCEINLINE constexpr FSentinelImpl(TRangeSentinel<FBase> InCurrent) : Current(InCurrent) { }
|
||||
|
||||
friend TTakeView;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
TTakeView(R&&, size_t) -> TTakeView<TAllView<R>>;
|
||||
|
||||
static_assert( CInputRange<TTakeView<TAllView<IRange< IInputIterator<int&>>>>>);
|
||||
static_assert( CForwardRange<TTakeView<TAllView<IRange< IForwardIterator<int&>>>>>);
|
||||
static_assert(CBidirectionalRange<TTakeView<TAllView<IRange<IBidirectionalIterator<int&>>>>>);
|
||||
static_assert( CRandomAccessRange<TTakeView<TAllView<IRange< IRandomAccessIterator<int&>>>>>);
|
||||
static_assert( CContiguousRange<TTakeView<TAllView<IRange< IContiguousIterator<int&>>>>>);
|
||||
|
||||
static_assert(CCommonRange<TTakeView<TAllView<ISizedRange< IRandomAccessIterator<int>>>>>);
|
||||
static_assert( CSizedRange<TTakeView<TAllView<ISizedRange<IInputOrOutputIterator<int>>>>>);
|
||||
static_assert( CView<TTakeView<TAllView< IRange<IInputOrOutputIterator<int>>>>>);
|
||||
|
||||
static_assert(COutputRange<TTakeView<TAllView<IRange<IOutputIterator<int&>>>>, int>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
|
||||
template <typename T>
|
||||
constexpr bool bEnableBorrowedRange<Range::TTakeView<T>> = bEnableBorrowedRange<T>;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
|
||||
/** Creates A view adapter that includes a specified number of elements from the beginning of a range. */
|
||||
template <CViewableRange R> requires (requires { TTakeView(DeclVal<R>(), DeclVal<size_t>()); })
|
||||
NODISCARD FORCEINLINE constexpr auto Take(R&& Base, size_t Count)
|
||||
{
|
||||
return TTakeView(Forward<R>(Base), Count);
|
||||
}
|
||||
|
||||
/** Creates A view adapter that includes a specified number of elements from the beginning of a range. */
|
||||
NODISCARD FORCEINLINE constexpr auto Take(size_t Count)
|
||||
{
|
||||
using FClosure = decltype([]<CViewableRange R> requires (requires { Range::Take(DeclVal<R>(), DeclVal<size_t>()); }) (R&& Base, size_t Count)
|
||||
{
|
||||
return Range::Take(Forward<R>(Base), Count);
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure, size_t>(Count);
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -18,8 +18,8 @@ NAMESPACE_BEGIN(Range)
|
||||
/**
|
||||
* A view adapter of a sequence that applies a transformation function to each element.
|
||||
* When based on an input view, the transform view satisfies at least an input view up to a random access view.
|
||||
* When based on a common view, the transform view satisfies a common view. When based on a sized view,
|
||||
* the transform view satisfies a sized view. When based on a forward view and the function return
|
||||
* When based on a common view, the counted iterator satisfies a common view. When based on a sized view,
|
||||
* the counted iterator satisfies a sized view. When based on a forward view and the function return
|
||||
* an assignable value, the transform view satisfies an output view.
|
||||
*/
|
||||
template <CInputRange V, CMoveConstructible F> requires (CView<V> && CObject<F>
|
||||
@ -178,7 +178,8 @@ private:
|
||||
return RHS.GetBase() - LHS.GetBase();
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr TRangeSentinel<FBase> GetBase() const { return Current; }
|
||||
NODISCARD FORCEINLINE constexpr const TRangeIterator<FBase>& GetBase() const& { return Current; }
|
||||
NODISCARD FORCEINLINE constexpr TRangeIterator<FBase> GetBase() && { return MoveTemp(Current); }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
@ -277,12 +274,12 @@ concept CSizedRange = CRange<R>
|
||||
template <CInputOrOutputIterator I, CSizedSentinelFor<I> S = ISizedSentinelFor<I>>
|
||||
struct ISizedRange /* : IRange<I, S> */
|
||||
{
|
||||
// ~Begin CRange.
|
||||
// ~Begin CRange
|
||||
|
||||
I Begin() /* const */;
|
||||
S End() /* const */;
|
||||
|
||||
// ~End CRange.
|
||||
// ~End CRange
|
||||
|
||||
/**
|
||||
* Get the number of elements in the range.
|
||||
@ -344,12 +341,12 @@ concept CContiguousRange = CRandomAccessRange<R> && CContiguousIterator<TRangeIt
|
||||
template <CContiguousIterator I, CSentinelFor<I> S = ISentinelFor<I>>
|
||||
struct IContiguousRange /* : IRange<I, S> */
|
||||
{
|
||||
// ~Begin CRange.
|
||||
// ~Begin CRange
|
||||
|
||||
I Begin() /* const */;
|
||||
S End() /* const */;
|
||||
|
||||
// ~End CRange.
|
||||
// ~End CRange
|
||||
|
||||
/**
|
||||
* Get the pointer to the container element storage.
|
||||
|
@ -1,14 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
@ -23,26 +19,32 @@ class IBasicViewInterface
|
||||
public:
|
||||
|
||||
/** @return The pointer to the underlying element storage. */
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() requires (CContiguousIterator<TRangeIterator< T>>) { return ToAddress(Range::Begin(static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousIterator<TRangeIterator<const T>>) { return ToAddress(Range::Begin(static_cast<const T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() requires (CContiguousRange< T>) { return Range::GetData(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange<const T>) { return Range::GetData(static_cast<const T&>(*this)); }
|
||||
|
||||
/** @return The reverse iterator to the first or end element. */
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin() requires (CBidirectionalRange< T> && CCommonRange< T>) { return MakeReverseIterator(Range::End (static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto REnd() requires (CBidirectionalRange< T> && CCommonRange< T>) { return MakeReverseIterator(Range::Begin(static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return MakeReverseIterator(Range::End (static_cast<const T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto REnd() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return MakeReverseIterator(Range::Begin(static_cast<const T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() requires (CRange< T>) { return Range::Begin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto End() requires (CRange< T>) { return Range::End (static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const T>) { return Range::Begin(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const T>) { return Range::End (static_cast<const T&>(*this)); }
|
||||
|
||||
/** @return The reverse iterator to the first or end element. */
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin() requires (CBidirectionalRange< T> && CCommonRange< T>) { return Range::RBegin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto REnd() requires (CBidirectionalRange< T> && CCommonRange< T>) { return Range::REnd (static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return Range::RBegin(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto REnd() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return Range::REnd (static_cast<const T&>(*this)); }
|
||||
|
||||
/** @return The number of elements in the container. */
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CForwardRange< T> && CSizedSentinelFor<TRangeSentinel< T>, TRangeIterator< T>>) { T& Derived = static_cast< T&>(*this); return Range::End(Derived) - Range::Begin(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CForwardRange<const T> && CSizedSentinelFor<TRangeSentinel<const T>, TRangeIterator<const T>>) { const T& Derived = static_cast<const T&>(*this); return Range::End(Derived) - Range::Begin(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< T>) { return Range::Num(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const T>) { return Range::Num(static_cast<const T&>(*this)); }
|
||||
|
||||
/** @return true if the container is empty, false otherwise. */
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() requires (CSizedRange< T> || CForwardRange< T>) { T& Derived = static_cast< T&>(*this); if constexpr (CSizedRange< T>) return Range::Num(Derived) == 0; else return Range::Begin(Derived) == Range::End(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (CSizedRange<const T> || CForwardRange<const T>) { const T& Derived = static_cast<const T&>(*this); if constexpr (CSizedRange<const T>) return Range::Num(Derived) == 0; else return Range::Begin(Derived) == Range::End(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() requires (CSizedRange< T> || CForwardRange< T>) { return Range::IsEmpty(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (CSizedRange<const T> || CForwardRange<const T>) { return Range::IsEmpty(static_cast<const T&>(*this)); }
|
||||
|
||||
/** @return true if the container is empty, false otherwise. */
|
||||
NODISCARD FORCEINLINE constexpr explicit operator bool() requires (requires { Range::IsEmpty(DeclVal< T&>()); }) { return !Range::IsEmpty(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr explicit operator bool() const requires (requires { Range::IsEmpty(DeclVal<const T&>()); }) { return !Range::IsEmpty(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr explicit operator bool() requires (CSizedRange< T> || CForwardRange< T>) { return !Range::IsEmpty(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr explicit operator bool() const requires (CSizedRange<const T> || CForwardRange<const T>) { return !Range::IsEmpty(static_cast<const T&>(*this)); }
|
||||
|
||||
/** @return The reference to the requested element. */
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) operator[](size_t Index) requires (CRandomAccessRange< T>) { return Range::Begin(static_cast< T&>(*this))[Index]; }
|
||||
@ -54,14 +56,7 @@ public:
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Back() requires (CBidirectionalRange< T> && CCommonRange< T>) { return *Range::RBegin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Back() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return *Range::RBegin(static_cast<const T&>(*this)); }
|
||||
|
||||
// ~Begin ENABLE_RANGE_BASED_FOR_LOOP_SUPPORT.
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto begin() requires (CRange< T>) { return Range::Begin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto end() requires (CRange< T>) { return Range::End (static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto begin() const requires (CRange<const T>) { return Range::Begin(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto end() const requires (CRange<const T>) { return Range::End (static_cast<const T&>(*this)); }
|
||||
|
||||
// ~End ENABLE_RANGE_BASED_FOR_LOOP_SUPPORT.
|
||||
ENABLE_RANGE_BASED_FOR_LOOP_SUPPORT
|
||||
|
||||
private:
|
||||
|
||||
|
@ -1,24 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Templates/Optional.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "Containers/ArrayView.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Factory.h"
|
||||
#include "Range/Range.h"
|
||||
#include "String/Char.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "String/StringView.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/Optional.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Noncopyable.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
#include <locale>
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
@ -1,17 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Range/Range.h"
|
||||
#include "String/Char.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Templates/Noncopyable.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Containers/ArrayView.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "String/Char.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
#include <cstring>
|
||||
@ -87,7 +85,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
using FElementType = T;
|
||||
using FElementType = TRemoveCV<T>;
|
||||
|
||||
using FReference = typename FSuper::FReference;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user