If I have a
boost::multi_array<int,2> myArray(boost::extents[10][10]);
Which type is the following?
myArray[4]
How should I define a reference to it in a function interface?
int doSomething(xxxxxx& mySubArray, const int dim) {
for (int i = 0; i < dim; i++) {
std::cout << mySubArray[i] << std::endl;
}
}
From the documentation: boost::multi_array<int, 2>::reference
.
For NumDims == 2
, this is the type boost::multi_array<int, 2>::template subarray<1>::type
, or alternately boost::array_view_gen<boost::multi_array<int, 2>, 1>::type
. Once the dimensionality of the array view reaches 0, you get an element reference (i.e. int &
) instead.