
7 Apr
2006
7 Apr
'06
11:10 a.m.
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