add cxIteratorRef() macro

Sat, 08 Jun 2024 20:08:09 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 08 Jun 2024 20:08:09 +0200
changeset 858
d9ad7904c4c2
parent 857
4d12e34bb130
child 859
6367456bf2d9

add cxIteratorRef() macro

src/cx/iterator.h file | annotate | diff | comparison | revisions
--- a/src/cx/iterator.h	Thu May 23 22:06:32 2024 +0200
+++ b/src/cx/iterator.h	Sat Jun 08 20:08:09 2024 +0200
@@ -78,6 +78,7 @@
 
 /**
  * Declares base attributes for an iterator.
+ * Must be the first member of an iterator structure.
  */
 #define CX_ITERATOR_BASE struct cx_iterator_base_s base
 
@@ -193,6 +194,15 @@
 #define cxIteratorFlagRemoval(iter) (iter).base.remove |= (iter).base.mutating
 
 /**
+ * Obtains a reference to an arbitrary iterator.
+ *
+ * This is useful for APIs that expect some iterator as an argument.
+ *
+ * @param iter the iterator
+ */
+#define cxIteratorRef(iter) &((iter).base)
+
+/**
  * Loops over an iterator.
  * @param type the type of the elements
  * @param elem the name of the iteration variable

mercurial