cortexlib  v0.2.0
Public Types | Public Member Functions | Protected Types | Protected Attributes | List of all members
cxl::normal_iterator< Iterator, Container > Class Template Reference

Normal Iterator. More...

#include <normal.hxx>

Public Types

using iterator_type = Iterator
 
using iterator_category = typename iter_traits_type::iterator_category
 
using value_type = typename iter_traits_type::value_type
 
using difference_type = typename iter_traits_type::difference_type
 
using pointer = typename iter_traits_type::pointer
 
using reference = typename iter_traits_type::reference
 

Public Member Functions

constexpr normal_iterator () noexcept
 Default Constructor. More...
 
template<typename Iter >
requires constexpr std::convertible_to< Iter, Iterator > normal_iterator (const normal_iterator< Iter, Container > &other) noexcept
 Converting Copy Constructor. More...
 
constexpr normal_iterator (const iterator_type &other) noexcept
 Iterator Copy Constructor. More...
 
constexpr auto operator* () noexcept -> reference
 Dereference Operator Overload. More...
 
constexpr auto operator* () const noexcept -> reference
 Dereference Operator Overload. More...
 
constexpr auto operator-> () noexcept -> pointer
 Arrow Deference Operator Overload. More...
 
constexpr auto operator-> () const noexcept -> pointer
 Arrow Deference Operator Overload. More...
 
constexpr auto operator++ () noexcept -> normal_iterator &
 Prefix Increment Operator Overload. More...
 
constexpr auto operator++ (int) noexcept -> normal_iterator
 Postfix Increment Operator Overload. More...
 
constexpr auto operator-- () noexcept -> normal_iterator &
 Prefix Decrement Operator Overload. More...
 
constexpr auto operator-- (int) noexcept -> normal_iterator
 Postfix Decrement Operator Overload. More...
 
constexpr auto operator[] (difference_type n) noexcept -> reference
 Subscript Operator Overload. More...
 
constexpr auto operator+= (difference_type step) noexcept -> normal_iterator &
 Additive Assignment Operator Overload. More...
 
constexpr auto operator-= (difference_type step) noexcept -> normal_iterator &
 Subtraction Assignment Operator Overload. More...
 
constexpr auto operator+ (difference_type step) const noexcept -> normal_iterator
 Addition Operator Overload. More...
 
constexpr auto operator- (difference_type step) const noexcept -> normal_iterator
 Subtraction Operator Overload. More...
 
constexpr auto base () const noexcept -> iterator_type
 Base Member Access. More...
 

Protected Types

using iter_traits_type = std::iterator_traits< Iterator >
 

Protected Attributes

Iterator current
 

Detailed Description

template<typename Iterator, typename Container>
class cxl::normal_iterator< Iterator, Container >

Normal Iterator.

This iterator is used to adapt non-iterator objects into objects (ie. pointers). normal_iterators does not change the semantics of the operators of the underlying iterator of type Iterator.

Template Parameters
IteratorThe underlying type of the iterator.
ContainerAllows iterators to be of different type even if the Iterator type is the same.

Member Typedef Documentation

◆ difference_type

template<typename Iterator , typename Container >
using cxl::normal_iterator< Iterator, Container >::difference_type = typename iter_traits_type::difference_type

◆ iter_traits_type

template<typename Iterator , typename Container >
using cxl::normal_iterator< Iterator, Container >::iter_traits_type = std::iterator_traits<Iterator>
protected

◆ iterator_category

template<typename Iterator , typename Container >
using cxl::normal_iterator< Iterator, Container >::iterator_category = typename iter_traits_type::iterator_category

◆ iterator_type

template<typename Iterator , typename Container >
using cxl::normal_iterator< Iterator, Container >::iterator_type = Iterator

◆ pointer

template<typename Iterator , typename Container >
using cxl::normal_iterator< Iterator, Container >::pointer = typename iter_traits_type::pointer

◆ reference

template<typename Iterator , typename Container >
using cxl::normal_iterator< Iterator, Container >::reference = typename iter_traits_type::reference

◆ value_type

template<typename Iterator , typename Container >
using cxl::normal_iterator< Iterator, Container >::value_type = typename iter_traits_type::value_type

Constructor & Destructor Documentation

◆ normal_iterator() [1/3]

template<typename Iterator , typename Container >
constexpr cxl::normal_iterator< Iterator, Container >::normal_iterator ( )
inlineconstexprnoexcept

Default Constructor.

Initialises current to the default value of the type Iterator.

◆ normal_iterator() [2/3]

