[Sent via gmane but it never appeared]
Hi gang,
Suppose I have a number of types that each have a
"value" enum, much like MPL's constant classes.
Now suppose that I want to construct a
runtime-indexable array of those values,
according to the position of each type in an
MPL vector.
For example:
int values[3];
typedef boost::mpl::vector_c values;
typedef some_magic_metafunction<values>::type runtime_function;
// values[0] = 10, values[1] = 11, values[2] = 12
runtime_function::fill_array(values);
The idea is that some_magic_metafunction<values> would
generate a type kind of like this:
template
struct magic {
static void fill_array(int *v) {
// Non-MPL type vector indexing -- could use an
// MPL iterator here
v[Index::value] = TypeValueListIndex::value::value;
if (Index::value < distance::type::value) {
magic::fill_array(v);
}
};
};
Get it? The problem is that I don't know how to make MPL
transition from strictly compile-time to something
in-between. It can statically know the size of the
value array and the values themselves but it has to
fill the array "values" at runtime so that the values may
be indexed by runtime computations.
Any guidance?
Thanks!
-Dave