Boost logo

Boost Users :

Subject: Re: [Boost-users] [statechart] friend state can't call overloaded member functions in machine class
From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2009-07-14 14:59:58


Hi David

[snip]
> class CoreApp : public boost::statechart::state_machine< CoreApp, Active >
> {
> friend struct Active;
> public:
> CoreApp() { initiate(); }
>
> private:
> void doInStateReaction(const EvNext &) {}
> void doInStateReaction(const EvBack &) {} ///< uncomment this line to
> resolve
> the error
> };
>
> struct Active : boost::statechart::simple_state< Active, CoreApp > {
> typedef boost::mpl::list <
> //sc::in_state_reaction < EvBack, CoreApp, &CoreApp::doInStateReaction
> >,
> sc::in_state_reaction < EvNext, CoreApp, &CoreApp::doInStateReaction >
> > reactions;
> };
>
>
> As one can see two functions doInStateReaction() are defined in the state
> machine class. Comment the second one out and it compiles. This problem
> occurs
> too if one uses a templated event which calls a templated function.
> A easy solution to this problem is to rename the functions slightly but I
> hope
> there is a better way. Has anyone an idea to catch this?

This has nothing to do with Boost.Statechart but is, IIRC, a plain old C++
"problem". Replace with the following lines and everything should work:

sc::in_state_reaction< EvBack, CoreApp, (void (CoreApp::*)(const EvBack &))
&CoreApp::doInStateReaction >,
sc::in_state_reaction< EvNext, CoreApp, (void (CoreApp::*)(const EvNext &))
&CoreApp::doInStateReaction >

Hope I got the syntax right...

HTH,

-- 
Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header. 

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