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>
Showing
Please register or sign in to comment