79512620

Date: 2025-03-16 13:41:25
Score: 1
Natty:
Report link

As per @Eljay suggestion I moved the definition of process() functions after the class declarations and it works fine:

class IdleState : State<StateMachine<TransitionMap, RunState, IdleState>>
{
public:
    /* Use parent constructor */
    using State<StateMachine<TransitionMap, RunState, IdleState>>::State;
    void process() override;
};

class RunState : State<StateMachine<TransitionMap, RunState, IdleState>>
{
public:
    /* Use parent constructor */
    using State<StateMachine<TransitionMap, RunState, IdleState>>::State;
    void process() override;
};

void IdleState::process()
{
    std::cout << "IDLE" << std::endl;
    state_machine_->emitEvent<IdleState>(StartEvent{});
}

void RunState::process()
{
    std::cout << "RUN" << std::endl;
    state_machine_->emitEvent<RunState>(StopEvent{});
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Eljay
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: konin