Boost logo

Boost Users :

Subject: Re: [Boost-users] BOOST_PP_ERROR(0x0003, BOOST_PP_REPEAT_OVERFLOW) with multiply nested BOOST_PP_REPEATS
From: Colin Fowler (fowler_at_[hidden])
Date: 2014-09-26 12:24:27


To partially answer my own question.....

in repeat.hpp....
# define BOOST_PP_REPEAT_4(c, m, d) BOOST_PP_ERROR(0x0003)

ARGGH :/

Any ideas on how to work around this? I suppose I could try the old
modulus/divide trick to turn a for(X){for(Y}
loop into a for(x*y) loop, however I'd definitely need to break the 256
repeat limit many times so that's pretty much useless

Colin

On 26-09-2014 15:44, Colin Fowler wrote:
> I'm having a problem with multiple nested repeats. I need to generate
> int x_0_0_0_0 to int x_a_b_c_d. Attempting to do so results in a
> BOOST_PP_ERROR.
> For readability, a few shorter defines
>
> #define TUPLE_ELEM BOOST_PP_TUPLE_ELEM
> #define REPEAT BOOST_PP_REPEAT
>
> and I also neglect the necessary BOOST_PP_CAT statements in DECL4D in
> this example
>
> #define DECL4D(z, n, text) TUPLE_ELEM(3, text) TUPLE_ELEM(0, text)
> TUPLE_ELEM(1, text) TUPLE_ELEM(2, text) n;
> #define DECL4C(z, n, text) REPEAT(TUPLE_ELEM(0, text), DECL4D,
> (TUPLE_ELEM(1, text), TUPLE_ELEM(2, text), n, TUPLE_ELEM(3, text)))
> #define DECL4B(z, n, text) REPEAT(TUPLE_ELEM(0, text), DECL4C,
> (TUPLE_ELEM(1, text), TUPLE_ELEM(2, text), n, TUPLE_ELEM(3, text)))
> #define DECL4A(z, n, text) REPEAT(TUPLE_ELEM(0, text), DECL4B,
> (TUPLE_ELEM(1, text), TUPLE_ELEM(2, text), n, TUPLE_ELEM(3, text)))
> #define decl4(a, b, c, d, text) REPEAT(a, DECL4A, (b, c, d, text))
>
> decl4(1, 1, 1, 1, int x_)
>
> Am I hitting a nesting depth limit or something else? Is there a way
> around this? Ideally I want to write a decl5 macro and have
> successfully written a decl1, decl2 and decl3 so far
>
> Regards,
> Colin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net