[msm] forward declaration of state machine with non-default constructor
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)) { } ------------------------
Hi Manuel,
I want to forward declare a state machine which has a non-default constructor.
struct wrapper::fsm : public boost::msm::back::state_machine<player_> { using boost::msm::back::state_machine<player_>::state_machine; };
I think you can’t “using” template constructors. Try: fsm(int some_value):boost::msm::back::state_machine<player_>(some_value){} HTH, Christophe
Hi Christophe, thanks for the reply. Sure, I can 'repeat' the constructor / its arguments. I just thought maybe I can avoid this. Bye Manuel 2014-08-29 21:13 GMT+02:00 <christophe.j.henry@googlemail.com>:
Hi Manuel,
I want to forward declare a state machine which has a non-default constructor. struct wrapper::fsm : public boost::msm::back::state_machine<player_> { using boost::msm::back::state_machine<player_>::state_machine; };
I think you can’t “using” template constructors. Try:
fsm(int some_value):boost::msm::back::state_machine<player_>(some_value){}
HTH, Christophe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
caligano
-
christophe.j.henry@googlemail.com
-
Manuel Schiller