extension of std::transform

Hi all!

Does anybody know anything about extensions of the std::transform algorithm that take more than two input ranges? Maybe there are some other workarounds on this topic?

Quite often I need something like

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <math.h>

using namespace std;
using namespace boost::lambda;

int main() {
	vector<double> coeffs,data;
	typedef map<string,int> map_t;
	typedef map_t::value_type pair_t;
	map_t weights;
	char* names[] = {"first","second","third"};
	for(size_t i=0;i<3;++i) {
		weights.insert(pair_t(names[i],100/(i+1)));
		coeffs.push_back(1.0+i*i);
		data.push_back((double)rand()/RAND_MAX);
	}
	transform_ext(coeffs.begin(),coeffs.end(),
		weights.begin(),
		data.begin(),
		data.begin(),
		bind<double>(exp,-_3*_3*0.5)*bind(pair_t::second,_2)-_1);
	return 0;
}


where we have 3 (or, possibly, more) containers of independent arguments of transformation. Obviously, one can just extend an existing implementation to admit three and more input ranges, or use a collection of all input ranges behaving as a unit container with iterator pointing to a tuple of a current set of arguments. Is there existing or more elegant ways to do it?
Topic archived. No new replies allowed.