metafunction to 'rangify'
Hi, struct inputs { double input1; int input2; bool input3; }; Given type 'inputs', how to I write a metafunction that can return to me this type: rangify<inputs>::type identical to struct inputs_rangified { union { double fixed; boost::tuple<double, double, double> range; } input1; // range is min, max, increment union { int fixed; boost::tuple <int, int, int> range; } input2; union { bool fixed; std::pair<bool, bool> range; } input3; std::bitset<3> is_range; }; 1. Is it possible to get the number of members of a struct at compile-time? 2. What would be the easiest way to fill inputs_rangified from an input stream? Typically, my application will have hundreds different 'inputs' types and I would like to automate this process. Regards,
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Mathias Gaunard Sent: 18 December 2009 22:51 To: boost-users@lists.boost.org Subject: Re: [Boost-users] metafunction to 'rangify'
Hicham Mouline wrote:
1. Is it possible to get the number of members of a struct at compile- time?
No. How about if I explicitly set a const static size_t number_of_members = ...; inside inputs?
would then the previously mentioned desired outcome be possible with Boost.fusion? Regards,
participants (3)
-
Edward Diener
-
Hicham Mouline
-
Mathias Gaunard