On Dec 9, 3:43 pm, Steve555 <foursh...@btinternet.com> wrote:
I'm looking for an algorithm that takes 2 vectors and a
function pointer as arguments? I want to use the function
pointer to calculate a result e.g. the product, and put the
result either in place, or in a third vector.
I've looked through the list of algorithms and there doesn't
appear to be one. transform() is the closest, but alas works
on only a single vector.
There are two versions of std::transform. The following code
should do the trick:
assert( v1.size() == v2.size() ) ;
std::transform( v1.begin(), v1.end(),
v2.begin(),
std::back_inserter( v3 ),
std::multiplies< double >() ) ;
--
James Kanze (GABI Software) email:james.ka...@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34