I’m trying to write some dimension-independent code for a template class in c++, using a boost::multi_array (though if other containers/data structures are better at this, I’d be happy to hear about it).
Given a dimension, I would like to iterate over the full range of every other dimension, returning a 1d view along the selected dimension. This is fairly straightforward, or at least it appears to be from the boost documentation.
What I can’t figure out how to do is iterate the selected dimension over all of the dimensions of the array, when the dimension of the array is known at compile time.
Any advice on how to do this?
Normally you can do it with boost::multi_array, heres some sample code to create a 2D view of a 3D multi_array: