The value type of a zip_range
is a tuple of references to elements:
#include <iostream>
#include <vector>
#include <boost/range.hpp>
#include <boost/range/combine.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/foreach.hpp>
int main(int ac,char* av[])
{
// input data; never mind how these get filled
int aa[] = {2, 3, 5, 8, 13, 21};
int bb[] = {1, 0, 1, 1, 0, 1};
std::vector<int> a(boost::begin(aa), boost::end(aa));
std::vector<int> const b(boost::begin(bb), boost::end(bb));
// output storage; assume it has always correct dim.
std::vector<int> c (a.size());
typedef boost::tuple<int const&, int&> val_t;
BOOST_FOREACH(val_t const& v, boost::combine(a, c)) {
v.get<1>() = v.get<0>() * 2;
}
}