Stratax 0.4.0rc1
Loading...
Searching...
No Matches
stratax::core::ArrayView< T >::basic_iterator< IsConst > Class Template Reference

Random-access iterator over logical flat indices of a view. More...

#include <ArrayView.hpp>

Public Types

using iterator_concept = std::random_access_iterator_tag
 C++20 random-access iterator concept tag.
 
using iterator_category = std::random_access_iterator_tag
 Legacy random-access iterator category tag.
 
using value_type = ArrayView::value_type
 Unqualified element type.
 
using difference_type = std::ptrdiff_t
 Signed iterator-distance type.
 
using reference = std::conditional_t< IsConst, const_reference, ArrayView::reference >
 Element reference with the iterator constness.
 

Public Member Functions

 basic_iterator ()=default
 Constructs a singular iterator.
 
 basic_iterator (view_type *view, size_type index) noexcept
 Constructs an iterator at a logical flat index, including the end position.
 
template<bool OtherConst>
requires (IsConst && !OtherConst)
 basic_iterator (const basic_iterator< OtherConst > &other) noexcept
 Converts a mutable iterator to a read-only iterator.
 
reference operator* () const
 Returns the element at the current logical position.
 
reference operator[] (difference_type offset) const
 Returns the element at a relative logical offset.
 
basic_iterator & operator++ ()
 Advances one position and returns this iterator.
 
basic_iterator operator++ (int)
 Advances one position and returns the previous iterator.
 
basic_iterator & operator-- ()
 Moves back one position and returns this iterator.
 
basic_iterator operator-- (int)
 Moves back one position and returns the previous iterator.
 
basic_iterator & operator+= (difference_type offset)
 Advances by a signed offset and returns this iterator.
 
basic_iterator & operator-= (difference_type offset)
 Moves back by a signed offset and returns this iterator.
 

Friends

basic_iterator operator+ (basic_iterator iterator, difference_type offset)
 Returns an iterator advanced by a signed offset.
 
basic_iterator operator+ (difference_type offset, basic_iterator iterator)
 Returns an iterator advanced by a signed offset.
 
basic_iterator operator- (basic_iterator iterator, difference_type offset)
 Returns an iterator moved back by a signed offset.
 
difference_type operator- (const basic_iterator &lhs, const basic_iterator &rhs)
 Returns the signed logical distance between iterators into the same view.
 
bool operator== (const basic_iterator &, const basic_iterator &)=default
 Compares both the view identity and logical position.
 
auto operator<=> (const basic_iterator &lhs, const basic_iterator &rhs)
 Orders logical positions within the same view.
 

Detailed Description

template<typename T>
template<bool IsConst>
class stratax::core::ArrayView< T >::basic_iterator< IsConst >

Random-access iterator over logical flat indices of a view.

Template Parameters
IsConstWhether dereferencing provides read-only access.
Precondition
The referenced view object and its underlying allocation remain alive and unchanged in layout while the iterator is used.
Dereference selects an index below size(); arithmetic stays within [begin(), end()], and ordering/difference compare the same view.
Complexity
Dereference and subscripting are O(view.rank()); arithmetic and comparison are O(1). The iterator is not contiguous.

Definition at line 70 of file ArrayView.hpp.

Member Typedef Documentation

◆ difference_type

template<typename T >
template<bool IsConst>
using stratax::core::ArrayView< T >::basic_iterator< IsConst >::difference_type = std::ptrdiff_t

Signed iterator-distance type.

Definition at line 86 of file ArrayView.hpp.

◆ iterator_category

template<typename T >
template<bool IsConst>
using stratax::core::ArrayView< T >::basic_iterator< IsConst >::iterator_category = std::random_access_iterator_tag

Legacy random-access iterator category tag.

Definition at line 82 of file ArrayView.hpp.

◆ iterator_concept

template<typename T >
template<bool IsConst>
using stratax::core::ArrayView< T >::basic_iterator< IsConst >::iterator_concept = std::random_access_iterator_tag

C++20 random-access iterator concept tag.

Definition at line 80 of file ArrayView.hpp.

◆ reference

template<typename T >
template<bool IsConst>
using stratax::core::ArrayView< T >::basic_iterator< IsConst >::reference = std::conditional_t<IsConst, const_reference, ArrayView::reference>

Element reference with the iterator constness.

Definition at line 88 of file ArrayView.hpp.

◆ value_type

template<typename T >
template<bool IsConst>
using stratax::core::ArrayView< T >::basic_iterator< IsConst >::value_type = ArrayView::value_type

Unqualified element type.

Definition at line 84 of file ArrayView.hpp.

Constructor & Destructor Documentation

◆ basic_iterator() [1/2]

