#include <iostream>
#include <boost/fusion/include/adapted.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/include/transform.hpp>
#include <boost/fusion/include/as_vector.hpp>
#include <boost/fusion/include/size.hpp>
#include <boost/variant/variant.hpp>
struct params {
double d1;
double d2;
double d3;
unsigned int i4;
unsigned int i5;
unsigned int i6;
unsigned int i7;
};
BOOST_FUSION_ADAPT_STRUCT(
params,
(double, d1)
(double, d2)
(double, d3)
(unsigned int, i4)
(unsigned int, i5)
(unsigned int, i6)
(unsigned int, i7)
)
template <typename T1>
struct range {
T1 min;
T1 max;
T1 inc;
};
template <typename T>
struct fixed_or_range {
typedef boost::variant<T, range<T> > type;
};
struct make_fixed_or_range
{
template<typename Sig> struct result;
template<typename Self, typename Arg>
struct result<Self(Arg)>
{
typedef typename fixed_or_range<Arg>::type type;
};
template<class Arg>
typename result<make_fixed_or_range(Arg)>::type
operator()(Arg);
};
typedef boost::fusion::result_of::as_vector<
boost::fusion::result_of::transform<
params,
make_fixed_or_range
>::type
>::type params_fixed_or_range;
int main()
{
...
params_fixed_or_range pfr; // now contains a sequence of fixed values or ranges
}