I've implemented a very minimal finite state machine in a class, and my original approach was to try this:
class Widget {
public:
void update(float time_interval){ state_(time_interval); }
private:
std::function< ?? > off_(float);
std::function< ?? > standby_(float);
std::function< ?? > locked_(float);
std::function< ?? > state_; // initialised to off_
};
Each state is a function which returns a state. But I can't work out how to declare a function whose return type includes its return type. Is there a way to break the recursion?
Instead, I used an enum class
and an ugly switch
statement.
Aucun commentaire:
Enregistrer un commentaire