boost::fusion zip_iterator and generic make_tuple call
Hi, I'm cross-posting here after a kind invitation from Joel. I hope I can tap into your expert wisom! :-) I have a fusion sequence of std::vectors which can be specified variably by users: typedef boost::fusion::vector<std::vector, std::vector, ...> Inputs; Using boost::zip_iterator, I would like to parallel iterate each std::vector of the sequence and call a user function, but I am not sure how to proceed. Of course I would like to do this in a generic manner so that the user can change the number of inputs (std::vectors) at will. My first non generic shot looks like this: typedef boost::fusion::vector<std::vector<int>, std::vector<int> > Inputs; Inputs my_input; struct UserFunction { static void apply(int i, int j) { } } template<class F> struct zip_func { void operator() (const boost::tuple<int, int>& t) const { F::apply(t.get<0>(), t.get<1>()); } }; int main (int argc, char* argv[]) { using namespace boost::fusion; std::foreach( boost::make_zip_iterator( boost::make_tuple( at_c<0>(my_input).begin(), at_c<1>(my_input).begin()), boost::make_zip_iterator( boost::make_tuple( at_c<0>(my_input).end(), at_c<1>(my_input).end()), zip_func<UserFunction>()) ); } To the experts on the list: I don't see how to generalize the zip_func operator() and make_tuple call based on the fusion::vector signature. Is it even feasible, or is my intuition leading me in a dead end? I saw that there is a zip_iterator for fusion sequence in a svn branch (http://svn.boost.org/svn/boost/branches/zip_iterator_fusion/), should I go more in that direction? Any pointers would be appreciated. Thank you for your time, David.
participants (1)
-
David Genest