|
Boost : |
From: Alex Mekhed (alexmekhed_at_[hidden])
Date: 2005-11-05 06:24:47
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...)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk