#include #include template void fill_array(MultiArray1 &a) { for (int i = 0; i < a.shape()[0]; ++i) { a[i] = 3.14159; } } int main() { const int dim1(2); const int dim2(3); boost::multi_array foo1d(boost::extents[dim1]); boost::multi_array foo2d(boost::extents[dim1][dim2]); fill_array(foo1d); // worky std::cout << "foo1d[0] = " << foo1d[0] << std::endl; typedef boost::multi_array_types::index_range range; boost::multi_array::array_view<1>::type view1 = foo2d[boost::indices[range()][0]]; fill_array(view1); // worky now fill_array(foo2d[boost::indices[range()][0]]); // still no worky std::cout << "foo2d[0][0] = " << foo2d[0][0] << std::endl; return 0; }