For those who are following the saga, I am still trying to define Finite State Machine, states & events in the "proper" C++ way, with templates.
What's wrong with this code?
template <typename StateTypeEnum, typename EventTypeEnum>
class Fsm
{
public:
Fsm(E_subSystems subSystem,
uint8_t instance,
const char * const fsmName,
const std::vector<State<StateTypeEnum, EventTypeEnum> >& states)
{}
where
template <typename StateTypeEnum, typename EventTypeEnum>
class State
{
public:
State(INPUT E_subSystems subSystem,
StateTypeEnum stateId,
const char * const stateName,
const std::map<Event<EventTypeEnum>, EventHandlerFunction>& events)
{}
The only error message is
no matching function for call to "State<E_callControlStates, E_callControEvents>::State()" fsm.h line 98 C/C++ Problem
It looks like the error message refers to a non-existent
default constructor for state, but why?
E_callControlStates, E_callControEvents
were the template parameters for declaring an object of Fsm (with no errors).
Obviously, I am overlooking something & making a st00pid n00b mistake, but what? Thanks in advance
My bad. Of course it had nothing to do with the code that I was looking at - but then it rarely does, does it?
The class Fsm declared
private: State<StateTypeEnum, EventTypeEnum> _currentState;
when it should have been
private: State<StateTypeEnum, EventTypeEnum> *_currentState;
Sorry for misleading you, folks, and thanks for deducing the problem, despite that.