Sat, 08 Jun 2024 20:08:09 +0200
add cxIteratorRef() macro
src/cx/iterator.h | file | annotate | diff | comparison | revisions |
1.1 --- a/src/cx/iterator.h Thu May 23 22:06:32 2024 +0200 1.2 +++ b/src/cx/iterator.h Sat Jun 08 20:08:09 2024 +0200 1.3 @@ -78,6 +78,7 @@ 1.4 1.5 /** 1.6 * Declares base attributes for an iterator. 1.7 + * Must be the first member of an iterator structure. 1.8 */ 1.9 #define CX_ITERATOR_BASE struct cx_iterator_base_s base 1.10 1.11 @@ -193,6 +194,15 @@ 1.12 #define cxIteratorFlagRemoval(iter) (iter).base.remove |= (iter).base.mutating 1.13 1.14 /** 1.15 + * Obtains a reference to an arbitrary iterator. 1.16 + * 1.17 + * This is useful for APIs that expect some iterator as an argument. 1.18 + * 1.19 + * @param iter the iterator 1.20 + */ 1.21 +#define cxIteratorRef(iter) &((iter).base) 1.22 + 1.23 +/** 1.24 * Loops over an iterator. 1.25 * @param type the type of the elements 1.26 * @param elem the name of the iteration variable