|
Boost Users : |
Subject: [Boost-users] [lambda] Return types in lambda expressions
From: Michael Crawford (mbcrawfo_at_[hidden])
Date: 2009-04-26 12:14:52
I'm trying to use bind and lambda to create a functor that can receive an
event generated by my GUI library, and dispatch an appropriate event into a
boost::statechart::state_machine. The GUI library requires the functor to
have the signature bool (const CEGUI::EventArgs&). An example of what
works:
template<typename EventType>
bool GuiEvent(const CEGUI::EventArgs&, GameStateMachine& gsm)
{
gsm.process_event(EventType( ));
return true;
}
//usage:
GameStateMachine sm;
...
boost::bind(&GuiEvent<EventExitGame>, _1, boost::ref(sm));
But is it possible to use lambda to eliminate the need for the function? It
looks like I would use something along the lines of
boost::bind<bool>(boost::ref(sm).process_event(EventExitGame( )) /*somehow
return true here*/, _1);
I'm just not quite seeing how I would get the lambda expression to return
true there.
Cheers.
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