Boost.MultiArray supports std::vector
elements. In general, Boost.MultiArray will perform concept checking at compile-time. Thus, if code compiles with the complete type, then it should be supported.
With mImage[0][0].origin()
:
mImage[0][0]
returns a reference to std::vector<Vector3_t>
.
origin()
is not a member function on std::vector<Vector3_t>
, resulting in an error.
origin()
is a member function of multi-array, that returns the address of the first element's storage. In the case where the array has not been reindexed to a positive index, this is equivalent of 0
for all indexes (i.e. mImage.origin() == &mImage[0][0]
).
Here is a brief and complete example with a multi-array of a vector of vector of ints.
#include <iostream>
#include <vector>
#include <boost/foreach.hpp>
#include <boost/range/counting_range.hpp>
#include <boost/multi_array.hpp>
int main()
{
typedef std::vector<int> vector3_type;
typedef boost::multi_array<std::vector<vector3_type>, 2> array_type;
array_type array(boost::extents[5][5]);
// Insert vector into multi-array.
array[0][0].push_back(vector3_type());
// Insert range of [100,105) into the first vector at [0][0]
BOOST_FOREACH(const int& i, boost::counting_range(100, 105))
array[0][0].front().push_back(i);
// Print all integers at [0][0][0]
BOOST_FOREACH(const int& i, array[0][0][0])
std::cout << i << std::endl;
}
And running produces the following expected output:
100
101
102
103
104