Hi Joey,

I have looked at your self-contained example, so I get the gist of what you're trying to do.  Rather than assigning to the array view, you can assign to an indices object and build the view after the fact.  Here's how to do the 2-dimensional case that you had commented out:

                     //This doesn't work, but I would love a generic version of this:
                     
                     array_type::index_gen::gen_type<1,2>::type myindices;
                     if (desired_slice [0] == -1)
                       myindices = indices [range ()][desired_slice [1]];
                         else
                     if (desired_slice [1] == -1)
                       myindices = indices [desired_slice [0]][range ()];

                     array_type::const_array_view <1>::type OneDView
                       = multi_array[myindices];

                     ret_val = (OneDView [whichPosition]);

HTH,
ron



On Jun 14, 2008, at 10:32 AM, Joey Mukherjee wrote:


I am trying to use boost::multi_array and want to create a view where I am 
lowering the number of dimensions, but I wish the dimension to be reduced 
to be decided at runtime. 

I have a vector of integers and this vector size is the same as the number 
of dimensions.  If the vector [1] value is -1, then the first dimension 
will have all values (i.e. range ()), otherwise it will be a number 
indicating what slice to use.