Boost logo

Boost Users :

Subject: Re: [Boost-users] [msm] & typeerasure / any
From: Raj Sambasivan (rajinikanth_at_[hidden])
Date: 2014-09-28 06:57:38


please ignore, sorted out.
I had to define explicit concepts, rather than the
BOOST_TYPE_ERASURE_MEMBER
<http://www.boost.org/doc/libs/1_56_0/doc/html/BOOST_TYPE_ERASURE_MEMBER.html>

thanks
-raj

On Sun, Sep 28, 2014 at 12:48 AM, Raj Sambasivan <rajinikanth_at_[hidden]>
wrote:

> 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<has_process_event<HandledEnum(Event1 const &)>, _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<has_process_event<HandledEnum(Event1 const &)>, _self&>
> any_fsm;
>
> *Works for vector:*
>
> BOOST_TYPE_ERASURE_MEMBER((has_push_back), push_back, 1)
>
> typedef any<has_push_back<void(int)>, _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
>



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