|
Boost Users : |
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2006-08-28 17:36:58
> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net