template<typename T >
template<bool IsConst>
stratax::core::ArrayView< T >::basic_iterator< IsConst >::basic_iterator ( view_type *  view,
size_type  index 
)
inlinenoexcept

Constructs an iterator at a logical flat index, including the end position.

Definition at line 93 of file ArrayView.hpp.

◆ basic_iterator() [2/2]

template<typename T >
template<bool IsConst>
template<bool OtherConst>
requires (IsConst && !OtherConst)
stratax::core::ArrayView< T >::basic_iterator< IsConst >::basic_iterator ( const basic_iterator< OtherConst > &  other)
inlinenoexcept

Converts a mutable iterator to a read-only iterator.

Definition at line 100 of file ArrayView.hpp.

Member Function Documentation

◆ operator*()

template<typename T >
template<bool IsConst>
reference stratax::core::ArrayView< T >::basic_iterator< IsConst >::operator* ( ) const
inline

Returns the element at the current logical position.

Definition at line 105 of file ArrayView.hpp.

◆ operator++() [1/2]

template<typename T >
template<bool IsConst>
basic_iterator & stratax::core::ArrayView< T >::basic_iterator< IsConst >::operator++ ( )
inline

Advances one position and returns this iterator.

Definition at line 110 of file ArrayView.hpp.

◆ operator++() [2/2]

template<typename T >
template<bool IsConst>
basic_iterator stratax::core::ArrayView< T >::basic_iterator< IsConst >::operator++ ( int  )
inline

Advances one position and returns the previous iterator.

Definition at line 112 of file ArrayView.hpp.

◆ operator+=()

template<typename T >
template<bool IsConst>
basic_iterator & stratax::core::ArrayView< T >::basic_iterator< IsConst >::operator+= ( difference_type  offset)
inline

Advances by a signed offset and returns this iterator.

Definition at line 119 of file ArrayView.hpp.

◆ operator--() [1/2]

template<typename T >
template<bool IsConst>
basic_iterator & stratax::core::ArrayView< T >::basic_iterator< IsConst >::operator-- ( )
inline

Moves back one position and returns this iterator.

Definition at line 114 of file ArrayView.hpp.

◆ operator--() [2/2]

template<typename T >
template<bool IsConst>
basic_iterator stratax::core::ArrayView< T >::basic_iterator< IsConst >::operator-- ( int  )
inline

Moves back one position and returns the previous iterator.

Definition at line 116 of file ArrayView.hpp.

◆ operator-=()

template<typename T >
template<bool IsConst>
basic_iterator & stratax::core::ArrayView< T >::basic_iterator< IsConst >::operator-= ( difference_type  offset)
inline

Moves back by a signed offset and returns this iterator.

Definition at line 126 of file ArrayView.hpp.

◆ operator[]()

template<typename T >
template<bool IsConst>
reference stratax::core::ArrayView< T >::basic_iterator< IsConst >::operator[] ( difference_type  offset) const
inline

Returns the element at a relative logical offset.

Definition at line 107 of file ArrayView.hpp.

Friends And Related Symbol Documentation

◆ basic_iterator

template<typename T >
template<bool IsConst>
template<bool >
friend class basic_iterator
friend

Definition at line 164 of file ArrayView.hpp.

◆ operator+ [1/2]

template<typename T >
template<bool IsConst>
basic_iterator operator+ ( basic_iterator< IsConst >  iterator,
difference_type  offset 
)
friend

Returns an iterator advanced by a signed offset.

Definition at line 129 of file ArrayView.hpp.

◆ operator+ [2/2]

template<typename T >
template<bool IsConst>
basic_iterator operator+ ( difference_type  offset,
basic_iterator< IsConst >  iterator 
)
friend

Returns an iterator advanced by a signed offset.

Definition at line 136 of file ArrayView.hpp.

◆ operator- [1/2]

template<typename T >
template<bool IsConst>
basic_iterator operator- ( basic_iterator< IsConst >  iterator,
difference_type  offset 
)
friend

Returns an iterator moved back by a signed offset.

Definition at line 142 of file ArrayView.hpp.

◆ operator- [2/2]

template<typename T >
template<bool IsConst>
difference_type operator- ( const basic_iterator< IsConst > &  lhs,
const basic_iterator< IsConst > &  rhs 
)
friend

Returns the signed logical distance between iterators into the same view.

Definition at line 149 of file ArrayView.hpp.

◆ operator<=>

template<typename T >
template<bool IsConst>
auto operator<=> ( const basic_iterator< IsConst > &  lhs,
const basic_iterator< IsConst > &  rhs 
)
friend

Orders logical positions within the same view.

Definition at line 158 of file ArrayView.hpp.


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