I'm using Boost Statechart Event for a State-Machine. I'm thinking of a vector/list to hold events.
I tried the following -
template <typename T>
struct Event : public boost::statechart::event<Event>
{
Event(const T & event) : m_event(event)
{
//
}
~Event()
{
}
Event & getEvent() const { return m_event; }
Event m_event;
};
struct EventOne : public Event<EventOne> {};
struct EventTwo : public Event<EventTwo> {};
In State-Machine class I want to add every event to a vector/list, which I'm unable to.
class StateOne;
class StateMachine : public boost::statechart::state_machine<StateMachine, StateOne>
{
StateMachine() = default;
~StateMachine() = default;
private:
std::list<boost::statechart::event<Event>> events; // Error in formation of std::list here
};
My objective is to add events to the list as mentioned below -
EventOne eOne;
EventTwo eTwo;
events.push_back(eOne);
events.push_back(eTwo);
events.push_back(EventOne());
I'm missing something. Kindly help me with the formation of vector/list with the example code. Thanks.
Errors:
error C3203: 'Event': unspecialized class template can't be used as a template argument for template parameter 'MostDerived', expected a real type
error C2460: 'Event<EventOne>::m_event': uses 'Event<Startup>', which is being defined
error C3203: 'Event': unspecialized class template can't be used as a template argument for template parameter 'MostDerived', expected a real type