Boost logo

Boost Users :

Subject: [Boost-users] [fusion] for_each with indices
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2012-07-30 18:20:54


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net