Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-04-14 04:01:22


"chun ping wang" <cablepuff_at_[hidden]> writes:

> Heres a simple question, that i want to do.
>
> Lets say you have a function call void f(double);
>
> and then you want to apply f to each argument inside vector<double> a;
>
> for_each(a.begin(), a.end(), f(_1));
>
> // the example above isn't possible..is there a simple way to do
> this?

  for_each(a.begin(), a.end(), bind(f, _1));

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.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