style(iterator): organize comments to make them more human readable

This commit is contained in:
2024-12-14 14:02:26 +08:00
parent 24dd4347d1
commit 5cfde63dd4
6 changed files with 119 additions and 171 deletions

View File

@@ -17,7 +17,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
/**
* 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.
* 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>>
@@ -30,74 +30,62 @@ concept CContiguousIterator = CRandomAccessIterator<I> && CLValueReference<TIter
/** This is an example of a contiguous iterator, indicate the traits that define a contiguous iterator. */
template <CLValueReference T>
struct IContiguousIterator /* : IBidirectionalIterator<T> */
struct IContiguousIterator /* : IRandomAccessIterator<T> */
{
/** The element type of the indirectly readable type. See 'IIndirectlyReadable'. */
// ~Begin CRandomAccessIterator.
using ElementType = TRemoveCVRef<T>;
/** Default constructor. See 'IIncrementable' and 'ISentinelFor'. */
IContiguousIterator();
/** Copy constructor. See 'IIncrementable' and 'ISentinelFor'. */
IContiguousIterator(const IContiguousIterator&);
/** Copy assignment operator. See 'IIncrementable' and 'ISentinelFor'. */
IContiguousIterator(IContiguousIterator&&);
IContiguousIterator* operator=(const IContiguousIterator&);
IContiguousIterator* operator=(IContiguousIterator&&);
/** Equality operator. See 'IIncrementable' and 'ISentinelFor'. */
friend bool operator==(const IContiguousIterator&, const IContiguousIterator&);
/** Three-way comparison operator. See 'IRandomAccessIterator'. */
friend strong_ordering operator<=>(const IContiguousIterator& LHS, const IContiguousIterator& RHS);
friend strong_ordering operator<=>(const IContiguousIterator&, const IContiguousIterator&);
// ~End CRandomAccessIterator.
/**
* Dereference operator. See 'IForwardIterator'.
* 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;
/** Pre-increment operator. See 'IWeaklyIncrementable'. */
IContiguousIterator& operator++();
// ~Begin CRandomAccessIterator.
/** Pre-decrement operator. See 'IBidirectionalIterator'. */
T operator[](ptrdiff) const;
IContiguousIterator& operator++();
IContiguousIterator& operator--();
/** Post-increment operator. See 'IIncrementable'. */
IContiguousIterator operator++(int);
/** Post-decrement operator. See 'IBidirectionalIterator'. */
IContiguousIterator operator--(int);
/** Addition assignment operator. See 'IRandomAccessIterator'. */
IContiguousIterator& operator+=(ptrdiff);
/** Subtraction assignment operator. See 'IRandomAccessIterator'. */
IContiguousIterator& operator-=(ptrdiff);
/** Addition operator. See 'IRandomAccessIterator'. */
IContiguousIterator operator+(ptrdiff) const;
/** Subtraction operator. See 'IRandomAccessIterator'. */
IContiguousIterator operator-(ptrdiff) const;
/** Addition operator. See 'IRandomAccessIterator'. */
friend IContiguousIterator operator+(ptrdiff, const IContiguousIterator&);
/** Subtraction operator. See 'IRandomAccessIterator'. */
friend ptrdiff operator-(const IContiguousIterator&, const IContiguousIterator&);
/** Subscript operator. See 'IRandomAccessIterator'. */
T operator[](ptrdiff) const;
// ~End CRandomAccessIterator.
};
// Use 'IContiguousIterator<int>' represents a contiguous iterator
// 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
// The int* is the most typical example of a contiguous iterator
static_assert(CContiguousIterator<int*>);
#if PLATFORM_COMPILER_GCC