template<typename Iterator , typename Container >
template<typename Iter >
requires constexpr std::convertible_to<Iter, Iterator> cxl::normal_iterator< Iterator, Container >::normal_iterator ( const normal_iterator< Iter, Container > &  other)
inlineconstexprnoexcept

Converting Copy Constructor.

Uses copy semantics to initialise current from another normal_iterator from a different underlying iterator type.

Template Parameters
Iter
Parameters
othertype: const normal_iterator<Iter, Container>&

◆ normal_iterator() [3/3]

template<typename Iterator , typename Container >
constexpr cxl::normal_iterator< Iterator, Container >::normal_iterator ( const iterator_type other)
inlineconstexprnoexcept

Iterator Copy Constructor.

Uses copy semantics to initialise current from an object as the same type as iterator_type. Because the the underlying types must be the same, current can be directly initialised from other.

Parameters
othertype: const iterator_type&

Member Function Documentation

◆ base()

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::base ( ) const -> iterator_type
inlineconstexprnoexcept

Base Member Access.

Returns a raw copy of current.

Returns
iterator_type

◆ operator*() [1/2]

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator* ( ) const -> reference
inlineconstexprnoexcept

Dereference Operator Overload.

Dereferences current and returns a reference of the value to the caller.

Returns
reference

◆ operator*() [2/2]

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator* ( ) -> reference
inlineconstexprnoexcept

Dereference Operator Overload.

Dereferences current and returns a reference of the value to the caller.

Returns
reference

◆ operator+()

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator+ ( difference_type  step) const -> normal_iterator
inlineconstexprnoexcept

Addition Operator Overload.

Constructs a new iterator from the addition of current and step.

Parameters
step
Returns
normal_iterator

◆ operator++() [1/2]

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator++ ( ) -> normal_iterator&
inlineconstexprnoexcept

Prefix Increment Operator Overload.

Applies the prefix increment operator to current and returns a reference to this.

Returns
normal_iterator&

◆ operator++() [2/2]

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator++ ( int  ) -> normal_iterator
inlineconstexprnoexcept

Postfix Increment Operator Overload.

Constructs a new iterator from current while applying the postfix increment operator on Construction. This effectively increments current for this while creating a new iterator with its current equal to the last value of this current.

Returns
normal_iterator

◆ operator+=()

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator+= ( difference_type  step) -> normal_iterator&
inlineconstexprnoexcept

Additive Assignment Operator Overload.

Increases the current's pointer value by step and assigns current the new pointer value and returns a reference to this.

Parameters
step
Returns
normal_iterator&

◆ operator-()

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator- ( difference_type  step) const -> normal_iterator
inlineconstexprnoexcept

Subtraction Operator Overload.

Constructs a new iterator from the subtraction of current and step.

Parameters
step
Returns
normal_iterator

◆ operator--() [1/2]

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator-- ( ) -> normal_iterator&
inlineconstexprnoexcept

Prefix Decrement Operator Overload.

Applies the prefix decrement operator to current and returns a reference to this.

Returns
normal_iterator&

◆ operator--() [2/2]

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator-- ( int  ) -> normal_iterator
inlineconstexprnoexcept

Postfix Decrement Operator Overload.

Constructs a new iterator from current while applying the postfix decrement operator on construction. This effectively decrements current for this while creating a new iterator with its current equal to the last value of this current.

Returns
normal_iterator

◆ operator-=()

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator-= ( difference_type  step) -> normal_iterator&
inlineconstexprnoexcept

Subtraction Assignment Operator Overload.

Decreases the current's pointer value by step and assigns current the new pointer value and returns a reference to this.

Parameters
step
Returns
normal_iterator&

◆ operator->() [1/2]

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator-> ( ) const -> pointer
inlineconstexprnoexcept

Arrow Deference Operator Overload.

Returns a pointer of current, this allows for access to the internal members if current is a class or object type through "indirection chaining".

Returns
pointer

◆ operator->() [2/2]

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator-> ( ) -> pointer
inlineconstexprnoexcept

Arrow Deference Operator Overload.

Returns a pointer of current, this allows for access to the internal members if current is a class or object type through "indirection chaining".

Returns
pointer

◆ operator[]()

template<typename Iterator , typename Container >
constexpr auto cxl::normal_iterator< Iterator, Container >::operator[] ( difference_type  n) -> reference
inlineconstexprnoexcept

Subscript Operator Overload.

Accesses the element at an offset to current's location in memory and returns a reference to the value stored at that location.

Parameters
ntype: difference_type
Returns
reference

Member Data Documentation

◆ current

template<typename Iterator , typename Container >
Iterator cxl::normal_iterator< Iterator, Container >::current
protected

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