Audio Processing Framework (APF) version 0.5.0
Macros
Iterator macros

Some macros to avoid code duplication in iterator (adaptor) classes. More...

Macros

#define APF_ITERATOR_CONSTRUCTORS(iterator_name, base_iterator_type, base_member)
 Straightforward default constructor and constructor from base iterator. More...
 
#define APF_ITERATOR_BASE(base_iterator_type, base_member)
 Get the base iterator. More...
 
#define APF_ITERATOR_OUTPUT_DEREFERENCE(base_member)
 Straightforward dereference operator. More...
 
#define APF_ITERATOR_OUTPUT_PREINCREMENT(base_member)
 Straightforward preincrement operator. More...
 
#define APF_ITERATOR_OUTPUT_POSTINCREMENT
 Postincrement operator (using preincrement operator). More...
 
#define APF_ITERATOR_INPUT_DEREFERENCE   APF_ITERATOR_OUTPUT_DEREFERENCE
 Straightforward dereference operator. More...
 
#define APF_ITERATOR_INPUT_ARROW(base_member)
 Straightforward arrow operator. More...
 
#define APF_ITERATOR_INPUT_EQUAL(base_member)
 Straightforward equality operator. More...
 
#define APF_ITERATOR_INPUT_PREINCREMENT   APF_ITERATOR_OUTPUT_PREINCREMENT
 Straightforward preincrement operator. More...
 
#define APF_ITERATOR_INPUT_POSTINCREMENT   APF_ITERATOR_OUTPUT_POSTINCREMENT
 Postincrement operator (using preincrement operator). More...
 
#define APF_ITERATOR_INPUT_UNEQUAL
 Unequality operator (using equality operator) More...
 
#define APF_ITERATOR_FORWARD_EQUAL   APF_ITERATOR_INPUT_EQUAL
 Straightforward equality operator. More...
 
#define APF_ITERATOR_FORWARD_DEREFERENCE   APF_ITERATOR_INPUT_DEREFERENCE
 Straightforward dereference operator. More...
 
#define APF_ITERATOR_FORWARD_ARROW   APF_ITERATOR_INPUT_ARROW
 Straightforward arrow operator. More...
 
#define APF_ITERATOR_FORWARD_PREINCREMENT   APF_ITERATOR_INPUT_PREINCREMENT
 Straightforward preincrement operator. More...
 
#define APF_ITERATOR_FORWARD_POSTINCREMENT   APF_ITERATOR_INPUT_POSTINCREMENT
 Postincrement operator (using preincrement operator). More...
 
#define APF_ITERATOR_FORWARD_UNEQUAL   APF_ITERATOR_INPUT_UNEQUAL
 Unequality operator (using equality operator). More...
 
#define APF_ITERATOR_BIDIRECTIONAL_EQUAL   APF_ITERATOR_FORWARD_EQUAL
 Straightforward equality operator. More...
 
#define APF_ITERATOR_BIDIRECTIONAL_DEREFERENCE   APF_ITERATOR_FORWARD_DEREFERENCE
 Straightforward dereference operator. More...
 
#define APF_ITERATOR_BIDIRECTIONAL_ARROW   APF_ITERATOR_FORWARD_ARROW
 Straightforward arrow operator. More...
 
#define APF_ITERATOR_BIDIRECTIONAL_PREINCREMENT   APF_ITERATOR_FORWARD_PREINCREMENT
 Straightforward preincrement operator. More...
 
#define APF_ITERATOR_BIDIRECTIONAL_PREDECREMENT(base_member)
 Straightforward predecrement operator. More...
 
#define APF_ITERATOR_BIDIRECTIONAL_POSTINCREMENT   APF_ITERATOR_FORWARD_POSTINCREMENT
 Postincrement operator (using preincrement operator). More...
 
#define APF_ITERATOR_BIDIRECTIONAL_UNEQUAL   APF_ITERATOR_FORWARD_UNEQUAL
 Unequality operator (using equality operator). More...
 
#define APF_ITERATOR_BIDIRECTIONAL_POSTDECREMENT
 Postdecrement operator (using predecrement operator). More...
 
#define APF_ITERATOR_RANDOMACCESS_EQUAL   APF_ITERATOR_BIDIRECTIONAL_EQUAL
 Straightforward equality operator. More...
 
#define APF_ITERATOR_RANDOMACCESS_DEREFERENCE   APF_ITERATOR_BIDIRECTIONAL_DEREFERENCE
 Straightforward dereference operator. More...
 
#define APF_ITERATOR_RANDOMACCESS_ARROW   APF_ITERATOR_BIDIRECTIONAL_ARROW
 Straightforward arrow operator. More...
 
#define APF_ITERATOR_RANDOMACCESS_PREINCREMENT   APF_ITERATOR_BIDIRECTIONAL_PREINCREMENT
 Straightforward preincrement operator. More...
 
