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

Custom const_iterator for a 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

 const_iterator ()=delete
 
 const_iterator (pointer ptr)
 
 operator bool () const
 
const T & operator* () const
 
const T * operator-> () const
 
const_iteratoroperator++ ()
 
const_iterator operator++ (int)
 
const_iteratoroperator-- ()
 
const_iterator operator-- (int)
 
const_iteratoroperator+= (difference_type n)
 
const_iteratoroperator-= (difference_type n)
 

Friends

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

Detailed Description

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

Custom const_iterator for a StrideView.

Member Typedef Documentation

◆ difference_type

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

◆ iterator_category

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

◆ pointer

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

◆ reference

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

◆ value_type

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

Constructor & Destructor Documentation

◆ const_iterator() [1/2]

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

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

◆ const_iterator() [2/2]

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

Creates a const_iterator from a T*. Implicitly constructable.

Parameters
ptrA pointer to construct the const_iterator from.

Member Function Documentation

◆ operator bool()

template<typename T, size_t Stride>
marvin::containers::StrideView< T, Stride >::const_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>
const T & marvin::containers::StrideView< T, Stride >::const_iterator::operator* ( ) const
inline

Dereferences the underlying pointer. Does not check for null.

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

◆ operator++() [1/2]

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

Pre increments the underlying pointer, by Stride steps.

Returns
A const_iterator to the incremented underlying pointer (*this).

◆ operator++() [2/2]

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

Post increments the underlying pointer, by Stride steps.

Returns
A const_iterator to the previous state of the internal pointer, before the increment.

◆ operator+=()

template<typename T, size_t Stride>
const_iterator & marvin::containers::StrideView< T, Stride >::const_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
A const_iterator to the modified underlying pointer (*this).

◆ operator--() [1/2]

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

Pre decrements the underlying pointer, by Stride steps.

Returns
A const_iterator to the decremented underlying pointer (*this).

◆ operator--() [2/2]

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

Post decrements the underlying pointer, by Stride steps.

Returns
A const_iterator to the previous state of the internal pointer, before the decrement.

◆ operator-=()

template<typename T, size_t Stride>
const_iterator & marvin::containers::StrideView< T, Stride >::const_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
A const_iterator to the modified underlying pointer (*this).

◆ operator->()

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

Retrieves the underlying pointer.

Returns
The pointer (to const) wrapped by this const_iterator.

Friends And Related Symbol Documentation

◆ operator!=

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

Inequality operator for two const_iterators.

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

◆ operator+ [1/2]

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

Addition operator for an const_iterator and a difference_type.

Parameters
iterAn const_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>
const_iterator operator+ ( difference_type n,
const const_iterator & iter )
friend

Subtraction operator for an const_iterator and a difference type.

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

◆ operator- [1/2]

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

Subtraction operator for an const_iterator and a difference type.

Parameters
iterAn const_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>
const_iterator operator- ( const const_iterator & lhs,
const const_iterator & rhs )
friend

Subtraction operator for two const_iterators.

Parameters
lhsA const const_iterator ref.
rhsA const 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 const_iterator & lhs,
const const_iterator & rhs )
friend

Less than operator for two const_iterators.

Parameters
lhsA const ref to an const_iterator.
rhsA const ref to an const_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 const_iterator & lhs,
const const_iterator & rhs )
friend

Less than or equal to operator for two const_iterators.

Parameters
lhsA const ref to an const_iterator.
rhsA const ref to an const_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 const_iterator & lhs,
const const_iterator & rhs )
friend

Equality operator for two const_iterators.

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

◆ operator>

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

Greater than operator for two const_iterators.

Parameters
lhsA const ref to an const_iterator.
rhsA const ref to an const_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 const_iterator & lhs,
const const_iterator & rhs )
friend

Greater than or equal to operator for two const_iterators.

Parameters
lhsA const ref to an const_iterator.
rhsA const ref to an const_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: