On Jun 24, 1:54 pm, Jesse Perla <jessepe...@gmail.com> wrote:
I believe the problem is that the index_gen object needs different types as we build the indices in parts. The following code shows what a hardcoded example would look like for N = 4 and M = 3
Sorry to answer my own question, but I poked around in the code and found that the member data is public. The following seems to solve my problem (though I would still love suggestions on if it is the best way to tackle this problem with multi_array): boost::multi_array<double, 4> vals; //...fill.... boost::detail::multi_array::index_gen<4, 3> slice_build; slice_build.ranges_[0] = range(0,n_1); slice_build.ranges_[1] = range(0,n_2); //could loop before slice_build.ranges_[2] = range(1); slice_build.ranges_[3] = range(0,n_4); //could loop after auto vals_slice4 = vals[ slice_build ]; cout << vals_slice4[0][0][0] << endl; cout << vals_slice4[1][1][1] << endl;