|
Boost Users : |
From: Imre (imre42_at_[hidden])
Date: 2006-04-07 07:10:05
Hi
I'm new to the boost::lambda lib, and have a problem.
I have a list that stores struct objects. One field of the struct is a
function pointer. I'd like to call the function pointer stored in each
element of the list, but I can't get it right.
First, I tried something like this:
struct S
{
typedef void (*Func)();
Func f;
...
};
...
std::list<S> l;
...
for_each(l.begin(), l.end(), bind(&S::f, _1));
I think this doesn't work because the bind yields a function object that
returns f itself, but doesn't call it. Instead, I'd need to build a
function object that returns the result of calling the f stored in the
current list node. Unfortunately, I don't know how to do it.
Thanks for any help.
Imre
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