#define APF_ITERATOR_RANDOMACCESS_PREDECREMENT   APF_ITERATOR_BIDIRECTIONAL_PREDECREMENT
 Straightforward predecrement operator. More...
 
#define APF_ITERATOR_RANDOMACCESS_ADDITION_ASSIGNMENT(base_member)
 Straightforward addition/assignment operator. More...
 
#define APF_ITERATOR_RANDOMACCESS_DIFFERENCE(base_member)
 Straightforward difference operator. More...
 
#define APF_ITERATOR_RANDOMACCESS_SUBSCRIPT
 Straightforward subscript operator (using + and dereference operator). More...
 
#define APF_ITERATOR_RANDOMACCESS_LESS(base_member)
 Straightforward less-than operator. More...
 
#define APF_ITERATOR_RANDOMACCESS_UNEQUAL   APF_ITERATOR_BIDIRECTIONAL_UNEQUAL
 Unequality operator (using equality operator). More...
 
#define APF_ITERATOR_RANDOMACCESS_OTHER_COMPARISONS
 Other comparisons (>, <=, >=). More...
 
#define APF_ITERATOR_RANDOMACCESS_POSTINCREMENT   APF_ITERATOR_BIDIRECTIONAL_POSTINCREMENT
 Postincrement operator (using preincrement operator). More...
 
#define APF_ITERATOR_RANDOMACCESS_POSTDECREMENT   APF_ITERATOR_BIDIRECTIONAL_POSTDECREMENT
 Postdecrement operator (using predecrement operator) More...
 
#define APF_ITERATOR_RANDOMACCESS_THE_REST
 The rest of the random access iterator requirements. More...
 

Detailed Description

Some macros to avoid code duplication in iterator (adaptor) classes.

For most of the macros you need special typedefs in your iterator class: self, reference, pointer, difference_type, ...

The assignment operator isn't provided here because normally the auto-generated assignment operator can be used.

Note
A default constructor is a requirement for every iterator. If you implement a special constructor, you also have to implement a default constructor!
See also
Iterators

Macro Definition Documentation

◆ APF_ITERATOR_CONSTRUCTORS

#define APF_ITERATOR_CONSTRUCTORS (   iterator_name,
  base_iterator_type,
  base_member 
)
Value:
\
explicit iterator_name(base_iterator_type base_iterator) \
: base_member(base_iterator) {} \ \
iterator_name() : base_member() {}

Straightforward default constructor and constructor from base iterator.

Parameters
iterator_nameName of the iterator class
base_iterator_typeTypename of the base iterator
base_memberName of the member variable holding the base iterator.

Definition at line 78 of file iterator.h.

◆ APF_ITERATOR_BASE

#define APF_ITERATOR_BASE (   base_iterator_type,
  base_member 
)
Value:
\
base_iterator_type base() const { assert(apf::no_nullptr(base_member)); \
return (base_member); }
bool no_nullptr(T *in)
Check for null-pointer.
Definition: iterator.h:64

Get the base iterator.

Parameters
base_iterator_typeTypename of the base iterator
base_memberName of the member variable holding the base iterator.

Definition at line 89 of file iterator.h.

◆ APF_ITERATOR_OUTPUT_DEREFERENCE

#define APF_ITERATOR_OUTPUT_DEREFERENCE (   base_member)
Value:
\
reference operator*() const { assert(apf::no_nullptr(base_member)); \
return *(base_member); }

Straightforward dereference operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 99 of file iterator.h.

◆ APF_ITERATOR_OUTPUT_PREINCREMENT

#define APF_ITERATOR_OUTPUT_PREINCREMENT (   base_member)
Value:
\
self& operator++() { assert(apf::no_nullptr(base_member)); \
++(base_member); return *this; }

Straightforward preincrement operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 107 of file iterator.h.

◆ APF_ITERATOR_OUTPUT_POSTINCREMENT

#define APF_ITERATOR_OUTPUT_POSTINCREMENT
Value:
\
self operator++(int) { self tmp = *this; ++(*this); return tmp; }

Postincrement operator (using preincrement operator).

Definition at line 114 of file iterator.h.

◆ APF_ITERATOR_INPUT_DEREFERENCE

#define APF_ITERATOR_INPUT_DEREFERENCE   APF_ITERATOR_OUTPUT_DEREFERENCE

Straightforward dereference operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 123 of file iterator.h.

◆ APF_ITERATOR_INPUT_ARROW

#define APF_ITERATOR_INPUT_ARROW (   base_member)
Value:
\
pointer operator->() const { assert(apf::no_nullptr(base_member)); \
return (base_member); }

Straightforward arrow operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 128 of file iterator.h.

◆ APF_ITERATOR_INPUT_EQUAL

