30 Jul
2012
30 Jul
'12
10:20 p.m.
I recently needed to iterate over a fusion sequence, calling a function for each element that depends not only on the element type but on its index (position within the sequence) as well. I didn't find anything readily available to use in conjunction with for_each, so I ended up using fold with the index as state. However, I would like to get the index as a compile time value. What would be the simpler/best way to do this? Creating an iterator adaptor that keeps track of advances to the base iterator (should I be using the iterator_facade extension mechanism)? Or perhaps zipping the sequence with some kind of infinite mpl::vector_c sequence? Agustín K-ballo Bergé.- http://fusionfenix.com