Boost logo

Boost Users :

From: Levent Yilmaz (sly5+gmane_at_[hidden])
Date: 2006-10-15 18:06:37


Hi,

I have this construct:

class foo {};
void fbar(foo*) {}

int main()
{
   using namespace boost::lambda;
   std::vector<foo> foos(3);
   std::for_each( foos.begin(), foos.end(), bind<void>(&fbar, &_1) );
}

OK, this works. But I want to store the lambda expression, and wasn't
able to to it. The following obvious try doesn't work:

boost::function<void(foo*)> func = bind<void>(&fbar, &_1);
std::for_each( foos.begin(), foos.end(), func );

How should I do this?

thx,

- Levent


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