#include #include void fill_array(boost::multi_array_ref &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; fill_array(foo2d[boost::indices[range()][0]]); // no worky std::cout << "foo2d[0][0] = " << foo2d[0][0] << std::endl; return 0; }