Boost's preprocessor library has a neat macro BOOST_PP_SEQ_CAT such that:
#define MY_SEQUENCE (a)(b)(c)
BOOST_PP_SEQ_CAT(MY_SEQUENCE)
becomes:
abc
In my answer for this question ( http://stackoverflow.com/a/35664207/159145 ) I gave a switch statement with many case sub-statements as a solution, but lamented the inability to define such a switch block via preprocessor macro or variadic template.
I did some more research and found that BOOST_PP_SEQ_CAT (defined here: https://github.com/boostorg/preprocessor/blob/develop/include/boost/preprocessor/seq/cat.hpp) ultimately performs concatenation here:
#define BOOST_PP_SEQ_CAT_O_I(a, b) a ## b
Could it be possible to then allow a macro'ized switch statement by modifying this macro?
#define BOOST_PP_SEQ_CAT_O_I(ARG_A, ARG_B) case: # ARG_A ## ARG_B
e.g.
switch(x) {
#define MY_SEQUENCE (1)(5)(7)
BOOST_PP_SEQ_CAT(MY_SEQUENCE)
retu true;
}
becomes:
switch(x) {
case 1: case 5: case 7:
retu true;
}
Problem is, I can't redefine BOOST_PP_SEQ_CAT because it's defined in Boost's own files, and modifying them doesn't seem like the right solution. Is there a way to define my own BOOST_PP_SEQ_CAT with the case: output without it being redefined by Boost?
