
31 Oct
2007
31 Oct
'07
3:42 p.m.
on Tue Oct 30 2007, Yu Di <diyu60607-AT-yahoo.com> wrote:
Hi, I am trying to use the preprocessor lib to generate something like
Cons<a, Cons<b, Cons<c, Cons<d, Nil> > > >
from
(a) (b) (c) (d)
The easy way to do things like this is to take advantage of the fact that the PP can generate invalid fragments of syntax, so something like: // not tested -- I may have the argument order wrong among other things #define cons_open(z, e, _) Cons<e, #define cons_close(z, e, _) > #define GENERATE(x) \ BOOST_PP_SEQ_FOR_EACH(cons_open, x, ~) Nil BOOST_PP_SEQ_FOR_EACH(cons_close,x,~) HTH, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com