Ungültige Verwendung eines unvollständigen Typs in der Implementierung der Vorlagen -StatusmaschineC++

Programme in C++. Entwicklerforum
Anonymous
 Ungültige Verwendung eines unvollständigen Typs in der Implementierung der Vorlagen -Statusmaschine

Post by Anonymous »

Ich bin ziemlich neu in der Programmierung von Vorlagen mit mir. Ich habe die Implementierung der generischen Zustandsmaschine geschrieben: < /p>
#include
#include
#include

template
class StateMachine
{
public:
StateMachine() : states_(Ss(this)...) {}

template
void setState()
{
current_state_ = &std::get(states_);
}

template
void emitEvent(E event)
{
setState();
}

void process()
{
std::visit([](auto &arg) {arg->process();}, current_state_);
}

private:
std::tuple states_;
std::variant current_state_ { &std::get(states_) };
};

template
class State
{
public:
State(SM* sm) : state_machine_(sm) {}
virtual void process() {};

protected:
SM* state_machine_;
};

namespace impl
{

/* Forward declarations */
class RunState;
class IdleState;

/* Events */
struct StopEvent {};
struct StartEvent {};

/* Transition map */
template
struct TransitionMap;

template
struct TransitionMap
{
using type = IdleState;
};

template
struct TransitionMap
{
using type = RunState;
};

template
struct TransitionMap
{
using type = IdleState;
};

template
struct TransitionMap
{
using type = RunState;
};

class IdleState : State
{
public:
/* Use parent constructor */
using State::State;
void process() override
{
std::cout

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post