I was looking for some suitable 2D element container. What I want is the ability to iterate through every element of the container using, for example BOOST_FOREACH and I also would like to have an ability to construct subview (slices / subranges) of my container and, probably iterate through them too.
Right now I am using boost::numeric::ublas::matrix for these purposes, but, well, it doesn’t look as a good solution for me, because, well, it’s a BLAS matrix, although it behaves very well as a plain 2d element container (custom unbounded / bounded storages are also very sweet).
Another boost alternative, boost::multi_array is bad, because you can’t iterate through every element using one BOOST_FOREACH statement and because constructing views has extremely obfuscated syntax.
Any alternatives?
Thank you.
I do the following (array type is container/iterator range concept):
However, this will not work for slices: your best solution is to write an iterator for them.
Here is an example of using
multi_arrayto provide storage of a custom class.Perhaps you could do the same: