除了预分配和遍历所有元素之外,是否有将 2D Boost MultiArray 转换为普通 2D 数组的最佳/最简单方法?
#include "boost/multi_array.hpp"
#include <cassert>
int main ()
{
// Create 2D multi-array
typedef boost::multi_array<double, 2> array_type;
typedef array_type::index index;
array_type A(boost::extents[3][4]);
// Fill in some values ...
double value = 1.0;
for(index i = 0; i != 3; ++i)
for(index j = 0; j != 4; ++j)
A[i][j] = value;
// Convert to a double[3][4] ...
double **convert = ???
return 0;
}