[boost.lambda] Function invocation via lambda

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(), *???*) Peregrine Falcon

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

Thanks! With that syntax, I almost wonder if a loop is clearer, though. Ah, well, at least I know how now. :D Peregrine Falcon
participants (2)
-
Falcon
-
Maxim Yegorushkin