MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
marvin::containers::StrideView< T, Stride >::iterator Class Referencefinal

Custom iterator for StrideView. More...

#include <marvin_StrideView.h>

Public Types

using value_type = T
 
using difference_type = std::ptrdiff_t
 
using pointer = T*
 
using reference = T&
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

 iterator ()=delete
 
 iterator (pointer ptr)
 
 operator bool () const
 
reference operator* () const
 
pointer operator-> () const
 
iteratoroperator++ ()
 
iterator operator++ (int)
 
iteratoroperator-- ()
 
iterator operator-- (int)
 
iteratoroperator+= (difference_type n)
 
iteratoroperator-= (difference_type n)
 

Friends

bool operator== (const iterator &lhs, const iterator &rhs)
 
bool operator!= (const iterator &lhs, const iterator &rhs)
 
bool operator< (const iterator &lhs, const iterator &rhs)
 
bool operator> (const iterator &lhs, const iterator &rhs)
 
bool operator<= (const iterator &lhs, const iterator &rhs)
 
bool operator>= (const iterator &lhs, const iterator &rhs)
 
iterator operator+ (const iterator &iter, difference_type n)
 
iterator operator+ (difference_type n, const iterator &iter)
 
iterator operator- (const iterator &iter, difference_type n)
 
difference_type operator- (const iterator &lhs, const iterator &rhs)
 

Detailed Description

template<typename T, size_t Stride>
class marvin::containers::StrideView< T, Stride >::iterator

Custom iterator for StrideView.

Member Typedef Documentation

◆ difference_type

template<typename T, size_t Stride>
using marvin::containers::StrideView< T, Stride >::iterator::difference_type = std::ptrdiff_t

◆ iterator_category

template<typename T, size_t Stride>
using marvin::containers::StrideView< T, Stride >::iterator::iterator_category = std::forward_iterator_tag

◆ pointer

template<typename T, size_t Stride>
using marvin::containers::StrideView< T, Stride >::iterator::pointer = T*

◆ reference

template<typename T, size_t Stride>
using marvin::containers::StrideView< T, Stride >::iterator::reference = T&

◆ value_type

template<typename T, size_t Stride>
using marvin::containers::StrideView< T, Stride >::iterator::value_type = T

Constructor & Destructor Documentation

◆ iterator() [1/2]

template<typename T, size_t Stride>
marvin::containers::StrideView< T, Stride >::iterator::iterator ( )
delete

Default constructor doesn't make sense - would just be a nullptr waiting to happen.

◆ iterator() [2/2]

template<typename T, size_t Stride>
marvin::containers::StrideView< T, Stride >::iterator::iterator ( pointer ptr)
inline

Creates an iterator from a T*. Implicitly constructable.

Parameters
ptrA pointer to construct the iterator from.

Member Function Documentation

◆ operator bool()

template<typename T, size_t Stride>
marvin::containers::StrideView< T, Stride >::iterator::operator bool ( ) const
inline

Checks the validity of the underlying pointer.

Returns
true if the underlying pointer is not null, false otherwise.

◆ operator*()

template<typename T, size_t Stride>
reference marvin::containers::StrideView< T, Stride >::iterator::operator* ( ) const
inline

Dereferences the underlying pointer. Does not check for null.

Returns
A reference to the value stored at the underlying pointer.

◆ operator++() [1/2]

template<typename T, size_t Stride>
iterator & marvin::containers::StrideView< T, Stride >::iterator::operator++ ( )
inline

Pre increments the underlying pointer, by Stride steps.

Returns
An iterator to the incremented underlying pointer (*this).

◆ operator++() [2/2]

template<typename T, size_t Stride>
iterator marvin::containers::StrideView< T, Stride >::iterator::operator++ ( int )
inline

Post increments the underlying pointer, by Stride steps.

Returns
An iterator to the previous state of the internal pointer, before the increment.

◆ operator+=()

template<typename T, size_t Stride>
iterator & marvin::containers::StrideView< T, Stride >::iterator::operator+= ( difference_type n)
inline

Adds n * Stride to the underlying pointer.

Parameters
nThe number of steps to add to the underlying pointer.
Returns
An iterator to the modified underlying pointer (*this).

◆ operator--() [1/2]

template<typename T, size_t Stride>
iterator & marvin::containers::StrideView< T, Stride >::iterator::operator-- ( )
inline

