Boost logo

Boost Users :

Subject: [Boost-users] metafunction to 'rangify'
From: Hicham Mouline (hicham_at_[hidden])
Date: 2009-12-18 10:37:50


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

Typically, my application will have hundreds different 'inputs' types and I
would like to automate this process.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at