StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Safe::Iterable< Component >::BasicIterator< IsConst > Class Template Referencefinal

Suite cursor. More...

#include <StormByte/safe/iterable.hxx>

Public Types

using iterator_category = std::conditional_t<random_access, std::random_access_iterator_tag, std::bidirectional_iterator_tag>
 Iterator category.
using iterator_concept = iterator_category
 C++20 iterator concept.
using value_type = typename Iterable::value_type
 Element type.
using difference_type = std::ptrdiff_t
 Cursor distance type.
using reference = decltype(*std::declval<Inner>())
 Element reference.
using pointer = void
 The cursor does not expose a raw component pointer.

Public Member Functions

 BasicIterator ()=default
 Construct a singular cursor.
template<bool OtherConst>
requires IsConst
&&!OtherConst BasicIterator (const BasicIterator< OtherConst > &other) noexcept
 Convert a mutable cursor to a read-only cursor.
reference operator* () const
 Return the current element.
BasicIterator & operator++ ()
 Advance one element.
BasicIterator operator++ (int)
 Advance one element.
BasicIterator & operator-- ()
 Move to the previous element.
BasicIterator operator-- (int)
 Move to the previous element.
BasicIterator & operator+= (difference_type offset)
 Advance by an offset.
BasicIterator & operator-= (difference_type offset)
 Retreat by an offset.
reference operator[] (difference_type offset) const
 Return the element at an offset.
BasicIterator operator+ (difference_type offset) const
 Return the cursor advanced by an offset.
BasicIterator operator- (difference_type offset) const
 Return the cursor retreated by an offset.
template<bool OtherConst>
requires random_access
difference_type operator- (const BasicIterator< OtherConst > &other) const
 Return the distance to another cursor.
template<bool OtherConst>
bool operator== (const BasicIterator< OtherConst > &other) const
 Compare cursor position.
template<bool OtherConst>
requires random_access
bool operator< (const BasicIterator< OtherConst > &other) const
 Order two cursors.
template<bool OtherConst>
requires random_access
bool operator> (const BasicIterator< OtherConst > &other) const
 Order two cursors.
template<bool OtherConst>
requires random_access
bool operator<= (const BasicIterator< OtherConst > &other) const
 Order two cursors.
template<bool OtherConst>
requires random_access
bool operator>= (const BasicIterator< OtherConst > &other) const
 Order two cursors.

Friends

class Iterable
template<bool>
class BasicIterator
BasicIterator operator+ (difference_type offset, const BasicIterator &cursor)
 Advance a cursor from the offset.

Detailed Description

template<Type::SafeComponent Component>
template<bool IsConst>
class StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >

Suite cursor.

The category follows the wrapped component.

Template Parameters
IsConstWhether dereference is read-only.

Member Typedef Documentation

◆ difference_type

template<Type::SafeComponent Component>
template<bool IsConst>
using StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::difference_type = std::ptrdiff_t

Cursor distance type.

◆ iterator_category

template<Type::SafeComponent Component>
template<bool IsConst>
using StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::iterator_category = std::conditional_t<random_access, std::random_access_iterator_tag, std::bidirectional_iterator_tag>

Iterator category.

◆ iterator_concept

template<Type::SafeComponent Component>
template<bool IsConst>
using StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::iterator_concept = iterator_category

C++20 iterator concept.

◆ pointer

template<Type::SafeComponent Component>
template<bool IsConst>
using StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::pointer = void

The cursor does not expose a raw component pointer.

◆ reference

template<Type::SafeComponent Component>
template<bool IsConst>
using StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::reference = decltype(*std::declval<Inner>())

Element reference.

◆ value_type

template<Type::SafeComponent Component>
template<bool IsConst>
using StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::value_type = typename Iterable::value_type

Element type.

Constructor & Destructor Documentation

◆ BasicIterator() [1/2]

template<Type::SafeComponent Component>
template<bool IsConst>
StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::BasicIterator ( )
default

Construct a singular cursor.

◆ BasicIterator() [2/2]

template<Type::SafeComponent Component>
template<bool IsConst>
template<bool OtherConst>
requires IsConst
&&!OtherConst StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::BasicIterator ( const BasicIterator< OtherConst > & other)
noexcept

Convert a mutable cursor to a read-only cursor.

