
I'm using Boost.Statechart and have come across a strange gcc-4.7.2 behavior on the attached sample code. The error is:
cpp-lab/boost/statechart/main.cpp:89:23: error: expected ')' before 'ctx'
If outermost_context() isn't used in Inner3() constructor and statechart::simple_state is used instead of statechart::state everything is OK. If Inner3 is not a template then everything is OK
The problem occurs only if a state template class is inherited from statechart::state.
Is there any workaround for the issue?
You can't use unqualified inherited names from within a template, because the compler wouldn't search them in the base. Try something like this:
template<class T> struct Inner3: public sc::state
{ Inner3(typename sc::state ::my_context ctx): sc::state ::my_base(ctx) { std::cout << "Inner3(): my outermost_context() is '" << this->outermost_context().name() << "'" << std::endl; } ~Inner3() { std::cout << "~Inner3()"<< std::endl; } };
That works. Thanks, lesson learned.