
22 Jun
2005
22 Jun
'05
7:02 a.m.
On Wed, 22 Jun 2005 06:30:43 +0400, Falcon <boost@chosenones.dyndns.org> wrote:
Sorry if this has been asked before (I couldn't find anything, or else I wasn't using the right searches)... How does one create a lambda function that invokes its parameter? For example, for use with std::for_each:
std::vector<boost::function0<void> > Methods; std::for_each(Methods.begin(), Methods.end(), *???*)
Probably like this: #include <vector> #include <algorithm> #include <boost/function.hpp> #include <boost/bind.hpp> #include <boost/bind/apply.hpp> int main() { std::vector<boost::function0<void> > Methods; std::for_each(Methods.begin(), Methods.end(), boost::bind(boost::apply<void>(), _1)); } -- Maxim Yegorushkin