Audio Processing Framework (APF) version 0.5.0
Public Types | Public Member Functions | Friends | List of all members
apf::cast_iterator< T, I > Class Template Reference

Iterator that casts items to T* on dereferenciation. More...

#include <apf/iterator.h>

Public Types

using value_type = T
 
using pointer = T *
 
using reference = T &
 
using difference_type = typename std::iterator_traits< I >::difference_type
 
using iterator_category = typename std::iterator_traits< I >::iterator_category
 

Public Member Functions

 cast_iterator (I base_iterator)
 Constructor from base iterator. More...
 
 cast_iterator ()
 Default constructor. More...
 
reference operator* () const
 Dereference operator. More...
 
pointer operator-> () const
 Arrow operator. More...
 
reference operator[] (difference_type n) const
 Subscript operator. More...
 
bool operator== (const self &rhs) const
 Straightforward equality operator. More...
 
selfoperator++ ()
 Straightforward preincrement operator. More...
 
selfoperator-- ()
 Straightforward predecrement operator. More...
 
selfoperator+= (difference_type n)
 Straightforward addition/assignment operator. More...
 
self operator++ (int)
 Postincrement operator (using preincrement operator). More...
 
self operator-- (int)
 Postdecrement operator (using predecrement operator). More...
 
bool operator!= (const self &rhs) const
 Unequality operator (using equality operator). More...
 
self operator+ (difference_type n) const
 Addition operator (iterator plus integer, using +=). More...
 
selfoperator-= (difference_type n)
 Subtraction/assignment operator (using +=). More...
 
self operator- (difference_type n) const
 Subtraction operator (using +=). More...
 
base () const
 Get the base iterator, inspired by std::reverse_iterator::base(). More...
 

Friends

bool operator< (const self &lhs, const self &rhs)
 Straightforward less-than operator. More...
 
difference_type operator- (const self &lhs, const self &rhs)
 Straightforward difference operator. More...
 
bool operator> (const self &lhs, const self &rhs)
 Straightforward greater-than operator (using less-than operator). More...
 
bool operator<= (const self &lhs, const self &rhs)
 Straightforward less-or-equal operator (using less-than operator). More...
 
bool operator>= (const self &lhs, const self &rhs)
 Straightforward greater-or-equal operator (using less-than operator). More...
 
self operator+ (difference_type n, const self &it)
 Addition operator (integer plus iterator, using +=). More...
 

Detailed Description

template<typename T, typename I>
class apf::cast_iterator< T, I >

Iterator that casts items to T* on dereferenciation.

