Boost logo

Boost Users :

From: Yu Di (diyu60607_at_[hidden])
Date: 2007-10-30 17:41:14


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)

I tried something like

#define START(x) Cons<x,Nil>
#define ADD(s,state,x) Cons<x,state >
#define GENERATE(x) BOOST_PP_SEQ_FOLD_RIGHT(ADD,START(BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_REVERSE(x))),BOOST_PP_SEQ_POP_BACK(x))

but immediately got into trouble with the commas. The best I can do is to add parentheses around the content of START and ADD, but that generated

(Cons<a, (Cons<b, (Cons<c, (Cons<d, Nil>) >) >) >)

which is not valid.

Is there any way I can achieve the desired output? Thanks,

Di, Yu
10.30

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com



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