Boost logo

Boost Users :

From: Andreas Huber (ahd6974-spamgroupstrap_at_[hidden])
Date: 2006-06-19 15:21:49


Hi Oliver

Oliver.Kowalke_at_[hidden] wrote:
> Hello,
> I've a problem to compile (gcc- 4.1.2) a templated asynchronous state
> machine.
>
> error: expected `)' before 'ctx'

MSVC 7.1 produces an almost identical diagnostic. This is a well-known
C++ "problem". As soon as the deriving class is a template you need to
fully qualify base class typedefs. The following works on MSVC7.1:

#include <boost/statechart/asynchronous_state_machine.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/fifo_scheduler.hpp>

namespace sc = boost::statechart;

template< typename streamT > struct proto;

template< typename streamT >
class presentation : public sc::asynchronous_state_machine<
 presentation< streamT >, proto< streamT > >
{
  typedef typename sc::asynchronous_state_machine<
   presentation< streamT >, proto< streamT > > base_type;
  public:
    // **** HERE ****
    presentation( typename base_type::my_context ctx ) : base_type(
ctx ) {}
};

template< typename streamT >
struct proto : sc::simple_state< proto, presentation< streamT > > {};

int main()
{
  sc::fifo_scheduler<> scheduler;
  sc::fifo_scheduler<>::processor_handle presentation_handle =
    scheduler.create_processor< presentation< int > >();
  scheduler.initiate_processor( presentation_handle );
  scheduler();
  return 0;
}

HTH,

-- 
Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header. 

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net