
Hi all, Is BOOST_PP_SEQ_ENUM broken? I can't use it with VC71. It expands to something like: BOOST_PP_SEQ_ENUM_3[space](x)(y)(z) and stops here, probably because of the space. Shouldn't the current definition: # define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, BOOST_PP_SEQ_SIZE(seq)) seq be replaced with something like: #define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_SEQ_CAT((BOOST_PP_SEQ_ENUM_)(BOOST_PP_SEQ_SIZE(seq))(seq)) Regards, Arkadiy

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Arkadiy Vertleyb
Is BOOST_PP_SEQ_ENUM broken?
No, but VC is. :)
I can't use it with VC71.
It works on VC6, VC7, and VC7.1 on my system. E.g. #include <boost/preprocessor/seq/enum.hpp> BOOST_PP_SEQ_ENUM((x)(y)(z)) // x, y, z
It expands to something like:
BOOST_PP_SEQ_ENUM_3[space](x)(y)(z)
and stops here, probably because of the space.
How are you deriving the sequence that you pass to SEQ_ENUM?
Shouldn't the current definition:
# define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, BOOST_PP_SEQ_SIZE(seq)) seq
be replaced with something like:
#define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_SEQ_CAT((BOOST_PP_SEQ_ENUM_)(BOOST_PP_SEQ_SIZE(seq))(seq))
No, the two should be equivalent. I suspect that you've ran afoul of VC's serious expansion order problems. I.e. the sequence that is passed is created by other macros that VC hasn't expanded yet (but should have), so when it gets to BOOST_PP_SEQ_ENUM_3, it looks some like this: BOOST_PP_SEQ_ENUM_3 MACRO() It then doesn't expand SEQ_ENUM_3, but does expand MACRO. In other words, the problem is likely something that has nothing to do with SEQ_ENUM, but is a problem elsewhere. In any case, the library strives to try to protect users from this VC problem, but it cannot do it in total because the problem ties implementation details from macro to macro (i.e. it is an encapsulation nightmare). The first attempt to "fix" it in this situation would be to say (for VC only): #include <boost/preprocessor/seq/enum.hpp> #undef BOOST_PP_SEQ_ENUM #define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_SEQ_ENUM_I((seq)) #define BOOST_PP_SEQ_ENUM_I(arg) BOOST_PP_SEQ_ENUM_II ## arg #define BOOST_PP_SEQ_ENUM_II(seq) \ BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, BOOST_PP_SEQ_SIZE(seq)) seq \ /**/ If you do this, does it work correctly? (BTW, I realize that the concatenation is undefined behavior.) Regards, Paul Mensonides

"Arkadiy Vertleyb" <vertleyb@hotmail.com> wrote in message news:ct5vq1$i7v$1@sea.gmane.org...
Hi all,
Is BOOST_PP_SEQ_ENUM broken? I can't use it with VC71. It expands to something like:
BOOST_PP_SEQ_ENUM_3[space](x)(y)(z)
and stops here, probably because of the space.
Please disregard this -- it's definitely not a space problem. There appears to be something wrong with my usage of it -- sometimes it works, and sometimes it doesn't. Something like this doesn't work as I would expect: cout << BOOST_PP_STRINGIZE(BOOST_PP_SEQ_ENUM((x)(y)(z))); But in other contexts it seems to work fine. Also, if I replace BOOST_PP_SEQ_ENUM with the following: #define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, BOOST_PP_SEQ_SIZE(seq)), seq) The output is "x, y, z" as expected. Regards, Arkadiy

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Arkadiy Vertleyb
BOOST_PP_SEQ_ENUM_3[space](x)(y)(z)
and stops here, probably because of the space.
Please disregard this -- it's definitely not a space problem. There appears to be something wrong with my usage of it -- sometimes it works, and sometimes it doesn't. Something like this doesn't work as I would expect:
cout << BOOST_PP_STRINGIZE(BOOST_PP_SEQ_ENUM((x)(y)(z)));
That shouldn't work regardless. An invocation of SEQ_ENUM with anything other than one element becomes (what I call) an intermediate. An "intermediate" is an argument to a macro that expands to multiple arguments. There is no way that STRINGIZE could be defined to handle an intermediate. E.g. #define STRINGIZE(x) PRIMITIVE_STRINGIZE(x) #define PRIMITIVE_STRINGIZE(x) #x The delay is necessary to allow 'x' to expand on input to STRINGIZE. However, because it does expand in this case, it tries to invoke: PRIMITIVE_STRINGIZE(x, y, z) ...which is, of course, too many arguments.
But in other contexts it seems to work fine.
Also, if I replace BOOST_PP_SEQ_ENUM with the following:
#define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, BOOST_PP_SEQ_SIZE(seq)), seq)
The output is "x, y, z" as expected.
Did you try the other workaround that I sent? The problem with the above is that it is picking up expansions that should have happened already (but haven't due to VC's bug-ridden implementation). The problem is that the above creates a dependency between CAT and whatever expansion might be picked up. Regards, Paul Mensonides

"Paul Mensonides" <pmenso57@comcast.net> wrote in message
cout << BOOST_PP_STRINGIZE(BOOST_PP_SEQ_ENUM((x)(y)(z)));
That shouldn't work regardless. An invocation of SEQ_ENUM with anything other than one element becomes (what I call) an intermediate. An "intermediate" is an argument to a macro that expands to multiple arguments. There is no way that STRINGIZE could be defined to handle an intermediate. E.g.
#define STRINGIZE(x) PRIMITIVE_STRINGIZE(x) #define PRIMITIVE_STRINGIZE(x) #x
The delay is necessary to allow 'x' to expand on input to STRINGIZE. However, because it does expand in this case, it tries to invoke:
PRIMITIVE_STRINGIZE(x, y, z)
...which is, of course, too many arguments.
What about some extra parenthesis: cout << BOOST_PP_STRINGIZE((BOOST_PP_SEQ_ENUM((x)(y)(z)))); //?
Did you try the other workaround that I sent?
#undef BOOST_PP_SEQ_ENUM #define BOOST_PP_SEQ_ENUM(seq) BOOST_PP_SEQ_ENUM_I((seq)) #define BOOST_PP_SEQ_ENUM_I(arg) BOOST_PP_SEQ_ENUM_II ## arg #define BOOST_PP_SEQ_ENUM_II(seq) \ BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, BOOST_PP_SEQ_SIZE(seq)) seq \ /**/ It doesn't seem to work with stringize (see above). Outputs: (BOOST_PP_SEQ_ENUM_II((x)(y)(z))) Without stringize everything seems to work fine in the first place... I only care about stringize because it seemed to be a convenient way to debug the stuff... Regards, Arkadiy

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Arkadiy Vertleyb
What about some extra parenthesis:
cout << BOOST_PP_STRINGIZE((BOOST_PP_SEQ_ENUM((x)(y)(z)))); //?
That should work fine, but doesn't--stringize.hpp now patched in the CVS. Regards, Paul Mensonides
participants (2)
-
Arkadiy Vertleyb
-
Paul Mensonides