1

This discussion has let to another question. It seems that index_gen in multi_array (a.k.a. boost::multi_array::index_gen) is set to boost::detail::multi_array::index_gen<0,0>, where I would have expected it to be boost::detail::multi_array::index_gen<Dim,Dim> where Dim is the template parameter of multi_array. Can anyone explain why this <0,0> type is used instead?

Community
  • 1
  • 1
David Doria
  • 9,873
  • 17
  • 85
  • 147
  • After looking at: http://www.boost.org/doc/libs/1_53_0/boost/multi_array/index_gen.hpp It seems to me like the index_gen is a way to generate content for the multi_array, it starts from 0,0 and allows you to advance to the next dimension or next dimension and range and assign ranges. – Jonathan Feb 25 '16 at 17:09
  • @Jonathan So then how do you store the object that gets generated (this was the reason I wanted this `index_gen` type in the first place: http://stackoverflow.com/questions/35556450/how-do-you-assign-a-boostindices-in-a-variable)? – David Doria Feb 25 '16 at 17:41
  • I looked in the link you posted. index_gen generates indices starting from the templated parameters it receives. The generated indices need to be passed to an actual instance of multi array in order to get/set the content of the multi array. If you want to store the generated indices instead of the data then I would use the auto keyword since you don't want to manually find the correct type. If you can't use auto then try and use decltype or something of the sort. Try: http://stackoverflow.com/questions/8482445/how-to-specify-degenerate-dimension-of-boost-multi-array-at-runtime – Jonathan Feb 28 '16 at 09:01
  • @Jonathan I could use `auto` if I just needed a local, but I'd like to be able to pass this to a function or store it as a class member, so I need to know the actual type. However, that question you linked to may get me where I'm looking to go - I'll have to try it out and report back. – David Doria Feb 28 '16 at 12:53
  • @Jonathan From that post I learned to access `range_` and `range_.start_/finish_` which helped in what I'm trying to do. If you add an answer about what this generator is/does (and hence why it is not templated on the dimension like I'd expect) I'll accept it. – David Doria Feb 29 '16 at 14:26

0 Answers0