HI Boost-users/christophe,
I'm trying to make use of type erasure for fsm based on suggestion from an
earlier mail thread
http://boost.2283326.n4.nabble.com/msm-access-to-root-fsm-td4649632.html
but hitting compilation errors. Can you pls help?
while the any works as expected for push back e.g for vector (bottom of
email) it doesnt work for MSM..
*Doesn't Work for MSM:*
BOOST_TYPE_ERASURE_MEMBER((has_process_event), process_event, 1)
typedef any, _self&> any_fsm;
struct AnyFSM
{
AnyFSM(any_fsm afsm_) : _afsm(afsm_) {}
void process(Event1& e) { _afsm.process_event(e); }
any_fsm _afsm;
};
TestFSM test;
test.start();
AnyFSM(test);
test.process(Event1());
*error:*
*test.cpp:47:43: **error: **'Event1' does not refer to a value*
typedef any, _self&> any_fsm;
*Works for vector:*
BOOST_TYPE_ERASURE_MEMBER((has_push_back), push_back, 1)
typedef any, _self&> any_container;
void append_many(any_container container) {
for(int i = 0; i < 10; ++i)
container.push_back(i);
}
struct AnyContainer
{
AnyContainer(any_container cont_) : _cont(cont_) {}
void append() {append_many(_cont); }
any_container _cont;
};
AnyContainer m(v);
m.append();
for(auto i : v)
{
std::cout << i << std::endl;
}
Thanks
-Raj