|
Boost Users : |
From: Levent Yilmaz (sly5+gmane_at_[hidden])
Date: 2006-09-14 14:27:52
This question is perhaps, rather a feature request from multi_array:
ptr_vector (of pointer container library) is nice but it is not multi
dimensional, multi_array is nice but it is not, well, ptr_multi_array.
For any single dimensional random access array there is multi_array_ref:
/**/
boost::array<size_t,2> shape = {4,4};
std::vector<int> v(16);
boost::multi_array_ref<int,2> mav(&v[0],shape);
/**/
But, this (&v[0]) wouldn't work with ptr_vector, due to the indirected
interface of pointer containers. I was thinking, one way of achieving
this is to have multi_array_ref work with any random access container,
rather than just plain C array. The above example would be:
/**/
boost::array<size_t,2> shape = {4,4};
std::vector<int> v(16);
boost::multi_array_ref< std::vector<int>, 2 > mav(v,shape);
/**/
Note the change of the first template parameter of multi_array_ref from
the element type to, container type. This way, it would similarly be
possible to use it with ptr_vector, or any other random access container
for that matter:
/**/
class foo;
boost::array<size_t,2> shape = {4,4};
boost::ptr_vector<foo> v(16);
boost::multi_array_ref< boost::ptr_vector<foo>, 2 > mav(v,shape);
/**/
The thing is, I am not sure if this can be done with the multi_array
library.
Or, what other ways are there to get a multi dimenstional pointer container?
thanks
- Levent.
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