Parameters
otherMutable cursor.

Member Function Documentation

◆ operator*()

template<Type::SafeComponent Component>
template<bool IsConst>
reference StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator* ( ) const

Return the current element.

Returns
Element reference. Valid until the component reallocates or erases it.

◆ operator+()

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator+ ( difference_type offset) const

Return the cursor advanced by an offset.

Random-access components only.

Parameters
offsetElement offset.
Returns
Advanced cursor.

◆ operator++() [1/2]

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator & StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator++ ( )

Advance one element.

Returns
This cursor.

◆ operator++() [2/2]

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator++ ( int )

Advance one element.

Returns
Previous cursor value.

◆ operator+=()

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator & StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator+= ( difference_type offset)

Advance by an offset.

Random-access components only.

Parameters
offsetElement offset.
Returns
This cursor.

◆ operator-() [1/2]

template<Type::SafeComponent Component>
template<bool IsConst>
template<bool OtherConst>
requires random_access
difference_type StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator- ( const BasicIterator< OtherConst > & other) const

Return the distance to another cursor.

Random-access components only.

Parameters
otherCursor to measure against.
Returns
Element distance.

◆ operator-() [2/2]

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator- ( difference_type offset) const

Return the cursor retreated by an offset.

Random-access components only.

Parameters
offsetElement offset.
Returns
Retreated cursor.

◆ operator--() [1/2]

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator & StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator-- ( )

Move to the previous element.

Returns
This cursor.

◆ operator--() [2/2]

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator-- ( int )

Move to the previous element.

Returns
Previous cursor value.

◆ operator-=()

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator & StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator-= ( difference_type offset)

Retreat by an offset.

Random-access components only.

Parameters
offsetElement offset.
Returns
This cursor.

◆ operator<()

template<Type::SafeComponent Component>
template<bool IsConst>
template<bool OtherConst>
requires random_access
bool StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator< ( const BasicIterator< OtherConst > & other) const

Order two cursors.

Random-access components only.

Parameters
otherCursor to compare.
Returns
Whether this cursor precedes other.

◆ operator<=()

template<Type::SafeComponent Component>
template<bool IsConst>
template<bool OtherConst>
requires random_access
bool StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator<= ( const BasicIterator< OtherConst > & other) const

Order two cursors.

Random-access components only.

Parameters
otherCursor to compare.
Returns
Whether this cursor precedes or equals other.

◆ operator==()

template<Type::SafeComponent Component>
template<bool IsConst>
template<bool OtherConst>
bool StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator== ( const BasicIterator< OtherConst > & other) const

Compare cursor position.

Parameters
otherCursor to compare.
Returns
Whether both designate the same element.

◆ operator>()

template<Type::SafeComponent Component>
template<bool IsConst>
template<bool OtherConst>
requires random_access
bool StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator> ( const BasicIterator< OtherConst > & other) const

Order two cursors.

Random-access components only.

Parameters
otherCursor to compare.
Returns
Whether this cursor follows other.

◆ operator>=()

template<Type::SafeComponent Component>
template<bool IsConst>
template<bool OtherConst>
requires random_access
bool StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator>= ( const BasicIterator< OtherConst > & other) const

Order two cursors.

Random-access components only.

Parameters
otherCursor to compare.
Returns
Whether this cursor follows or equals other.

◆ operator[]()

template<Type::SafeComponent Component>
template<bool IsConst>
reference StormByte::Safe::Iterable< Component >::BasicIterator< IsConst >::operator[] ( difference_type offset) const

Return the element at an offset.

Random-access components only.

Parameters
offsetElement offset.
Returns
Element reference.

◆ BasicIterator

template<Type::SafeComponent Component>
template<bool IsConst>
template<bool>
friend class BasicIterator
friend

◆ Iterable

template<Type::SafeComponent Component>
template<bool IsConst>
friend class Iterable
friend

◆ operator+

template<Type::SafeComponent Component>
template<bool IsConst>
BasicIterator operator+ ( difference_type offset,
const BasicIterator< IsConst > & cursor )
friend

Advance a cursor from the offset.

Required by random_access_iterator.

Parameters
offsetElement offset.
cursorCursor to advance.
Returns
Advanced cursor.

The documentation for this class was generated from the following file: