Boost logo

Boost Users :

Subject: Re: [Boost-users] [MSM] Boost.MSM: statemachine to transition on templatized event-type
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2015-05-29 10:00:52


Hi,

> having tested Boost.MSM, I'm pretty happy with it.

:)

>It's interesting, in that it seems to handle all states in a static table.
>No "new" operator etc.

It's much faster without dynamic allocation.

<snip>

    g_row<StateInitial, EventT, StateEven, &Machine_<EventT>::guardToEven>,

>Unfortunately
>gcc gives this error:
>d.cpp:119:5: error: ‘g_row’ was not declared in this scope
> g_row<StateInitial, EventT, StateEven,
&Machine_<EventT>::guardToEven>,

Short answer. Try:

typename Machine_<EventT>::template g_row<StateFloat, EventT, StateFloat,
&Machine_<EventT>::guardToFloat>

Long answer: g_row is a type of state_machine_def and as your fsm is a
template, it becomes a dependent type (=> typename) and a template one even
(=> template).

C++ is sometimes really annoying :(

Longer answer. Give up this front-end, it's deprecated anyway. A better
solution will be:

#include <boost/msm/front/functor_row.hpp>
using namespace boost::msm::front;

struct GuardToOdd
  {
      template <class EVT,class FSM,class SourceState,class TargetState>
      bool operator()(EVT const& num,FSM& ,SourceState& ,TargetState& )
      {
          const long long x = static_cast<long long>(num.getNum());
          return ((x == num.getNum()) // is Integral type
                  && ((x % 2) != 0));
      }
  };

Row< StateFloat, EventT, StateOdd, none, GuardToOdd>

HTH,
Christophe



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