[preprocessor] sequence->initializer

Hello, support I have some Boost.Preprocessor data structure, say a sequence: #define SEQ ("1")("2")("3") how can I convert it into initalizer {"1", "2", "3"}? E.g: #define MY_TEST(SEQ) char* var = { SOMEHOW_GET_LIST_OF_VALUES(SEQ) } I've tried to look at preprocessor docs, but it's rather hard to find the answer. TIA, Volodya

Vladimir Prus <ghost@cs.msu.su> writes:
Hello, support I have some Boost.Preprocessor data structure, say a sequence:
#define SEQ ("1")("2")("3")
how can I convert it into initalizer {"1", "2", "3"}? E.g:
#define MY_TEST(SEQ) char* var = { SOMEHOW_GET_LIST_OF_VALUES(SEQ) }
I've tried to look at preprocessor docs, but it's rather hard to find the answer.
Yeah, they are hard to read. Why not look at the PP appendix of "C++ Template Metaprogramming"? http://www.boost-consulting.com/mplbook -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

David Abrahams wrote:
Vladimir Prus <ghost@cs.msu.su> writes:
Hello, support I have some Boost.Preprocessor data structure, say a sequence:
#define SEQ ("1")("2")("3")
how can I convert it into initalizer {"1", "2", "3"}? E.g:
#define MY_TEST(SEQ) char* var = { SOMEHOW_GET_LIST_OF_VALUES(SEQ) }
I've tried to look at preprocessor docs, but it's rather hard to find the answer.
Yeah, they are hard to read. Why not look at the PP appendix of "C++ Template Metaprogramming"? http://www.boost-consulting.com/mplbook
Ah. one of the sample chapters is specifically about preprocessor. Thanks, I've just found BOOST_PP_SEQ_ENUM there. - Volodya

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Vladimir Prus
Hello, support I have some Boost.Preprocessor data structure, say a sequence:
#define SEQ ("1")("2")("3")
how can I convert it into initalizer {"1", "2", "3"}? E.g:
#define MY_TEST(SEQ) char* var = { SOMEHOW_GET_LIST_OF_VALUES(SEQ) }
BOOST_PP_SEQ_ENUM converts a sequence to a comma-separated list. E.g. #include <boost/preprocessor/seq/enum.hpp> #define MY_TEST(seq) \ char* var[] = { BOOST_PP_SEQ_ENUM(seq) } \ /**/ #define SEQ ("1")("2")("3") MY_TEST(SEQ); // char* var[] = { "1", "2", "3" }; Regards, Paul Mensonides
participants (3)
-
David Abrahams
-
Paul Mensonides
-
Vladimir Prus