[statechart] - error with templated states (no type 'inner_contex_type')

Hello, I get another error if I use templated states (gcc-3.4.6). 'simple_state.hpp:403: error: no type named inner_context_type in struct proto<int>' Instantiation of state_machine:: initiate() causes the error. with regards, Oliver #include <iostream> #include <stdexcept> #include <boost/statechart/simple_state.hpp> #include <boost/statechart/state_machine.hpp> namespace sc = boost::statechart; template< typename S > struct proto; template< typename S > struct sm : public sc::state_machine< sm< S >, proto< S >
{}; template< typename S > struct inactive; template< typename S > struct proto : public sc::simple_state< proto< S >, sm< S >, inactive< S >
{}; template< typename S > struct inactive : public sc::simple_state< inactive< S >, proto< S >
{}; int main() { try { sm< int > fsm; fsm.initiate(); // <<== causes compiler error return 0; } catch ( std::runtime_error const& e) { std::cerr << e.what() << std::endl; } catch (...) { std::cerr << "unhandled exception" << std::endl; } return -1; }

Oliver.Kowalke@infineon.com schrieb:
namespace sc = boost::statechart;
template< typename S > struct proto;
template< typename S > struct sm : public sc::state_machine< sm< S >, proto< S > {};
template< typename S > struct inactive;
template< typename S > struct proto : public sc::simple_state< proto< S >, sm< S >, inactive< S > {};
template< typename S > struct inactive : public sc::simple_state< inactive< S >, proto< S > {};
FYI in your examples you're missing a '>' everywhere. :) (I don't think that it is the real problem, I only want to mention you about this ;) ) BR Vinzenz

Oh, my fault this is my mail client that thinks that it is a quote and doesn't shows up the missing '>'. I am sorry. But I've mentioned something what confuses me a bit: template< typename S > struct sm : public sc::state_machine< sm< S >, proto< S >
{}; Won't this cause a endless recursion on instantiation? BR Vinzenz

Hi Oliver
I get another error if I use templated states (gcc-3.4.6). 'simple_state.hpp:403: error: no type named inner_context_type in struct proto<int>' Instantiation of state_machine:: initiate() causes the error.
A brief look at your code suggests that you have run into the same problem like Dave Greene: http://article.gmane.org/gmane.comp.lib.boost.user/17091 You need wrap all inner initial states that are template instantiations into an mpl::list<> ... template< typename S > struct proto : public sc::simple_state< proto< S >, sm< S >, mpl::list< inactive< S > > // *** here ***
{}; ... and everything should work as expected. Follow the link above for details. HTH, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
participants (3)
-
Andreas Huber
-
Oliver.Kowalke@infineon.com
-
Vinzenz 'evilissimo' Feenstra