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

Iterator adaptor with a function call at dereferenciation. More...

#include <apf/iterator.h>

Public Types

using iterator_category = typename std::iterator_traits< I >::iterator_category
 
using reference = typename std::result_of< _signature >::type
 Can be a reference, but doesn't necessarily have to. More...
 
using value_type = typename std::remove_reference< reference >::type
 
using pointer = value_type *
 
using difference_type = typename std::iterator_traits< I >::difference_type
 

Public Member Functions

 transform_iterator (I base_iterator=I(), F f=F())
 Constructor. More...
 
reference operator* ()
 Dereference operator. More...
 
pointer operator-> ()
 Arrow 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...
 
bool operator!= (const self &rhs) const
 Unequality operator (using equality operator). More...
 
reference operator[] (difference_type n) const
 Straightforward subscript operator (using + and dereference op). More...
 
self operator-- (int)
 Postdecrement operator (using predecrement 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 I, typename F>
class apf::transform_iterator< I, F >

Iterator adaptor with a function call at dereferenciation.

Template Parameters
Itype of base iterator
FUnary function object which takes an I::value_type. Example: math::raised_cosine
Warning
The result of F can be any type, but operator->() only works if it is a reference! If it's not a reference, you will get an error similar to this:
error: lvalue required as unary ‘&’ operand
See also
boost::transform_iterator: same idea, but much fancier implementation! http://boost.org/doc/libs/release/libs/iterator/doc/transform_iterator.html
transform_proxy, transform_proxy_const

Definition at line 876 of file iterator.h.

Member Typedef Documentation

◆ iterator_category

template<typename I , typename F >
using apf::transform_iterator< I, F >::iterator_category = typename std::iterator_traits<I>::iterator_category

Definition at line 884 of file iterator.h.

◆ reference

template<typename I , typename F >
using apf::transform_iterator< I, F >::reference = typename std::result_of<_signature>::type

Can be a reference, but doesn't necessarily have to.

Definition at line 887 of file iterator.h.

◆ value_type

template<typename I , typename F >
using apf::transform_iterator< I, F >::value_type = typename std::remove_reference<reference>::type

Definition at line 888 of file iterator.h.

◆ pointer

template<typename I , typename F >
using apf::transform_iterator< I, F >::pointer = value_type*

Definition at line 889 of file iterator.h.

◆ difference_type

template<typename I , typename F >
using apf::transform_iterator< I, F >::difference_type = typename std::iterator_traits<I>::difference_type

Definition at line 890 of file iterator.h.

Constructor & Destructor Documentation

◆ transform_iterator()

template<typename I , typename F >
apf::transform_iterator< I, F >::transform_iterator ( base_iterator = I(),
f = F() 
)
inlineexplicit

Constructor.

Definition at line 893 of file iterator.h.

Member Function Documentation

◆ operator*()

template<typename I , typename F >
reference apf::transform_iterator< I, F >::operator* ( )
inline

Dereference operator.

Dereference the base iterator, use it as argument to the stored function and return the result.

Note
This is non-const because _f might have state

Definition at line 902 of file iterator.h.

◆ operator->()

template<typename I , typename F >
pointer apf::transform_iterator< I, F >::operator-> ( )
inline

Arrow operator.

Dereference the base iterator, use it as argument to the stored function and return the address of the result.

Warning
Only works if the result of F is a reference!

Definition at line 908 of file iterator.h.

References apf::accumulating_iterator< I >::operator*().

◆ operator==()

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

Straightforward equality operator.

Definition at line 913 of file iterator.h.

◆ operator++() [1/2]

template<typename I , typename F >
self & apf::transform_iterator< I, F >::operator++ ( )
inline

Straightforward preincrement operator.

Definition at line 914 of file iterator.h.

◆ operator--() [1/2]

template<typename I , typename F >
self & apf::transform_iterator< I, F >::operator-- ( )
inline

Straightforward predecrement operator.

Definition at line 916 of file iterator.h.

◆ operator+=()

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

Straightforward addition/assignment operator.

Definition at line 917 of file iterator.h.

◆ operator++() [2/2]

template<typename I , typename F >
self apf::transform_iterator< I, F >::operator++ ( int  )
inline

Postincrement operator (using preincrement operator).

Definition at line 919 of file iterator.h.

◆ operator!=()

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

Unequality operator (using equality operator).

Definition at line 920 of file iterator.h.

◆ operator[]()

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

Straightforward subscript operator (using + and dereference op).

Definition at line 921 of file iterator.h.

◆ operator--() [2/2]

template<typename I , typename F >
self apf::transform_iterator< I, F >::operator-- ( int  )
inline

Postdecrement operator (using predecrement operator).

Definition at line 922 of file iterator.h.

◆ operator+()

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

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

Definition at line 924 of file iterator.h.

◆ operator-=()

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

Subtraction/assignment operator (using +=).

Definition at line 924 of file iterator.h.

◆ operator-()

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

Subtraction operator (using +=).

Definition at line 924 of file iterator.h.

◆ base()

template<typename I , typename F >
I apf::transform_iterator< I, F >::base ( ) const
inline

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

Definition at line 926 of file iterator.h.

Friends And Related Function Documentation

◆ operator<

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

Straightforward less-than operator.

Definition at line 915 of file iterator.h.

◆ operator-

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

Straightforward difference operator.

Definition at line 918 of file iterator.h.

◆ operator>

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

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

Definition at line 923 of file iterator.h.

◆ operator<=

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

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

Definition at line 923 of file iterator.h.

◆ operator>=

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

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

Definition at line 923 of file iterator.h.

◆ operator+

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

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

Definition at line 924 of file iterator.h.


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