[PREPROCESSOR]:New sequence handler

Hello, sorry if I will be wrong, I am new to boost. As far as I know, BOOST_PP_SEQ_FOR_EACH_I works only with 256 elements, well, I've wrote macro that works with unlimited (256, 512, well it may be limited by some compilers options, like string length, maybe) number of elements (while testing I'vnt met bugs...). But if You're interested in, I can email the code (here?). P.S.: Also, there is some difference: #define ENUM_SWITCH_CASE(x) case x: return #x; #define ENUMR(x) x, #define ENUM(E, x) \ enum E { NEWL(ENUMR,x) }; \ inline const char *to_string(day_t e)\ {\ switch(e)\ {\ NEWL(ENUM_SWITCH_CASE, x)\ };\ }; #define ENUMRSEQQ1_END #define ENUM_SWITCH_CASESEQQ1_END #define ENUM_SWITCH_CASE_ENDET default: return "<invalid>"; ENUM(day_t,(Monday)(Tuesday)(Wednesday)(Thursday)(Friday)(Saturday)(Sunday)) There is 3 defines in the end, NEWL (my macro) - make's the code with 2 constants in the end ( (a)(b)(c) -> a,b,c, C1 C2 ), so first define eliminates one unneeded constant (one will be used for enum ending), second and third defines does almost the same, but ENDET used for making default case in switch. P.P.S: And another difference is that name of one of the constants in the end variyng from the number of the elements in sequence. (Maybe one of the constants can be removed...)

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Alex Mekhed
Hello, sorry if I will be wrong, I am new to boost. As far as I know, BOOST_PP_SEQ_FOR_EACH_I works only with 256
The primary reason that SEQ_FOR_EACH_I only works for up to 256 elements is that it passes the element index to the user-defined macro... BOOST_PP_SEQ_FOR_EACH_I(macro, data, (a)(b)(c)) macro(r, data, 0, a) macro(r, data, 1, b) macro(r, data, 2, c) ^ ^ ^ ...and the library cannot count higher than 256. The seconary reason that SEQ_FOR_EACH_I only works for a limited number of elements is that it is difficult to get access to the user-defined macro during the sequential iteration. That is, it isn't hard to enumerate through any number of elements; it's another thing altogether to call a macro for each element. Now, I said it is difficult. It is possible (Chaos does it), but you have to rely a great deal on the timing of expansion order--which is nearly impossible to support on the preprocessors of some prominent compilers that Boost must support. Regards, Paul Mensonides
participants (2)
-
Alex Mekhed
-
Paul Mensonides