0

我正在为状态机使用 Boost Statechart Event。我正在考虑一个向量/列表来举办活动。

我尝试了以下 -

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> {};

在状态机类中,我想将每个事件添加到一个向量/列表中,这是我无法做到的。

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
};

我的目标是将事件添加到列表中,如下所述 -

EventOne eOne;
EventTwo eTwo;

events.push_back(eOne);
events.push_back(eTwo);
events.push_back(EventOne());

我错过了一些东西。请用示例代码帮助我形成向量/列表。谢谢。

错误:

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
4

0 回答 0