title: Generic C++ multidimensional iterators
body: <p>In my current project I am dealing with a multidimensional datastructure.
  The underlying file is stored sequentially (i.e. one huge array, no vector of vectors).
  The algorithms that use these datastructures need to know the size of the individual dimensions.</p>
  
  <p>I am wondering if a multidimensional iterator class has been definied somewhere in a generic way and if there are any standards or preferred ways on how to tackle this.</p>
  
  <p>At the moment I am just using a linear iterator with some additional methods that return the size of each dimension and how many dimensions are there in the first part. The reason I don't like it is because I can't use std:: distance in a reasonable way for example (i.e. only returns distance of the whole structure, but not for each dimension separately).</p>
  
  <p>For the most part I will access the datastructure in a linear fashion (first dimension start to finish -> next dimension+...and so on), but it would be good to know when one dimension "ends". I don't know how to do this with just operator*(), operator+() and operator==() in such an approach.</p>
  
  <p>A vector of vectors approach is disfavored, because I don't want to split up the file. Also the algorithms must operate on structure with different dimensionality and are therefore hard to generalize (or maybe there is a way?).</p>
  
  <p>Boost multi_array has the same problems (multiple "levels" of iterators).</p>
  
  <p>I hope this is not too vague or abstract. Any hint in the right direction would be appreciated.</p>
  
  <p>I was looking for a solution myself again and revisited boost:: multi_array. As it turns out it is possible to generate sub views on the data with them, but at the same time also take a direct iterator at the top level and implicitely "flatten" the data structure. The implemented versions of multi_array however do not suit my needs, therefore I probably will implement one myself (that handles the caching of the files in the background) that is compatible with the other multi_arrays.</p>
  
  <p>I will update it again once the implementation is done.</p>