#define APF_ITERATOR_INPUT_EQUAL (   base_member)
Value:
\
bool operator==(const self& rhs) const { \
return ((base_member) == (rhs.base_member)); }

Straightforward equality operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 136 of file iterator.h.

◆ APF_ITERATOR_INPUT_PREINCREMENT

#define APF_ITERATOR_INPUT_PREINCREMENT   APF_ITERATOR_OUTPUT_PREINCREMENT

Straightforward preincrement operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 144 of file iterator.h.

◆ APF_ITERATOR_INPUT_POSTINCREMENT

#define APF_ITERATOR_INPUT_POSTINCREMENT   APF_ITERATOR_OUTPUT_POSTINCREMENT

Postincrement operator (using preincrement operator).

Definition at line 148 of file iterator.h.

◆ APF_ITERATOR_INPUT_UNEQUAL

#define APF_ITERATOR_INPUT_UNEQUAL
Value:
\
bool operator!=(const self& rhs) const { return !operator==(rhs); } \

Unequality operator (using equality operator)

Definition at line 152 of file iterator.h.

◆ APF_ITERATOR_FORWARD_EQUAL

#define APF_ITERATOR_FORWARD_EQUAL   APF_ITERATOR_INPUT_EQUAL

Straightforward equality operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 161 of file iterator.h.

◆ APF_ITERATOR_FORWARD_DEREFERENCE

#define APF_ITERATOR_FORWARD_DEREFERENCE   APF_ITERATOR_INPUT_DEREFERENCE

Straightforward dereference operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 165 of file iterator.h.

◆ APF_ITERATOR_FORWARD_ARROW

#define APF_ITERATOR_FORWARD_ARROW   APF_ITERATOR_INPUT_ARROW

Straightforward arrow operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 169 of file iterator.h.

◆ APF_ITERATOR_FORWARD_PREINCREMENT

#define APF_ITERATOR_FORWARD_PREINCREMENT   APF_ITERATOR_INPUT_PREINCREMENT

Straightforward preincrement operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 173 of file iterator.h.

◆ APF_ITERATOR_FORWARD_POSTINCREMENT

#define APF_ITERATOR_FORWARD_POSTINCREMENT   APF_ITERATOR_INPUT_POSTINCREMENT

Postincrement operator (using preincrement operator).

Definition at line 177 of file iterator.h.

◆ APF_ITERATOR_FORWARD_UNEQUAL

#define APF_ITERATOR_FORWARD_UNEQUAL   APF_ITERATOR_INPUT_UNEQUAL

Unequality operator (using equality operator).

Definition at line 180 of file iterator.h.

◆ APF_ITERATOR_BIDIRECTIONAL_EQUAL

#define APF_ITERATOR_BIDIRECTIONAL_EQUAL   APF_ITERATOR_FORWARD_EQUAL

Straightforward equality operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 187 of file iterator.h.

◆ APF_ITERATOR_BIDIRECTIONAL_DEREFERENCE

#define APF_ITERATOR_BIDIRECTIONAL_DEREFERENCE   APF_ITERATOR_FORWARD_DEREFERENCE

Straightforward dereference operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 191 of file iterator.h.

◆ APF_ITERATOR_BIDIRECTIONAL_ARROW

#define APF_ITERATOR_BIDIRECTIONAL_ARROW   APF_ITERATOR_FORWARD_ARROW

Straightforward arrow operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 195 of file iterator.h.

◆ APF_ITERATOR_BIDIRECTIONAL_PREINCREMENT

#define APF_ITERATOR_BIDIRECTIONAL_PREINCREMENT   APF_ITERATOR_FORWARD_PREINCREMENT

Straightforward preincrement operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 199 of file iterator.h.

◆ APF_ITERATOR_BIDIRECTIONAL_PREDECREMENT

#define APF_ITERATOR_BIDIRECTIONAL_PREDECREMENT (   base_member)
Value:
\
self& operator--() { assert(apf::no_nullptr(base_member)); \
--(base_member); return *this; }

Straightforward predecrement operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 204 of file iterator.h.

◆ APF_ITERATOR_BIDIRECTIONAL_POSTINCREMENT

#define APF_ITERATOR_BIDIRECTIONAL_POSTINCREMENT   APF_ITERATOR_FORWARD_POSTINCREMENT

Postincrement operator (using preincrement operator).

Definition at line 211 of file iterator.h.

◆ APF_ITERATOR_BIDIRECTIONAL_UNEQUAL

#define APF_ITERATOR_BIDIRECTIONAL_UNEQUAL   APF_ITERATOR_FORWARD_UNEQUAL

Unequality operator (using equality operator).

Definition at line 214 of file iterator.h.

◆ APF_ITERATOR_BIDIRECTIONAL_POSTDECREMENT

