Frage

This is from the Boost docs and compiles without problems.

#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;
}

My question is: What is the second template parameter? It's not clear to me from the documentation. This code will only compile if it is set to 3.

War es hilfreich?

Lösung

It's how many dimensions you need.

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

So if you change this number, you'll have to change this line to.

Andere Tipps

It is the 'Numeric Dimension' --- i.e. the number of dimensions of your array: three because you have three subscripts on your boost::extents.

It is the number of dimension of the array:

you have change accordingly the ctor call :

array_type A(boost::extents[3][4]);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top