Boost logo

Boost Users :

Subject: [Boost-users] [msm] forward declaration of state machine with non-default constructor
From: caligano (caligano_at_[hidden])
Date: 2014-08-28 08:49:37


Hi,

I want to forward declare a state machine which has a non-default
constructor.

I found this example here: http://stackoverflow.com/a/10922799/678093
But I can't call the non-default constructor of the state machine.
I either get

- "error: call of overloaded ‘fsm(int)’ is ambiguous" (if inheriting
constructors using C++11) or
- "error: no matching function for call to ‘wrapper::fsm::fsm(int)"

What can I do about it?

Thanks,
Manuel

Example:

------------------------
// wrapper.h
#include <boost/msm/front/state_machine_def.hpp>
#include <boost/msm/back/state_machine.hpp>
#include <boost/shared_ptr.hpp>

class wrapper
{
  wrapper();
  struct fsm;
  boost::shared_ptr<fsm> player_fsm;
};

------------------------
// wrapper.cpp
#include "wrapper.h"

struct player_ : public boost::msm::front::state_machine_def<player_>
{
    player_(int some_value)
    {}
};

struct wrapper::fsm : public boost::msm::back::state_machine<player_>
{
    using boost::msm::back::state_machine<player_>::state_machine;
};

wrapper::wrapper()
  : player_fsm(new fsm(100))
{

}
------------------------






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