#define APF_ITERATOR_BIDIRECTIONAL_POSTDECREMENT
Value:
\
self operator--(int) { self tmp = *this; --(*this); return tmp; }

Postdecrement operator (using predecrement operator).

Definition at line 218 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_EQUAL

#define APF_ITERATOR_RANDOMACCESS_EQUAL   APF_ITERATOR_BIDIRECTIONAL_EQUAL

Straightforward equality operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 227 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_DEREFERENCE

#define APF_ITERATOR_RANDOMACCESS_DEREFERENCE   APF_ITERATOR_BIDIRECTIONAL_DEREFERENCE

Straightforward dereference operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 231 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_ARROW

#define APF_ITERATOR_RANDOMACCESS_ARROW   APF_ITERATOR_BIDIRECTIONAL_ARROW

Straightforward arrow operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 235 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_PREINCREMENT

#define APF_ITERATOR_RANDOMACCESS_PREINCREMENT   APF_ITERATOR_BIDIRECTIONAL_PREINCREMENT

Straightforward preincrement operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 239 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_PREDECREMENT

#define APF_ITERATOR_RANDOMACCESS_PREDECREMENT   APF_ITERATOR_BIDIRECTIONAL_PREDECREMENT

Straightforward predecrement operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 243 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_ADDITION_ASSIGNMENT

#define APF_ITERATOR_RANDOMACCESS_ADDITION_ASSIGNMENT (   base_member)
Value:
\
self& operator+=(difference_type n) { \
assert(!n || apf::no_nullptr(base_member)); \
(base_member) += n; return *this; }

Straightforward addition/assignment operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 248 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_DIFFERENCE

#define APF_ITERATOR_RANDOMACCESS_DIFFERENCE (   base_member)
Value:
\
friend difference_type operator-(const self& lhs, const self& rhs) { \
assert(apf::no_nullptr(lhs.base_member) \
&& apf::no_nullptr(rhs.base_member)); \
return ((lhs.base_member) - (rhs.base_member)); }

Straightforward difference operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 257 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_SUBSCRIPT

#define APF_ITERATOR_RANDOMACCESS_SUBSCRIPT
Value:
\
reference operator[](difference_type n) const { \
return *(*this + n); }

Straightforward subscript operator (using + and dereference operator).

Definition at line 266 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_LESS

#define APF_ITERATOR_RANDOMACCESS_LESS (   base_member)
Value:
\
friend bool operator<(const self& lhs, const self& rhs) { \
assert(apf::no_nullptr(lhs.base_member) \
&& apf::no_nullptr(rhs.base_member)); \
return (lhs.base_member) < (rhs.base_member); }

Straightforward less-than operator.

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 274 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_UNEQUAL

#define APF_ITERATOR_RANDOMACCESS_UNEQUAL   APF_ITERATOR_BIDIRECTIONAL_UNEQUAL

Unequality operator (using equality operator).

Parameters
base_memberName of the member variable holding the base iterator.

Definition at line 284 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_OTHER_COMPARISONS

#define APF_ITERATOR_RANDOMACCESS_OTHER_COMPARISONS
Value:
\
friend bool operator>(const self& lhs, const self& rhs) \
{ return rhs < lhs; } \ \
friend bool operator<=(const self& lhs, const self& rhs) \
{ return !(rhs < lhs); } \\
friend bool operator>=(const self& lhs, const self& rhs) \
{ return !(lhs < rhs); }

Other comparisons (>, <=, >=).

All are using the less-than operator.

Definition at line 289 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_POSTINCREMENT

#define APF_ITERATOR_RANDOMACCESS_POSTINCREMENT   APF_ITERATOR_BIDIRECTIONAL_POSTINCREMENT

Postincrement operator (using preincrement operator).

Definition at line 302 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_POSTDECREMENT

#define APF_ITERATOR_RANDOMACCESS_POSTDECREMENT   APF_ITERATOR_BIDIRECTIONAL_POSTDECREMENT

Postdecrement operator (using predecrement operator)

Definition at line 306 of file iterator.h.

◆ APF_ITERATOR_RANDOMACCESS_THE_REST

#define APF_ITERATOR_RANDOMACCESS_THE_REST
Value:
\
self operator+(difference_type n) const { self tmp(*this); return tmp += n; }\ \
friend self operator+(difference_type n, const self& it) { \
self temp(it); return temp += n; } \ \
self& operator-=(difference_type n) { *this += -n; return *this; } \ \
self operator-(difference_type n) const { self tmp(*this); return tmp += -n; }

The rest of the random access iterator requirements.

  • Addition operator (iterator plus integer, using +=)
  • Addition operator (integer plus iterator, using +=)
  • Subtraction/assignment operator (using +=)
  • Subtraction operator (using +=)

Definition at line 314 of file iterator.h.