Boost logo

Boost Users :

Subject: [Boost-users] [tuple][fusion] Creating tuple type from function type
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2009-04-23 11:54:10


I would like to take a given function type and create a (Fusion or Boost)
tuple with its parameter types as members. This would be straightforward
to do with function_types and Fusion, but I would also like to add a
separate tag to each tuple type. For example, I would like to do the
following:

struct tag1 {};
struct tag2 {};
typedef tagged_function_tuple<tag1, void(int, double)>::type t1;
typedef tagged_function_tuple<tag2, void(int, double)>::type t2;

and have t1 and t2 be distinct types, each equivalent to
fusion::vector<int, double> (or some kind of tuple<int, vector>). In
particular, I would like to use the nice constructor syntax to allow
things like t1(1, 2.5) to work, with as nice error messages as possible
when incorrect argument counts or types are used. I would also like to
"hide" the tags in the type, so just creating fusion::vector<tag1, int,
double> would not be ideal. Is there a way to do this? Otherwise, I
assume I can copy-and-paste the code for fusion::tuple and modify it to
add a tag. Is that the recommended way? Thank you for your help.

-- Jeremiah Willcock


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