]> git.ozlabs.org Git - ccan/commit
cppmagic: Iteration
authorDavid Gibson <david@gibson.dropbear.id.au>
Tue, 26 Jan 2016 10:54:47 +0000 (21:54 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Wed, 3 Feb 2016 22:44:13 +0000 (09:44 +1100)
commit0ca50da908dcc8f97af4145a9afce714cd6b225d
treebd6de61b299e46e0fbce9b0e0ed5a5ad810b18b3
parent7ddee86d9ac424dbec04583e37e9584375bd6d74
cppmagic: Iteration

This implements macros which iterate across their arguments.  This is
implemented in terms of (kinda sorta) recursion.  In fact, they will stop
working with enough arguments, but the limit is large and can be easily
increased by changing the depth of the CPPMAGIC_EVAL() macro.

There are 3 iterators (for now):
  CPPMAGIC_MAP
    applies another macro to each of its remaining arguments - the results
    are comma separated, so they can be passed into another CPPMAGIC_MAP
    invocation.
  CPPMAGIC_2MAP
    does the same thing, but takes the arguments a pair at a time, using
    a supplied two-argument macro.
  CPPMAGIC_JOIN
    combines the arguments with a chosen delimiter (effectively replacing
the commas between the arguments with the delimiter)
same thing, but takes the arguments a pair at a time.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/cppmagic/cppmagic.h
ccan/cppmagic/test/run.c