Boost logo

Boost Users :

From: Kevin Heifner (heifner_k_at_[hidden])
Date: 2006-03-02 23:07:09


Meryl Silverburgh wrote:
> I would like to know if I can use transform and lambda to add 2 int
> vector and save the result into a third int vector
>
> vector<int> src1;
> vector<int> src2;
>
> vector<int> result // put the value of src1 and src2

Yes.

using boost::lambda::_1;
using boost::lambda::_2;

std::transform(src1.begin(), src1.end(),
                src2.begin(),
                std::backinserter(result),
                _1 + _2);

KevinH

-- 
Kevin Heifner  heifner @ ociweb.com  http://heifner.blogspot.com
           Object Computing, Inc. (OCI) www.ociweb.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net