[statechart] template state derived from simple_state compile error

Hi,
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.
The error i get is :
sc_test.cpp: In member function ‘boost::statechart::result
init<TCallBackType>::react(const initialize&)’:
sc_test.cpp:38: error: expected primary-expression before ‘>’ token
sc_test.cpp:38: error: expected primary-expression before ‘)’ token
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.
I'm using gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Any help will be aprecciated.
Here's the code, there is a comment where the error occurs.
#include
{
//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.

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. The error i get is : sc_test.cpp: In member function ‘boost::statechart::result init<TCallBackType>::react(const initialize&)’: sc_test.cpp:38: error: expected primary-expression before ‘>’ token sc_test.cpp:38: error: expected primary-expression before ‘)’ token 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. I'm using gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
FWIW, your code compiles well in MSVC10

On Sun, Jul 25, 2010 at 6:04 PM, Igor R
I'm experiencing a compiling problem with boost.statechart. I'm using gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
FWIW, your code compiles well in MSVC10
Thanks Igor, well, at list I know it's some syntax misbehavior related to gcc
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Sun, Jul 25, 2010 at 6:49 PM, Nicolas Emiliani
On Sun, Jul 25, 2010 at 6:04 PM, Igor R
wrote: I'm experiencing a compiling problem with boost.statechart. I'm using gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
FWIW, your code compiles well in MSVC10
Thanks Igor, well, at list I know it's some syntax misbehavior related to gcc
Well, finally cracked it. Apparently since the method invocation is dependant on the parameter of the template the keyword template should be used, resulting in: this->template transit< post<TCallBackType> > (); Ohhhh yeah!.... Nasssssty.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Gaetano Mendola
-
Igor R
-
Nicolas Emiliani