On 21-09-2014 17:51, Edward Diener wrote: <SNIP>
The BOOST_PP_REPEAT macro takes a single count, so you would need to pass into the macro a single repetition count while preserving the individual counts in some way for BOOST_PP_REPEAT. The only way you could do this is by having the 'data' field of BOOST_PP_REPEAT be more complicated, ie. by having the 'data' field include both your 'text' and the individual count numbers. When you need a single input to include complicated data you should look at how to work with Boost PP arrays, lists, tuples, and/or seqs; all of which let you incorporate a number of pieces of data in a single input.
So given:
decl2 ( int x, 5, 2 )
and using a Boost PP tuple,
you want to pass to initially pass to BOOST_PP_REPEAT something like (10, DECL2, (text,(5,2))) and then you can work out how to generate your output for each of the 10 repetitions of DECL2.
You can recursively call BOOST_PP_REPEAT from within BOOST_PP_REPEAT processing, and while it is advantageous to use the BOOST_PP_REPEAT_z form it is not necessary.
I hope this helps you to figure out how to do what you want.
Hi Edward, that was very helpful, thank you! I had tried using tuples
yesterday but couldn't get the syntax right. I've come up with the
following that's very close to doing exactly what I want (I need to
fiddle around the ordering of the output a bit).
#include