boost multi array

Boost MultiArray is a library that simplifies using arrays with multiple dimensions.

1.

#include <boost/multi_array.hpp>
#include <iostream>

int main() {
  boost::multi_array<char, 1> a(boost::extends[6]);
  a[0] = 'B';
  a[1] = 'o';
  a[2] = 'o';
  a[3] = 's';
  a[4] = 't';
  a[5] = '\0';
  std::cout << a.origin() << std::endl;
  return 0;
}

boost::multi_array is a template expecting two parameters: The first parameter is the type of the elements to store in the array. The second parameter determines how many dimensions the array should have. The second parameter only sets the number of dimensions, not the number of elements in each dimension.

猜你喜欢

转载自www.cnblogs.com/sssblog/p/11050551.html