Variadic to Head/Tail TMP List

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. Compiler tests: GCC 4.7 -> Compiler Error GCC 4.7.1 & Trunk -> OK http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53108 Clang Trunk -> OK MSVC 11 beta -> has no Variadic Templates Regards, FP.

on Wed Apr 25 2012, Fernando Pelliccioni <fpelliccioni-AT-gmail.com> wrote:
Hi,
Is this piece of code useful ?
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

On Thu, Apr 26, 2012 at 3:53 PM, Dave Abrahams <dave@boostpro.com> wrote:
on Wed Apr 25 2012, Fernando Pelliccioni <fpelliccioni-AT-gmail.com> wrote:
Hi,
Is this piece of code useful ?
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.
participants (2)
-
Dave Abrahams
-
Fernando Pelliccioni