Pre decrements the underlying pointer, by Stride steps.

Returns
An iterator to the decremented underlying pointer (*this).

◆ operator--() [2/2]

template<typename T, size_t Stride>
iterator marvin::containers::StrideView< T, Stride >::iterator::operator-- ( int )
inline

Post decrements the underlying pointer, by Stride steps.

Returns
An iterator to the previous state of the internal pointer, before the decrement.

◆ operator-=()

template<typename T, size_t Stride>
iterator & marvin::containers::StrideView< T, Stride >::iterator::operator-= ( difference_type n)
inline

Subtracts n * Stride from the underlying pointer.

Parameters
nThe number of steps to subtract from the underlying pointer.
Returns
An iterator to the modified underlying pointer (*this).

◆ operator->()

template<typename T, size_t Stride>
pointer marvin::containers::StrideView< T, Stride >::iterator::operator-> ( ) const
inline

Retrieves the underlying pointer.

Returns
The pointer wrapped by this iterator.

Friends And Related Symbol Documentation

◆ operator!=

template<typename T, size_t Stride>
bool operator!= ( const iterator & lhs,
const iterator & rhs )
friend

Inequality operator for two iterators.

Parameters
lhsA const ref to an iterator.
rhsA const ref to an iterator.
Returns
true if the underlying pointers are not equal, false otherwise.

◆ operator+ [1/2]

template<typename T, size_t Stride>
iterator operator+ ( const iterator & iter,
difference_type n )
friend

Addition operator for an iterator and a difference_type.

Parameters
iterAn iterator to modify
nA scalar to add to the underlying pointer of iter
Returns
A modified copy of iter, increased by n.

◆ operator+ [2/2]

template<typename T, size_t Stride>
iterator operator+ ( difference_type n,
const iterator & iter )
friend

Addition operator for a difference_type and an iterator.

Parameters
nA scalar to add to the underlying pointer of iter.
iterAn iterator to modify.
Returns
A modified copy of iter, increased by n.

◆ operator- [1/2]

template<typename T, size_t Stride>
iterator operator- ( const iterator & iter,
difference_type n )
friend

Subtraction operator for an iterator and a difference type.

Parameters
iterAn iterator to modify.
nA scalar to subtract from iter.
Returns
A modified copy of iter, decreased by n.

◆ operator- [2/2]

template<typename T, size_t Stride>
difference_type operator- ( const iterator & lhs,
const iterator & rhs )
friend

Subtraction operator for two iterators.

Parameters
lhsA const iterator ref.
rhsA const iterator ref.
Returns
The internal pointer of rhs subtracted from the internal pointer of rhs.

◆ operator<

template<typename T, size_t Stride>
bool operator< ( const iterator & lhs,
const iterator & rhs )
friend

Less than operator for two iterators.

Parameters
lhsA const ref to an iterator.
rhsA const ref to an iterator.
Returns
true if lhs' underlying pointer is less than rhs' underlying pointer, false otherwise.

◆ operator<=

template<typename T, size_t Stride>
bool operator<= ( const iterator & lhs,
const iterator & rhs )
friend

Less than or equal to operator for two iterators.

Parameters
lhsA const ref to an iterator.
rhsA const ref to an iterator.
Returns
true if lhs' underlying pointer is less than or equal to rhs' underlying pointer, false otherwise.

◆ operator==

template<typename T, size_t Stride>
bool operator== ( const iterator & lhs,
const iterator & rhs )
friend

Equality operator for two iterators.

Parameters
lhsA const ref to an iterator.
rhsA const ref to an iterator.
Returns
true if the underlying pointers are equal, false otherwise.

◆ operator>

template<typename T, size_t Stride>
bool operator> ( const iterator & lhs,
const iterator & rhs )
friend

Greater than operator for two iterators.

Parameters
lhsA const ref to an iterator.
rhsA const ref to an iterator.
Returns
true if lhs' underlying pointer is greater than rhs' underlying pointer, false otherwise.

◆ operator>=

template<typename T, size_t Stride>
bool operator>= ( const iterator & lhs,
const iterator & rhs )
friend

Greater than or equal to operator for two iterators.

Parameters
lhsA const ref to an iterator.
rhsA const ref to an iterator.
Returns
true if lhs' underlying pointer is greater than or equal to rhs' underlying pointer, false otherwise.

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