Boost logo

Boost Users :

Subject: [Boost-users] boost::fusion zip_iterator and generic make_tuple call
From: David Genest (david.genest_at_[hidden])
Date: 2009-03-13 10:20:48


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 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;

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
(, should I
go more in that direction? Any pointers would be appreciated.

Thank you for your time,


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at