
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Paul Mensonides
I have the following sequence
#define SEQ (a)(b)(c)(d)
I want to transform it to something like this
F(a,b) F(b,c) F(c,d)
How can I do it efficiently and elegantly?
Thank you in advance.
Is F a macro?
In the mean time, the following should get you started... #include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/control/iif.hpp> #include <boost/preprocessor/tuple/eat.hpp> #define A(seq) B(BOOST_PP_CAT(X0 seq, 0)) #define B(sf) C(BOOST_PP_CAT(Y1 sf, 0)) #define C(sf) Z0 sf #define X0(x) (x) X1 #define X1(x) (1)(x) X2 #define X2(x) (1)(x) X1 #define X10 (0) #define X20 (0) #define Y1(x) (x, Y2 #define Y2(y) y) Y1 #define Y10 #define Y20 #define Z0(x, bit) (x Z1 #define Z1(x, bit) , x) BOOST_PP_IIF(bit, ZX, BOOST_PP_TUPLE_EAT(2))(x, Z2) #define Z2(x, bit) , x) BOOST_PP_IIF(bit, ZX, BOOST_PP_TUPLE_EAT(2))(x, Z1) #define ZX(x, next) (x next #define SEQ \ (a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m) \ (n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z) \ /**/ A(SEQ) Regards, Paul Mensonides