|
Boost : |
Subject: Re: [boost] Variadic to Head/Tail TMP List
From: Fernando Pelliccioni (fpelliccioni_at_[hidden])
Date: 2012-04-27 08:46:24
On Thu, Apr 26, 2012 at 3:53 PM, Dave Abrahams <dave_at_[hidden]> wrote:
>
> on Wed Apr 25 2012, Fernando Pelliccioni <fpelliccioni-AT-gmail.com> wrote:
>
> > Hi,
> >
> > Is this piece of code useful ?
> >
> > http://pastebin.com/tRrqVHTw
> >
> > The purpose is to tranform code like the following:
> >
> > typedef cons<int, cons<float, cons<char, cons<string>>>> t0;
> > // fusion::cons or similar data structures
> >
> > in
> >
> > typedef chain_generator<cons, nil> cons_gen;
> > typedef cons_gen::gen<int, float, char, std::string>::type t1;
> >
> > I don't know if there is something similar in a library.
> > I think it could be useful.
>
> Quite possibly. What prompted you to write it?
>
> --
> Dave Abrahams
> BoostPro Computing
> http://www.boostpro.com
>
>
I was playing with the Roshan Naik's Castor library (Logic Programming). I
saw an example that used a similar Head/Tail data structure.
I thought it would be easier to write it this way (without using Macros).
Also... as an exercise for variadic templates, beyond the typical
recursive template function example.
Not so easy to implement variadics in class templates. I had to use some
ugly tricks. I wish I could delete the dummy template parameter.
I thought maybe something like this could be useful in libraries such as
MPL or Fusion.
Thanks and Regards,
Fernando.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk