Boost logo

Boost Users :

From: Vladan Vidakovic (v.vidakovic_at_[hidden])
Date: 2008-04-03 20:33:31


Hi, I'm learning about multi_arrays and have not been able to find much
info about different ways of initializing them. In particular I'm
interested in initializing a multi_array in the same way I can init a
basic C/C++ array:

  int array_2d[3][3] = { {1,2,3}, {2,3,4}, {3,4,5} };

When I declare an analogous multi_array, the compiler (VC++ 8.0)
complains about the third line:

  typedef boost::multi_array< int, 2 > int_2d_array_t;
  boost::array< int_2d_array_t::index, 2 > shape = {{ 3, 3 }};
  
  int_2d_array_t A(shape) = { {1,2,3}, {2,3,4}, {3,4,5} }; // error
C2143: syntax error : missing ';' before '='
  

The online documentation only mentions initialization of individual
elements (A[0][0][0] = 4;), but in doing it that way would be very
tedious.

What alternatives are there?

Thanks. Regards,
Vladan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net