C++ 了解Boost多阵列参数

C++ 了解Boost多阵列参数,c++,templates,boost,boost-multi-array,C++,Templates,Boost,Boost Multi Array,这是源于,编译时没有问题 #include "boost/multi_array.hpp" int main () { // Create a 3D array that is 3 x 4 x 2 typedef boost::multi_array<double,3> array_type; typedef array_type::index index; array_type A(boost::extents[3][4][2]); ret

这是源于,编译时没有问题

#include "boost/multi_array.hpp"

int main () {
    // Create a 3D array that is 3 x 4 x 2
    typedef boost::multi_array<double,3> array_type;
    typedef array_type::index index;
    array_type A(boost::extents[3][4][2]);
    return 0;
}
#包括“boost/multi_array.hpp”
int main(){
//创建一个3 x 4 x 2的三维阵列
typedef boost::multi_array_type;
typedef数组_type::index索引;
数组_类型A(boost::extensts[3][4][2]);
返回0;
}

我的问题是:第二个模板参数是什么?从文档中我不清楚。此代码仅在设置为
3

时才可编译。这是您需要的维度数

boost::extents[3][4][2] // we use 3 dimensions

因此,如果您更改此数字,您必须将此行更改为。

这是您需要的尺寸

boost::extents[3][4][2] // we use 3 dimensions

所以如果你改变这个数字,您必须将此行更改为。

这是“数字维度”——即数组的维度数:三,因为在
boost::extensts
上有三个下标。这是“数字维度”——即数组的维度数:三,因为在数组上有三个下标
boost::extensts

它是数组的维数:

您已相应更改ctor调用:

array_type A(boost::extents[3][4]);

它是数组的维数:

您已相应更改ctor调用:

array_type A(boost::extents[3][4]);