style(iterator): organize comments to make them more human readable
This commit is contained in:
parent
24dd4347d1
commit
5cfde63dd4
@ -31,38 +31,30 @@ concept CBidirectionalIterator = CForwardIterator<I>
|
||||
template <CReference T>
|
||||
struct IBidirectionalIterator /* : IForwardIterator<T> */
|
||||
{
|
||||
/** The element type of the indirectly readable type. See 'IIndirectlyReadable'. */
|
||||
// ~Begin CForwardIterator.
|
||||
|
||||
using ElementType = TRemoveCVRef<T>;
|
||||
|
||||
/** Default constructor. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
IBidirectionalIterator();
|
||||
|
||||
/** Copy constructor. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
IBidirectionalIterator(const IBidirectionalIterator&);
|
||||
|
||||
/** Copy assignment operator. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
IBidirectionalIterator(IBidirectionalIterator&&);
|
||||
IBidirectionalIterator* operator=(const IBidirectionalIterator&);
|
||||
IBidirectionalIterator* operator=(IBidirectionalIterator&&);
|
||||
|
||||
/** Equality operator. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
friend bool operator==(const IBidirectionalIterator&, const IBidirectionalIterator&);
|
||||
|
||||
/** Dereference operator. See 'IForwardIterator'. */
|
||||
T operator*() const;
|
||||
|
||||
/** Pre-increment operator. See 'IWeaklyIncrementable'. */
|
||||
IBidirectionalIterator& operator++();
|
||||
// ~End CForwardIterator.
|
||||
|
||||
/** Pre-decrement operator. */
|
||||
IBidirectionalIterator& operator++(); // Also satisfies CForwardIterator.
|
||||
IBidirectionalIterator& operator--();
|
||||
|
||||
/** Post-increment operator. See 'IIncrementable'. */
|
||||
IBidirectionalIterator operator++(int);
|
||||
|
||||
/** Post-decrement operator. */
|
||||
IBidirectionalIterator operator++(int); // Also satisfies CForwardIterator.
|
||||
IBidirectionalIterator operator--(int);
|
||||
};
|
||||
|
||||
// Use 'IBidirectionalIterator<int>' represents a bidirectional iterator.
|
||||
// Use IBidirectionalIterator<int> represents a bidirectional iterator.
|
||||
static_assert(CBidirectionalIterator<IBidirectionalIterator<int&>>);
|
||||
static_assert( COutputIterator<IBidirectionalIterator<int&>, int>);
|
||||
|
||||
|
@ -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
|
||||
|
@ -20,37 +20,38 @@ concept CForwardIterator = CInputIterator<I> && CIncrementable<I> && CSentinelFo
|
||||
|
||||
/** This is an example of a forward iterator, indicate the traits that define a forward iterator. */
|
||||
template <CReference T>
|
||||
struct IForwardIterator /* : IInputIterator<T>, IIncrementable, ISentinelFor<I> */
|
||||
struct IForwardIterator /* : IInputIterator<T>, IIncrementable, ISentinelFor<IForwardIterator> */
|
||||
{
|
||||
/** The element type of the indirectly readable type. See 'IIndirectlyReadable'. */
|
||||
// ~Begin CInputIterator.
|
||||
|
||||
using ElementType = TRemoveCVRef<T>;
|
||||
|
||||
/** Default constructor. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
// ~End CInputIterator.
|
||||
|
||||
// ~Begin CIncrementable and CSentinelFor<IForwardIterator>.
|
||||
|
||||
IForwardIterator();
|
||||
|
||||
/** Copy constructor. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
IForwardIterator(const IForwardIterator&);
|
||||
|
||||
/** Copy assignment operator. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
IForwardIterator(IForwardIterator&&); // Also satisfies IInputIterator.
|
||||
IForwardIterator* operator=(const IForwardIterator&);
|
||||
IForwardIterator* operator=(IForwardIterator&&); // Also satisfies IInputIterator.
|
||||
|
||||
/** Equality operator. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
friend bool operator==(const IForwardIterator&, const IForwardIterator&);
|
||||
|
||||
/**
|
||||
* Indirectly read the element from the indirectly readable type. See 'IIndirectlyReadable'.
|
||||
* Indirectly write the element if the type is also an indirectly writable type. See 'IIndirectlyWritable'.
|
||||
*/
|
||||
T operator*() const;
|
||||
// ~End CIncrementable and CSentinelFor<IForwardIterator>.
|
||||
|
||||
/** Pre-increment operator. See 'IWeaklyIncrementable'. */
|
||||
IForwardIterator& operator++();
|
||||
// ~Begin CInputIterator.
|
||||
|
||||
/** Post-increment operator. See 'IIncrementable'. */
|
||||
IForwardIterator operator++(int);
|
||||
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.
|
||||
// Use IForwardIterator<int> represents a forward iterator.
|
||||
static_assert(CForwardIterator<IForwardIterator<int&>>);
|
||||
static_assert( COutputIterator<IForwardIterator<int&>, int>);
|
||||
|
||||
|
@ -33,64 +33,54 @@ concept CRandomAccessIterator = CBidirectionalIterator<I> && CTotallyOrdered<I>
|
||||
|
||||
/** This is an example of a random access iterator, indicate the traits that define a random access iterator. */
|
||||
template <CReference T>
|
||||
struct IRandomAccessIterator /* : IBidirectionalIterator<T> */
|
||||
struct IRandomAccessIterator /* : IBidirectionalIterator<T>, ISizedSentinelFor<IRandomAccessIterator> */
|
||||
{
|
||||
/** The element type of the indirectly readable type. See 'IIndirectlyReadable'. */
|
||||
// ~Begin CBidirectionalIterator.
|
||||
|
||||
using ElementType = TRemoveCVRef<T>;
|
||||
|
||||
/** Default constructor. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
// ~End CBidirectionalIterator.
|
||||
|
||||
// ~Begin CBidirectionalIterator and CSizedSentinelFor<IRandomAccessIterator>.
|
||||
|
||||
IRandomAccessIterator();
|
||||
|
||||
/** Copy constructor. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
IRandomAccessIterator(const IRandomAccessIterator&);
|
||||
|
||||
/** Copy assignment operator. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
IRandomAccessIterator(IRandomAccessIterator&&);
|
||||
IRandomAccessIterator* operator=(const IRandomAccessIterator&);
|
||||
IRandomAccessIterator* operator=(IRandomAccessIterator&&);
|
||||
|
||||
/** Equality operator. See 'IIncrementable' and 'ISentinelFor'. */
|
||||
friend bool operator==(const IRandomAccessIterator&, const IRandomAccessIterator&);
|
||||
|
||||
/** Three-way comparison operator. */
|
||||
friend strong_ordering operator<=>(const IRandomAccessIterator& LHS, const IRandomAccessIterator& RHS);
|
||||
// ~End CBidirectionalIterator and CSizedSentinelFor<IRandomAccessIterator>.
|
||||
|
||||
/** Dereference operator. See 'IForwardIterator'. */
|
||||
T operator*() const;
|
||||
friend strong_ordering operator<=>(const IRandomAccessIterator&, const IRandomAccessIterator&);
|
||||
|
||||
T operator*() const; // Also satisfies CBidirectionalIterator.
|
||||
|
||||
T operator[](ptrdiff) const;
|
||||
|
||||
// ~Begin CBidirectionalIterator.
|
||||
|
||||
/** Pre-increment operator. See 'IWeaklyIncrementable'. */
|
||||
IRandomAccessIterator& operator++();
|
||||
|
||||
/** Pre-decrement operator. See 'IBidirectionalIterator'. */
|
||||
IRandomAccessIterator& operator--();
|
||||
|
||||
/** Post-increment operator. See 'IIncrementable'. */
|
||||
IRandomAccessIterator operator++(int);
|
||||
|
||||
/** Post-decrement operator. See 'IBidirectionalIterator'. */
|
||||
IRandomAccessIterator operator--(int);
|
||||
|
||||
/** Addition assignment operator. */
|
||||
IRandomAccessIterator& operator+=(ptrdiff);
|
||||
// ~End CBidirectionalIterator.
|
||||
|
||||
/** Subtraction assignment operator. */
|
||||
IRandomAccessIterator& operator+=(ptrdiff);
|
||||
IRandomAccessIterator& operator-=(ptrdiff);
|
||||
|
||||
/** Addition operator. */
|
||||
IRandomAccessIterator operator+(ptrdiff) const;
|
||||
|
||||
/** Subtraction operator. */
|
||||
IRandomAccessIterator operator-(ptrdiff) const;
|
||||
|
||||
/** Addition operator. */
|
||||
friend IRandomAccessIterator operator+(ptrdiff, const IRandomAccessIterator&);
|
||||
|
||||
/** Subtraction operator. */
|
||||
friend ptrdiff operator-(const IRandomAccessIterator&, const IRandomAccessIterator&);
|
||||
|
||||
/** Subscript operator. */
|
||||
T operator[](ptrdiff) const;
|
||||
friend ptrdiff operator-(const IRandomAccessIterator&, const IRandomAccessIterator&); // Also satisfies CSizedSentinelFor<IRandomAccessIterator>.
|
||||
};
|
||||
|
||||
// Use 'IRandomAccessIterator<int>' represents a random access iterator
|
||||
// Use IRandomAccessIterator<int> represents a random access iterator
|
||||
static_assert(CRandomAccessIterator<IRandomAccessIterator<int&>>);
|
||||
static_assert( COutputIterator<IRandomAccessIterator<int&>, int>);
|
||||
|
||||
|
@ -24,23 +24,17 @@ concept CSentinelFor = CSemiregular<S> && CInputOrOutputIterator<I> && CWeaklyEq
|
||||
template <CInputOrOutputIterator I>
|
||||
struct ISentinelFor
|
||||
{
|
||||
/** Default constructor. */
|
||||
ISentinelFor();
|
||||
|
||||
/** Copy constructor. */
|
||||
ISentinelFor(const ISentinelFor&);
|
||||
|
||||
/** Copy assignment operator. */
|
||||
ISentinelFor* operator=(const ISentinelFor&);
|
||||
|
||||
/** Equality operator. */
|
||||
bool operator==(const I&) const&;
|
||||
};
|
||||
|
||||
// Use 'ISentinelFor' represents a sentinel for an iterator.
|
||||
// Use ISentinelFor represents a sentinel for an iterator.
|
||||
static_assert(CSentinelFor<ISentinelFor<IInputOrOutputIterator<int>>, IInputOrOutputIterator<int>>);
|
||||
|
||||
// The 'CSentinelFor' requires this code is valid.
|
||||
// The CSentinelFor requires this code is valid.
|
||||
static_assert(
|
||||
requires(ISentinelFor<IInputOrOutputIterator<int>> Sentinel, IInputOrOutputIterator<int> Iter)
|
||||
{
|
||||
@ -49,7 +43,7 @@ static_assert(
|
||||
}
|
||||
);
|
||||
|
||||
/** Disable the 'CSizedSentinelFor' concept for specific types. */
|
||||
/** Disable the CSizedSentinelFor concept for specific types. */
|
||||
template <typename S, typename I>
|
||||
inline constexpr bool bDisableSizedSentinelFor = false;
|
||||
|
||||
@ -71,27 +65,23 @@ concept CSizedSentinelFor = CSentinelFor<S, I>
|
||||
template <CInputOrOutputIterator I>
|
||||
struct ISizedSentinelFor /* : ISentinelFor<I> */
|
||||
{
|
||||
/** Default constructor. */
|
||||
ISizedSentinelFor();
|
||||
|
||||
/** Copy constructor. */
|
||||
ISizedSentinelFor(); // Also satisfies ISentinelFor<I>.
|
||||
ISizedSentinelFor(const ISizedSentinelFor&);
|
||||
|
||||
/** Copy assignment operator. */
|
||||
ISizedSentinelFor(ISizedSentinelFor&&); // Also satisfies ISentinelFor<I>.
|
||||
ISizedSentinelFor& operator=(const ISizedSentinelFor&);
|
||||
ISizedSentinelFor& operator=(ISizedSentinelFor&&); // Also satisfies ISentinelFor<I>.
|
||||
|
||||
/** Equality operator. */
|
||||
bool operator==(const I&) const&;
|
||||
bool operator==(const I&) const&; // Also satisfies ISentinelFor<I>.
|
||||
|
||||
/** Subtraction operator. The 'Sentinel - Iter' is equal to negative 'Iter - Sentinel'. */
|
||||
friend ptrdiff operator-(const I&, const ISizedSentinelFor&);
|
||||
friend ptrdiff operator-(const ISizedSentinelFor&, const I&);
|
||||
};
|
||||
|
||||
// Use 'ISizedSentinelFor' represents a sized sentinel for an iterator.
|
||||
// Use ISizedSentinelFor represents a sized sentinel for an iterator.
|
||||
static_assert(CSizedSentinelFor<ISizedSentinelFor<IInputOrOutputIterator<int>>, IInputOrOutputIterator<int>>);
|
||||
|
||||
// The 'CSentinelFor' requires this code is valid.
|
||||
// The CSentinelFor requires this code is valid.
|
||||
static_assert(
|
||||
requires(ISizedSentinelFor<IInputOrOutputIterator<int>> Sentinel, IInputOrOutputIterator<int> Iter)
|
||||
{
|
||||
|
@ -76,18 +76,18 @@ struct IIndirectlyReadable
|
||||
|
||||
/**
|
||||
* Indirectly read the element from the indirectly readable type.
|
||||
* The return type may not be 'const ElementType&', this concept only requires that the return type
|
||||
* and 'ElementType' has some relationship, such as copy constructible to 'ElementType' if the type is copyable.
|
||||
* This means that returning a proxy class castable to 'ElementType' is also valid.
|
||||
* If this is an iterator adaptor, use 'decltype(auto)' to forward the return value.
|
||||
* The return type may not be const ElementType&, this concept only requires that the return type
|
||||
* and ElementType has some relationship, such as copy constructible to ElementType if the type is copyable.
|
||||
* This means that returning a proxy class castable to ElementType is also valid.
|
||||
* If this is an iterator adaptor, use decltype(auto) to forward the return value.
|
||||
*/
|
||||
T operator*() const;
|
||||
};
|
||||
|
||||
// Use 'IIndirectlyReadable<int>' represents an indirectly readable type and 'int' is the regular element type.
|
||||
// Use IIndirectlyReadable<int> represents an indirectly readable type and int is the regular element type.
|
||||
static_assert(CIndirectlyReadable<IIndirectlyReadable<int>> && CRegular<int>);
|
||||
|
||||
// The 'CIndirectlyReadable' requires this code is valid.
|
||||
// The CIndirectlyReadable requires this code is valid.
|
||||
static_assert(
|
||||
requires(IIndirectlyReadable<int> Iter, int& A)
|
||||
{
|
||||
@ -112,19 +112,19 @@ struct IIndirectlyWritable
|
||||
{
|
||||
/**
|
||||
* Indirectly write the element from the indirectly writable type.
|
||||
* The return type may not be 'T&', this concept only requires that the return type and 'T' has some relationship,
|
||||
* such as can be assigned from 'T&' if the type is copyable or 'T&&' if the type is movable.
|
||||
* This means that returning a proxy class can be assigned from 'T' is also valid.
|
||||
* The return type may not be T&, this concept only requires that the return type and T has some relationship,
|
||||
* such as can be assigned from T& if the type is copyable or T&& if the type is movable.
|
||||
* This means that returning a proxy class can be assigned from T is also valid.
|
||||
* If this is also an indirectly readable type, the equivalent value is read after writing.
|
||||
* If this is an iterator adaptor, use 'decltype(auto)' to forward the return value.
|
||||
* If this is an iterator adaptor, use decltype(auto) to forward the return value.
|
||||
*/
|
||||
T operator*() const;
|
||||
};
|
||||
|
||||
// Use 'IIndirectlyWritable<int>' represents an indirectly writable type and 'int' is the regular element type.
|
||||
// Use IIndirectlyWritable<int> represents an indirectly writable type and int is the regular element type.
|
||||
static_assert(CIndirectlyWritable<IIndirectlyWritable<int&>, int> && CRegular<int>);
|
||||
|
||||
// The 'CIndirectlyWritable' requires this code is valid.
|
||||
// The CIndirectlyWritable requires this code is valid.
|
||||
static_assert(
|
||||
requires(IIndirectlyWritable<int&> Iter, int& A)
|
||||
{
|
||||
@ -140,23 +140,16 @@ concept CWeaklyIncrementable = CMovable<I>
|
||||
/** This is an example of a weakly incrementable type, indicate the traits that define a weakly incrementable type. */
|
||||
struct IWeaklyIncrementable
|
||||
{
|
||||
/** Move constructor. */
|
||||
IWeaklyIncrementable(IWeaklyIncrementable&&);
|
||||
|
||||
/** Move assignment operator. */
|
||||
IWeaklyIncrementable* operator=(IWeaklyIncrementable&&);
|
||||
|
||||
/** Pre-increment operator. */
|
||||
IWeaklyIncrementable& operator++();
|
||||
|
||||
/**
|
||||
* Post-increment operator.
|
||||
* Specify, the concept not requires the return type is any specific type, so the return type can be 'void'.
|
||||
*/
|
||||
/** Post-increment operator. Specify, the concept not requires the return type is any specific type, so the return type can be void. */
|
||||
void operator++(int);
|
||||
};
|
||||
|
||||
// Use 'IWeaklyIncrementable' represents a weakly incrementable type.
|
||||
// Use IWeaklyIncrementable represents a weakly incrementable type.
|
||||
static_assert(CWeaklyIncrementable<IWeaklyIncrementable>);
|
||||
|
||||
/**
|
||||
@ -174,26 +167,21 @@ concept CIncrementable = CRegular<I> && CWeaklyIncrementable<I>
|
||||
*/
|
||||
struct IIncrementable /* : IWeaklyIncrementable */
|
||||
{
|
||||
/** Default constructor. */
|
||||
IIncrementable();
|
||||
|
||||
/** Copy constructor. */
|
||||
IIncrementable(const IIncrementable&);
|
||||
|
||||
/** Copy assignment operator. */
|
||||
IIncrementable(IIncrementable&&); // Also satisfies IWeaklyIncrementable.
|
||||
IIncrementable* operator=(const IIncrementable&);
|
||||
IIncrementable* operator=(IIncrementable&&); // Also satisfies IWeaklyIncrementable.
|
||||
|
||||
/** Equality operator. */
|
||||
friend bool operator==(const IIncrementable&, const IIncrementable&);
|
||||
|
||||
/** Pre-increment operator. See 'IWeaklyIncrementable'. */
|
||||
IIncrementable& operator++();
|
||||
IIncrementable& operator++(); // Also satisfies IWeaklyIncrementable.
|
||||
|
||||
/** Post-increment operator. */
|
||||
/** Post-increment operator. Specify, the concept requires the return value is the original value before incrementing. */
|
||||
IIncrementable operator++(int);
|
||||
};
|
||||
|
||||
// Use 'IIncrementable' represents an incrementable type.
|
||||
// Use IIncrementable represents an incrementable type.
|
||||
static_assert(CIncrementable<IIncrementable>);
|
||||
|
||||
/**
|
||||
@ -208,23 +196,22 @@ concept CInputOrOutputIterator = CWeaklyIncrementable<I>
|
||||
template <CReferenceable T>
|
||||
struct IInputOrOutputIterator /* : IWeaklyIncrementable */
|
||||
{
|
||||
/** Move constructor. See 'IWeaklyIncrementable'. */
|
||||
IInputOrOutputIterator(IInputOrOutputIterator&&);
|
||||
// ~Begin CWeklyIncrementable.
|
||||
|
||||
/** Move assignment operator. See 'IWeaklyIncrementable'. */
|
||||
IInputOrOutputIterator(IInputOrOutputIterator&&);
|
||||
IInputOrOutputIterator* operator=(IInputOrOutputIterator&&);
|
||||
|
||||
/** Pre-increment operator. See 'IWeaklyIncrementable'. */
|
||||
IInputOrOutputIterator& operator++();
|
||||
|
||||
/** Post-increment operator. See 'IWeaklyIncrementable'. */
|
||||
void operator++(int);
|
||||
|
||||
// ~End CWeklyIncrementable.
|
||||
|
||||
/** Dereference operator. It does not matter what the return type is, as long as it is referenceable. */
|
||||
T operator*() const;
|
||||
};
|
||||
|
||||
// Use 'IInputOrOutputIterator' represents an input or output iterator.
|
||||
// Use IInputOrOutputIterator represents an input or output iterator.
|
||||
static_assert(CInputOrOutputIterator<IInputOrOutputIterator<int>>);
|
||||
|
||||
/** A concept specifies a type is an input iterator. */
|
||||
@ -235,29 +222,30 @@ concept CInputIterator = CInputOrOutputIterator<I> && CIndirectlyReadable<I>;
|
||||
template <CReferenceable T>
|
||||
struct IInputIterator /* : IInputOrOutputIterator, IIndirectlyReadable */
|
||||
{
|
||||
/** The element type of the indirectly readable type. See 'IIndirectlyReadable'. */
|
||||
// ~Begin CIndirectlyReadable.
|
||||
|
||||
using ElementType = TRemoveCVRef<T>;
|
||||
|
||||
/** Move constructor. See 'IWeaklyIncrementable'. */
|
||||
IInputIterator(IInputIterator&&);
|
||||
// ~End CIndirectlyReadable.
|
||||
|
||||
/** Move assignment operator. See 'IWeaklyIncrementable'. */
|
||||
// ~Begin CInputOrOutputIterator.
|
||||
|
||||
IInputIterator(IInputIterator&&);
|
||||
IInputIterator* operator=(IInputIterator&&);
|
||||
|
||||
/** Indirectly read the element from the indirectly readable type. See 'IIndirectlyReadable'. */
|
||||
T operator*() const;
|
||||
T operator*() const; // Also satisfies CIndirectlyReadable.
|
||||
|
||||
/** Pre-increment operator. See 'IWeaklyIncrementable'. */
|
||||
IInputIterator& operator++();
|
||||
|
||||
/** Post-increment operator. See 'IWeaklyIncrementable'. */
|
||||
void operator++(int);
|
||||
|
||||
// ~End CInputOrOutputIterator.
|
||||
};
|
||||
|
||||
// Use 'IInputIterator<int>' represents an input iterator and 'int' is the regular element type.
|
||||
// Use IInputIterator<int> represents an input iterator and int is the regular element type.
|
||||
static_assert(CInputIterator<IInputIterator<int>> && CRegular<int>);
|
||||
|
||||
// The 'CInputIterator' requires this code is valid.
|
||||
// The CInputIterator requires this code is valid.
|
||||
static_assert(
|
||||
requires(IInputIterator<int> Iter, int& A)
|
||||
{
|
||||
@ -277,32 +265,31 @@ concept COutputIterator = CInputOrOutputIterator<I> && CIndirectlyWritable<I, T>
|
||||
template <CReference T>
|
||||
struct IOutputIterator /* : IInputOrOutputIterator, IIndirectlyWritable<T> */
|
||||
{
|
||||
/** Move constructor. See 'IWeaklyIncrementable'. */
|
||||
IOutputIterator(IOutputIterator&&);
|
||||
// ~Begin CIndirectlyWritable.
|
||||
|
||||
/** Move assignment operator. See 'IWeaklyIncrementable'. */
|
||||
IOutputIterator(IOutputIterator&&);
|
||||
IOutputIterator* operator=(IOutputIterator&&);
|
||||
|
||||
/** Indirectly write the element from the indirectly writable type. See 'IIndirectlyWritable'. */
|
||||
T operator*() const;
|
||||
T operator*() const; // Also satisfies CIndirectlyWritable.
|
||||
|
||||
/** Pre-increment operator. See 'IWeaklyIncrementable'. */
|
||||
IOutputIterator& operator++();
|
||||
|
||||
/**
|
||||
* Post-increment operator.
|
||||
* Specify, the concept not requires the return type is self type,
|
||||
* but requires the expression '*Iter++ = A;' is equivalent to '*Iter = A; ++Iter;'.
|
||||
* This means that returning a proxy class that satisfies 'CIndirectlyWritable<T>' is also valid.
|
||||
* See 'IWeaklyIncrementable'.
|
||||
* This means that returning a proxy class that satisfies CIndirectlyWritable<T> is also valid.
|
||||
* Also satisfies CIndirectlyWritable.
|
||||
*/
|
||||
IIndirectlyWritable<T> operator++(int);
|
||||
|
||||
// ~End CIndirectlyWritable.
|
||||
};
|
||||
|
||||
// Use 'IOutputIterator<int>' represents an output iterator and 'int' is the regular element type.
|
||||
// Use IOutputIterator<int> represents an output iterator and int is the regular element type.
|
||||
static_assert(COutputIterator<IOutputIterator<int&>, int> && CRegular<int>);
|
||||
|
||||
// The 'CInputIterator' requires this code is valid.
|
||||
// The CInputIterator requires this code is valid.
|
||||
static_assert(
|
||||
requires(IOutputIterator<int&> Iter, int& A)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user