There is an extra dereference inside the dereference operator, similar to boost::indirect_iterator (http://boost.org/doc/libs/release/libs/iterator/doc/indirect_iterator.html). But before that, the pointer is casted to the desired type T.

Template Parameters
TPointee type to be casted to
IBase iterator type
Precondition
value_type of I must be a pointer to a compatible type!
See also
make_cast_iterator() (helper function)
cast_proxy, cast_proxy_const

Definition at line 523 of file iterator.h.

Member Typedef Documentation

◆ value_type

template<typename T , typename I >
using apf::cast_iterator< T, I >::value_type = T

Definition at line 529 of file iterator.h.

◆ pointer

template<typename T , typename I >
using apf::cast_iterator< T, I >::pointer = T*

Definition at line 530 of file iterator.h.

◆ reference

template<typename T , typename I >
using apf::cast_iterator< T, I >::reference = T&

Definition at line 531 of file iterator.h.

◆ difference_type

template<typename T , typename I >
using apf::cast_iterator< T, I >::difference_type = typename std::iterator_traits<I>::difference_type

Definition at line 532 of file iterator.h.

◆ iterator_category

template<typename T , typename I >
using apf::cast_iterator< T, I >::iterator_category = typename std::iterator_traits<I>::iterator_category

Definition at line 533 of file iterator.h.

Constructor & Destructor Documentation

◆ cast_iterator() [1/2]

template<typename T , typename I >
apf::cast_iterator< T, I >::cast_iterator ( base_iterator)
inlineexplicit

Constructor from base iterator.

Parameters
base_iteratorbase iterator

Definition at line 536 of file iterator.h.

◆ cast_iterator() [2/2]

template<typename T , typename I >
apf::cast_iterator< T, I >::cast_iterator ( )
inline

Default constructor.

Note
This constructor creates a singular iterator. Another cast_iterator can be assigned to it, but nothing else works.

Definition at line 536 of file iterator.h.

Member Function Documentation

◆ operator*()

template<typename T , typename I >
reference apf::cast_iterator< T, I >::operator* ( ) const
inline

Dereference operator.

Returns
Reference to current item, casted to T.

Definition at line 542 of file iterator.h.

References apf::no_nullptr().

◆ operator->()

template<typename T , typename I >
pointer apf::cast_iterator< T, I >::operator-> ( ) const
inline

Arrow operator.

Returns
Pointer to current item, casted to T.

Definition at line 550 of file iterator.h.

References apf::no_nullptr().

◆ operator[]()

template<typename T , typename I >
reference apf::cast_iterator< T, I >::operator[] ( difference_type  n) const
inline

Subscript operator.

Parameters
nindex
Returns
Reference to n-th item, casted to T.

Definition at line 560 of file iterator.h.

References apf::no_nullptr().

◆ operator==()

template<typename T , typename I >
bool apf::cast_iterator< T, I >::operator== ( const self rhs) const
inline

Straightforward equality operator.

Definition at line 567 of file iterator.h.

◆ operator++() [1/2]

template<typename T , typename I >
self & apf::cast_iterator< T, I >::operator++ ( )
inline

Straightforward preincrement operator.

Definition at line 569 of file iterator.h.

◆ operator--() [1/2]

template<typename T , typename I >
self & apf::cast_iterator< T, I >::operator-- ( )
inline

Straightforward predecrement operator.

Definition at line 570 of file iterator.h.

◆ operator+=()

template<typename T , typename I >
self & apf::cast_iterator< T, I >::operator+= ( difference_type  n)
inline

Straightforward addition/assignment operator.

Definition at line 571 of file iterator.h.

◆ operator++() [2/2]

template<typename T , typename I >
self apf::cast_iterator< T, I >::operator++ ( int  )
inline

Postincrement operator (using preincrement operator).

Definition at line 573 of file iterator.h.

◆ operator--() [2/2]

template<typename T , typename I >
self apf::cast_iterator< T, I >::operator-- ( int  )
inline

Postdecrement operator (using predecrement operator).

Definition at line 574 of file iterator.h.

◆ operator!=()

template<typename T , typename I >
bool apf::cast_iterator< T, I >::operator!= ( const self rhs) const
inline

Unequality operator (using equality operator).

Definition at line 575 of file iterator.h.

◆ operator+()

template<typename T , typename I >
self apf::cast_iterator< T, I >::operator+ ( difference_type  n) const
inline

Addition operator (iterator plus integer, using +=).

Definition at line 577 of file iterator.h.

◆ operator-=()

template<typename T , typename I >
self & apf::cast_iterator< T, I >::operator-= ( difference_type  n)
inline

Subtraction/assignment operator (using +=).

Definition at line 577 of file iterator.h.

◆ operator-()

template<typename T , typename I >
self apf::cast_iterator< T, I >::operator- ( difference_type  n) const
inline

Subtraction operator (using +=).

Definition at line 577 of file iterator.h.

◆ base()

template<typename T , typename I >
I apf::cast_iterator< T, I >::base ( ) const
inline

Get the base iterator, inspired by std::reverse_iterator::base().

Definition at line 579 of file iterator.h.

Friends And Related Function Documentation

◆ operator<

template<typename T , typename I >
bool operator< ( const self lhs,
const self rhs 
)
friend

Straightforward less-than operator.

Definition at line 568 of file iterator.h.

◆ operator-

template<typename T , typename I >
difference_type operator- ( const self lhs,
const self rhs 
)
friend

Straightforward difference operator.

Definition at line 572 of file iterator.h.

◆ operator>

template<typename T , typename I >
bool operator> ( const self lhs,
const self rhs 
)
friend

Straightforward greater-than operator (using less-than operator).

Definition at line 576 of file iterator.h.

◆ operator<=

template<typename T , typename I >
bool operator<= ( const self lhs,
const self rhs 
)
friend

Straightforward less-or-equal operator (using less-than operator).

Definition at line 576 of file iterator.h.

◆ operator>=

template<typename T , typename I >
bool operator>= ( const self lhs,
const self rhs 
)
friend

Straightforward greater-or-equal operator (using less-than operator).

Definition at line 576 of file iterator.h.

◆ operator+

template<typename T , typename I >
self operator+ ( difference_type  n,
const self it 
)
friend

Addition operator (integer plus iterator, using +=).

Definition at line 577 of file iterator.h.


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