I'm experiencing a compiling problem with boost.statechart.
I created a template class called request<TCallBackType> derived from state_machine,
and two template states called init<TCallBackType> and post<TCallBackType>, the idea
is that request's initial states is init, and when recating to an event (initialize) it transits
to post.
I'm pretty sure this has to be with the fact that the template method transit is here
dependant of the template parameter, thus the compiler can't solve it, but I can't seem
to figure it out. Tryed using typename but did not work.
Any help will be aprecciated.
Here's the code, there is a comment where the error occurs.
#include <boost/statechart/event.hpp>
#include <boost/statechart/state_machine.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/state.hpp>
#include <boost/statechart/transition.hpp>
#include <boost/statechart/custom_reaction.hpp>
#include <boost/mpl/list.hpp>
namespace sc = boost::statechart;
//FORWARD DECLARATION OF THE INITIAL STATE
template<typename TCallBackType> struct init;
template<typename TCallBackType> struct post;
//STATE MACHINE
template<typename TCallBackType>
struct request : sc::state_machine<request<TCallBackType> , init<TCallBackType> > {
TCallBackType call_backs;
};
//EVENT
struct initialize : sc::event<initialize> {
};
//INITIAL STATE
template<typename TCallBackType>
struct init : sc::simple_state< init<TCallBackType>, request<TCallBackType> > {
//reactions
typedef boost::mpl::list<
sc::custom_reaction<initialize>
> reactions;
//on initialize
sc::result react(const initialize& e){
//HERE I GET THE COMPILING ERROR
//IF I COMMENT THIS IT ALL GOES SMOOTHLY
return this->transit< post<TCallBackType> > ();
}
typedef post<TCallBackType> p;
};
//SECOND STATE
template<typename TCallBackType>
struct post : sc::simple_state< post<TCallBackType>, request<TCallBackType> > {
//reactions
typedef boost::mpl::list<
sc::custom_reaction<initialize>
> reactions;
//on initialize
sc::result react(const initialize& e){
return this->discard_event();
}
};
int main(int argc, char* argv[]){
request<int> r;
r.initiate();
return 0;
}
Nicolas Emiliani.