You are close. In the example above, zip_func is the functor that you provide that does the work you want it to. In this case, something like:
typedef unordered_map<string,string> stringmap;
struct map_insertor {
void operator()(const boost::tuple<const string&, const string&> &t ) {
m_map.insert(make_pair(t.get<0>(),t.get<1>());
}
map_insertor(stringmap &m) : m_map(m) {}
private:
stringmap &m_map;
};
stringmap my_map;
for_each(
boost::make_zip_iterator(
boost::make_tuple(beg1, beg2)
),
boost::make_zip_iterator(
boost::make_tuple(end1, end2)
),
map_insertor(my_map)
);
But there is nothing wrong with the simple solution.
typedef vector<string> stringvec;
stringvec::iterator ik = vec_of_keys.begin();
stringvec::iterator iv = vec_of_vals.begin();
for( ;(ik != vec_of_keys.end()) && (iv != vec_of_vals.end()); ik++,iv++) {
my_map.insert(make_pair(*ik, *iv));
}