boost::multi_array equivalent for runtime number of dimensions
Hello, I only know at runtime the dimension and extends of a multidimensional array, though the number of dimensions is always < 10 for e.g. Is there a container that allows this? Otherwise, I can write code for multi_array<T, 2> multi_array<T, 3> . multi_array<T, 10>, do a switch case on the dimensions variable, and select the appropriate code, regards,
I only know at runtime the dimension and extends of a multidimensional array, though the number of dimensions is always < 10 for e.g.
Is there a container that allows this?
OvermindDL1 proposed to use boost.variant in thread called "question about multi_array use" (see there for a more complete code). for example: typedef boost::variant <multi_array<int, 2> ,multi_array<int, 3> ,multi_array<int, 4> ,multi_array<int, 5> ,multi_array<int, 6> ,multi_array<int, 7> ,multi_array<int, 8> > multi_array_variant_t; and he says that using boost.fusion will be even better. I didn't try it, but I would like to know if the solution really works well. Alfredo.
On Thu, Jan 7, 2010 at 11:48 AM, alfC <alfredo.correa@gmail.com> wrote:
I only know at runtime the dimension and extends of a multidimensional array, though the number of dimensions is always < 10 for e.g.
Is there a container that allows this?
OvermindDL1 proposed to use boost.variant in thread called "question about multi_array use" (see there for a more complete code). for example: typedef boost::variant <multi_array<int, 2> ,multi_array<int, 3> ,multi_array<int, 4> ,multi_array<int, 5> ,multi_array<int, 6> ,multi_array<int, 7> ,multi_array<int, 8> > multi_array_variant_t;
and he says that using boost.fusion will be even better. I didn't try it, but I would like to know if the solution really works well.
I have been using Boost.Fusion, I cannot recommend it enough, I have completely decoupled the sizes of things from what operates on them.
participants (3)
-
alfC
-
Hicham Mouline
-
OvermindDL1