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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Oliver.Kowalke-2
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;
}

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

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

Vinzenz 'evilissimo' Feenstra-3
[hidden email] 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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

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

Vinzenz 'evilissimo' Feenstra-3
In reply to this post by Oliver.Kowalke-2
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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

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

Andreas Huber-2
In reply to this post by Oliver.Kowalke-2
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.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost