diff --git a/Redcraft.Utility/Source/Public/Containers/Array.h b/Redcraft.Utility/Source/Public/Containers/Array.h index ac9c5ae..99092d1 100644 --- a/Redcraft.Utility/Source/Public/Containers/Array.h +++ b/Redcraft.Utility/Source/Public/Containers/Array.h @@ -1,14 +1,18 @@ #pragma once #include "CoreTypes.h" -#include "Range/Range.h" -#include "Memory/Allocator.h" -#include "Iterator/Iterator.h" +#include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" #include "Templates/TypeHash.h" -#include "TypeTraits/TypeTraits.h" -#include "Miscellaneous/Compare.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 "Miscellaneous/Compare.h" #include "Miscellaneous/AssertionMacros.h" NAMESPACE_REDCRAFT_BEGIN diff --git a/Redcraft.Utility/Source/Public/Containers/ArrayView.h b/Redcraft.Utility/Source/Public/Containers/ArrayView.h index 43e8060..6b8c79c 100644 --- a/Redcraft.Utility/Source/Public/Containers/ArrayView.h +++ b/Redcraft.Utility/Source/Public/Containers/ArrayView.h @@ -1,15 +1,15 @@ #pragma once #include "CoreTypes.h" -#include "Range/Range.h" -#include "Memory/Address.h" -#include "Memory/Allocator.h" -#include "Containers/Array.h" -#include "Iterator/Iterator.h" +#include "TypeTraits/TypeTraits.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" diff --git a/Redcraft.Utility/Source/Public/Containers/Bitset.h b/Redcraft.Utility/Source/Public/Containers/Bitset.h index 4f83ca4..7c0bcd0 100644 --- a/Redcraft.Utility/Source/Public/Containers/Bitset.h +++ b/Redcraft.Utility/Source/Public/Containers/Bitset.h @@ -1,16 +1,17 @@ #pragma once #include "CoreTypes.h" -#include "Range/Range.h" -#include "Memory/Memory.h" -#include "Memory/Allocator.h" -#include "Iterator/Iterator.h" +#include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" #include "Templates/TypeHash.h" #include "Templates/Noncopyable.h" -#include "TypeTraits/TypeTraits.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 "Miscellaneous/Compare.h" -#include "Memory/MemoryOperator.h" #include "Miscellaneous/AssertionMacros.h" NAMESPACE_REDCRAFT_BEGIN diff --git a/Redcraft.Utility/Source/Public/Containers/List.h b/Redcraft.Utility/Source/Public/Containers/List.h index 221cd1d..ef38759 100644 --- a/Redcraft.Utility/Source/Public/Containers/List.h +++ b/Redcraft.Utility/Source/Public/Containers/List.h @@ -1,14 +1,18 @@ #pragma once #include "CoreTypes.h" -#include "Range/Range.h" -#include "Memory/Allocator.h" -#include "Iterator/Iterator.h" +#include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" #include "Templates/TypeHash.h" -#include "TypeTraits/TypeTraits.h" -#include "Miscellaneous/Compare.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 "Miscellaneous/Compare.h" #include "Miscellaneous/AssertionMacros.h" NAMESPACE_REDCRAFT_BEGIN diff --git a/Redcraft.Utility/Source/Public/Containers/StaticArray.h b/Redcraft.Utility/Source/Public/Containers/StaticArray.h index 956e486..d89fd2d 100644 --- a/Redcraft.Utility/Source/Public/Containers/StaticArray.h +++ b/Redcraft.Utility/Source/Public/Containers/StaticArray.h @@ -1,12 +1,13 @@ #pragma once #include "CoreTypes.h" -#include "Range/Range.h" -#include "Templates/Meta.h" -#include "Iterator/Iterator.h" -#include "Templates/Utility.h" -#include "Templates/TypeHash.h" #include "TypeTraits/TypeTraits.h" +#include "Templates/Utility.h" +#include "Templates/Meta.h" +#include "Templates/TypeHash.h" +#include "Iterator/Utility.h" +#include "Iterator/BasicIterator.h" +#include "Iterator/ReverseIterator.h" #include "Miscellaneous/Compare.h" #include "Miscellaneous/AssertionMacros.h" diff --git a/Redcraft.Utility/Source/Public/Containers/StaticBitset.h b/Redcraft.Utility/Source/Public/Containers/StaticBitset.h index 7830525..08d6771 100644 --- a/Redcraft.Utility/Source/Public/Containers/StaticBitset.h +++ b/Redcraft.Utility/Source/Public/Containers/StaticBitset.h @@ -1,14 +1,14 @@ #pragma once #include "CoreTypes.h" -#include "Range/Range.h" -#include "Iterator/Iterator.h" +#include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" #include "Templates/TypeHash.h" #include "Templates/Noncopyable.h" -#include "TypeTraits/TypeTraits.h" +#include "Iterator/Utility.h" +#include "Iterator/BasicIterator.h" +#include "Iterator/ReverseIterator.h" #include "Miscellaneous/Compare.h" -#include "Memory/MemoryOperator.h" #include "Miscellaneous/AssertionMacros.h" NAMESPACE_REDCRAFT_BEGIN diff --git a/Redcraft.Utility/Source/Public/Iterator/BasicIterator.h b/Redcraft.Utility/Source/Public/Iterator/BasicIterator.h new file mode 100644 index 0000000..656b04c --- /dev/null +++ b/Redcraft.Utility/Source/Public/Iterator/BasicIterator.h @@ -0,0 +1,250 @@ +#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 +concept CForwardIterator = CInputIterator && CIncrementable && CSentinelFor; + +/** This is an example of a forward iterator, indicate the traits that define a forward iterator. */ +template +struct IForwardIterator /* : IInputIterator, IIncrementable, ISentinelFor */ +{ + // ~Begin CInputIterator. + + using FElementType = TRemoveCVRef; + + // ~End CInputIterator. + + // ~Begin CIncrementable and CSentinelFor. + + 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. + + // ~Begin CInputIterator. + + T operator*() const; // Optional satisfies CIndirectlyWritable. + + IForwardIterator& operator++(); // Also satisfies CIncrementable. + + IForwardIterator operator++(int); // Also satisfies CIncrementable. + + // ~End CInputIterator. +}; + +// Use IForwardIterator represents a forward iterator. +static_assert(CForwardIterator>); +static_assert( COutputIterator, int>); + +/** A concept specifies a type is a bidirectional iterator. Add the decrement operator to the forward iterator. */ +template +concept CBidirectionalIterator = CForwardIterator + && requires(I Iter) { + { --Iter } -> CSameAs; + { Iter-- } -> CSameAs; + }; + +/** + * 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 +struct IBidirectionalIterator /* : IForwardIterator */ +{ + // ~Begin CForwardIterator. + + using FElementType = TRemoveCVRef; + + 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 represents a bidirectional iterator. +static_assert(CBidirectionalIterator>); +static_assert( COutputIterator, 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 +concept CRandomAccessIterator = CBidirectionalIterator && CTotallyOrdered && CSizedSentinelFor + && requires(I Iter, const I Jter, const ptrdiff N) { + { Iter += N } -> CSameAs; + { Jter + N } -> CSameAs; + { N + Jter } -> CSameAs; + { Iter -= N } -> CSameAs; + { Jter - N } -> CSameAs; + { Jter[N] } -> CSameAs>; + }; + +/** This is an example of a random access iterator, indicate the traits that define a random access iterator. */ +template +struct IRandomAccessIterator /* : IBidirectionalIterator, ISizedSentinelFor */ +{ + // ~Begin CBidirectionalIterator. + + using FElementType = TRemoveCVRef; + + // ~End CBidirectionalIterator. + + // ~Begin CBidirectionalIterator and CSizedSentinelFor. + + IRandomAccessIterator(); + IRandomAccessIterator(const IRandomAccessIterator&); + IRandomAccessIterator(IRandomAccessIterator&&); + IRandomAccessIterator* operator=(const IRandomAccessIterator&); + IRandomAccessIterator* operator=(IRandomAccessIterator&&); + + friend bool operator==(const IRandomAccessIterator&, const IRandomAccessIterator&); + + // ~End CBidirectionalIterator and CSizedSentinelFor. + + 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. +}; + +// Use IRandomAccessIterator represents a random access iterator +static_assert(CRandomAccessIterator>); +static_assert( COutputIterator, 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 +concept CContiguousIterator = CRandomAccessIterator && CLValueReference> + && CSameAs, TRemoveCVRef>> + && CSameAs, TAddPointer>> + && requires(I& Iter) + { + { ToAddress(Iter) } -> CSameAs>>; + }; + +/** This is an example of a contiguous iterator, indicate the traits that define a contiguous iterator. */ +template +struct IContiguousIterator /* : IRandomAccessIterator */ +{ + // ~Begin CRandomAccessIterator. + + using FElementType = TRemoveCVRef; + + 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 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 represents a contiguous iterator +static_assert(CContiguousIterator>); +static_assert( COutputIterator, int>); + +// The int* is the most typical example of a contiguous iterator +static_assert(CContiguousIterator); + +#if PLATFORM_COMPILER_GCC +# pragma GCC diagnostic pop +#endif + +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Iterator/BidirectionalIterator.h b/Redcraft.Utility/Source/Public/Iterator/BidirectionalIterator.h deleted file mode 100644 index b75ef52..0000000 --- a/Redcraft.Utility/Source/Public/Iterator/BidirectionalIterator.h +++ /dev/null @@ -1,67 +0,0 @@ -#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 -concept CBidirectionalIterator = CForwardIterator - && requires(I Iter) { - { --Iter } -> CSameAs; - { Iter-- } -> CSameAs; - }; - -/** - * 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 -struct IBidirectionalIterator /* : IForwardIterator */ -{ - // ~Begin CForwardIterator. - - using FElementType = TRemoveCVRef; - - 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 represents a bidirectional iterator. -static_assert(CBidirectionalIterator>); -static_assert( COutputIterator, int>); - -#if PLATFORM_COMPILER_GCC -# pragma GCC diagnostic pop -#endif - -NAMESPACE_MODULE_END(Utility) -NAMESPACE_MODULE_END(Redcraft) -NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h b/Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h deleted file mode 100644 index c155721..0000000 --- a/Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h +++ /dev/null @@ -1,98 +0,0 @@ -#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 -concept CContiguousIterator = CRandomAccessIterator && CLValueReference> - && CSameAs, TRemoveCVRef>> - && CSameAs, TAddPointer>> - && requires(I& Iter) - { - { ToAddress(Iter) } -> CSameAs>>; - }; - -/** This is an example of a contiguous iterator, indicate the traits that define a contiguous iterator. */ -template -struct IContiguousIterator /* : IRandomAccessIterator */ -{ - // ~Begin CRandomAccessIterator. - - using FElementType = TRemoveCVRef; - - 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 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 represents a contiguous iterator -static_assert(CContiguousIterator>); -static_assert( COutputIterator, int>); - -// The int* is the most typical example of a contiguous iterator -static_assert(CContiguousIterator); - -#if PLATFORM_COMPILER_GCC -# pragma GCC diagnostic pop -#endif - -NAMESPACE_MODULE_END(Utility) -NAMESPACE_MODULE_END(Redcraft) -NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h b/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h index eeb12ad..827386b 100644 --- a/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h @@ -3,9 +3,7 @@ #include "CoreTypes.h" #include "Iterator/Utility.h" #include "Iterator/Sentinel.h" -#include "Iterator/BidirectionalIterator.h" -#include "Iterator/RandomAccessIterator.h" -#include "Iterator/ContiguousIterator.h" +#include "Iterator/BasicIterator.h" #include "Miscellaneous/AssertionMacros.h" #include "Miscellaneous/Compare.h" #include "TypeTraits/TypeTraits.h" diff --git a/Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h b/Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h deleted file mode 100644 index 27233c5..0000000 --- a/Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h +++ /dev/null @@ -1,64 +0,0 @@ -#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 -concept CForwardIterator = CInputIterator && CIncrementable && CSentinelFor; - -/** This is an example of a forward iterator, indicate the traits that define a forward iterator. */ -template -struct IForwardIterator /* : IInputIterator, IIncrementable, ISentinelFor */ -{ - // ~Begin CInputIterator. - - using FElementType = TRemoveCVRef; - - // ~End CInputIterator. - - // ~Begin CIncrementable and CSentinelFor. - - 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. - - // ~Begin CInputIterator. - - T operator*() const; // Optional satisfies CIndirectlyWritable. - - IForwardIterator& operator++(); // Also satisfies CIncrementable. - - IForwardIterator operator++(int); // Also satisfies CIncrementable. - - // ~End CInputIterator. -}; - -// Use IForwardIterator represents a forward iterator. -static_assert(CForwardIterator>); -static_assert( COutputIterator, int>); - -#if PLATFORM_COMPILER_GCC -# pragma GCC diagnostic pop -#endif - -NAMESPACE_MODULE_END(Utility) -NAMESPACE_MODULE_END(Redcraft) -NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Iterator/Iterator.h b/Redcraft.Utility/Source/Public/Iterator/Iterator.h index 2aa426d..4573cb6 100644 --- a/Redcraft.Utility/Source/Public/Iterator/Iterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/Iterator.h @@ -3,10 +3,7 @@ #include "CoreTypes.h" #include "Iterator/Utility.h" #include "Iterator/Sentinel.h" -#include "Iterator/ForwardIterator.h" -#include "Iterator/BidirectionalIterator.h" -#include "Iterator/RandomAccessIterator.h" -#include "Iterator/ContiguousIterator.h" +#include "Iterator/BasicIterator.h" #include "Iterator/ReverseIterator.h" #include "Iterator/MoveIterator.h" #include "Iterator/CountedIterator.h" diff --git a/Redcraft.Utility/Source/Public/Iterator/MoveIterator.h b/Redcraft.Utility/Source/Public/Iterator/MoveIterator.h index 3993072..ef9e590 100644 --- a/Redcraft.Utility/Source/Public/Iterator/MoveIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/MoveIterator.h @@ -3,10 +3,7 @@ #include "CoreTypes.h" #include "Iterator/Utility.h" #include "Iterator/Sentinel.h" -#include "Iterator/ForwardIterator.h" -#include "Iterator/BidirectionalIterator.h" -#include "Iterator/RandomAccessIterator.h" -#include "Iterator/ContiguousIterator.h" +#include "Iterator/BasicIterator.h" #include "Miscellaneous/Compare.h" #include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" diff --git a/Redcraft.Utility/Source/Public/Iterator/RandomAccessIterator.h b/Redcraft.Utility/Source/Public/Iterator/RandomAccessIterator.h deleted file mode 100644 index c0e225b..0000000 --- a/Redcraft.Utility/Source/Public/Iterator/RandomAccessIterator.h +++ /dev/null @@ -1,93 +0,0 @@ -#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 -concept CRandomAccessIterator = CBidirectionalIterator && CTotallyOrdered && CSizedSentinelFor - && requires(I Iter, const I Jter, const ptrdiff N) { - { Iter += N } -> CSameAs; - { Jter + N } -> CSameAs; - { N + Jter } -> CSameAs; - { Iter -= N } -> CSameAs; - { Jter - N } -> CSameAs; - { Jter[N] } -> CSameAs>; - }; - -/** This is an example of a random access iterator, indicate the traits that define a random access iterator. */ -template -struct IRandomAccessIterator /* : IBidirectionalIterator, ISizedSentinelFor */ -{ - // ~Begin CBidirectionalIterator. - - using FElementType = TRemoveCVRef; - - // ~End CBidirectionalIterator. - - // ~Begin CBidirectionalIterator and CSizedSentinelFor. - - IRandomAccessIterator(); - IRandomAccessIterator(const IRandomAccessIterator&); - IRandomAccessIterator(IRandomAccessIterator&&); - IRandomAccessIterator* operator=(const IRandomAccessIterator&); - IRandomAccessIterator* operator=(IRandomAccessIterator&&); - - friend bool operator==(const IRandomAccessIterator&, const IRandomAccessIterator&); - - // ~End CBidirectionalIterator and CSizedSentinelFor. - - 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. -}; - -// Use IRandomAccessIterator represents a random access iterator -static_assert(CRandomAccessIterator>); -static_assert( COutputIterator, int>); - -#if PLATFORM_COMPILER_GCC -# pragma GCC diagnostic pop -#endif - -NAMESPACE_MODULE_END(Utility) -NAMESPACE_MODULE_END(Redcraft) -NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Iterator/ReverseIterator.h b/Redcraft.Utility/Source/Public/Iterator/ReverseIterator.h index bb8f02d..b0f6556 100644 --- a/Redcraft.Utility/Source/Public/Iterator/ReverseIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/ReverseIterator.h @@ -3,9 +3,7 @@ #include "CoreTypes.h" #include "Iterator/Utility.h" #include "Iterator/Sentinel.h" -#include "Iterator/BidirectionalIterator.h" -#include "Iterator/RandomAccessIterator.h" -#include "Iterator/ContiguousIterator.h" +#include "Iterator/BasicIterator.h" #include "Miscellaneous/Compare.h" #include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" diff --git a/Redcraft.Utility/Source/Public/Range/FilterView.h b/Redcraft.Utility/Source/Public/Range/FilterView.h index 1b74544..c064912 100644 --- a/Redcraft.Utility/Source/Public/Range/FilterView.h +++ b/Redcraft.Utility/Source/Public/Range/FilterView.h @@ -1,15 +1,16 @@ #pragma once #include "CoreTypes.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" +#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/AllView.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Range/Utility.h b/Redcraft.Utility/Source/Public/Range/Utility.h index 1e8783e..c7b77de 100644 --- a/Redcraft.Utility/Source/Public/Range/Utility.h +++ b/Redcraft.Utility/Source/Public/Range/Utility.h @@ -1,9 +1,12 @@ #pragma once #include "CoreTypes.h" -#include "Templates/Utility.h" -#include "Iterator/Iterator.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" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Range/View.h b/Redcraft.Utility/Source/Public/Range/View.h index e923149..c807345 100644 --- a/Redcraft.Utility/Source/Public/Range/View.h +++ b/Redcraft.Utility/Source/Public/Range/View.h @@ -1,10 +1,11 @@ #pragma once #include "CoreTypes.h" -#include "Range/Utility.h" -#include "Iterator/Iterator.h" -#include "Templates/Utility.h" #include "TypeTraits/TypeTraits.h" +#include "Templates/Utility.h" +#include "Iterator/Utility.h" +#include "Iterator/Sentinel.h" +#include "Range/Utility.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) diff --git a/Redcraft.Utility/Source/Public/String/String.h b/Redcraft.Utility/Source/Public/String/String.h index 67ecef6..9075d1b 100644 --- a/Redcraft.Utility/Source/Public/String/String.h +++ b/Redcraft.Utility/Source/Public/String/String.h @@ -1,17 +1,24 @@ #pragma once #include "CoreTypes.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 "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 "String/Char.h" +#include "String/StringView.h" #include "Miscellaneous/AssertionMacros.h" +#include + NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) diff --git a/Redcraft.Utility/Source/Public/String/StringView.h b/Redcraft.Utility/Source/Public/String/StringView.h index 890682d..e11ed79 100644 --- a/Redcraft.Utility/Source/Public/String/StringView.h +++ b/Redcraft.Utility/Source/Public/String/StringView.h @@ -1,15 +1,17 @@ #pragma once #include "CoreTypes.h" -#include "Range/Range.h" -#include "String/Char.h" -#include "Memory/Allocator.h" -#include "Iterator/Iterator.h" +#include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" #include "Templates/TypeHash.h" -#include "Containers/ArrayView.h" -#include "TypeTraits/TypeTraits.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 "Miscellaneous/AssertionMacros.h" #include