I am using boost:msm to create a state machine. It seems when processing events, the state machine does not care about polymorphism.
Say I have multiple events all derived from a base event:
struct EvtBase { virtual ~EvtBase();}
struct EvtA : EvtBase {};
struct EvtB : EvtBase {};
Then if I have a bunch of events stored in a vector via pointers of base event type:
typedef std::shared_ptr<EvtBase> ptrEvt;
std::vector<ptrEvt> event_list {std::make_shared<EvtA>(), std::make_shared<EvtB>()};
When I process these events by the state machine:
for (const auto& pEvt: event_list) {
fsm.process_event(*pEvt);
}
The boost::msm state machine thinks it receives EvtBase
, rather than the actual event pointed by the pointer.
Am I doing something wrong, or is there a way to change this behavior and make process_event
respect polymorphism?