In the previous article, we’ve played with creating and joining strings in compile time. Now with those tools at our disposal, we’re ready to challenge the main goal – creating a transition table in compile time. This article is a part of a bigger series (part1, part2, part3) and since it references previous solutions and ideas a lot I highly recommend reading all previous articles before reading this one. Also, this part is a bit lengthy so I recommend grabbing a cup of coffee or tea beforehand 🙂
In the previous series of articles (part1, part2) we’ve played with a simple state machine with some basic functionality. As the machine grows bigger, the need for debugging utilities becomes more important. To implement such utilities we need to do some groundwork first. All state, event, and action names are known at compile-time and for most of them, we could easily generate a string with the name during compilation. What’s problematic is that some of the types could be parametrized and would require some form of compile-time string concatenation. That’s exactly what we are going to explore in this article 🙂
In my previous article we’ve talked about implementing a simple state machine based on a std::variant and other newer additions to the C++ standard. Even though the implementation had its merits it was far from being complete. In this article, we improve upon that design to make it more useful and easy to use. (więcej…)
Finite State Machines are a very useful concept that allows modeling complex behavior. The basic idea is quite simple. We have a set of possible states and we define rules that govern transitions between the current state and some other state upon receiving an event. So how to implement one in C++17? Of course, there is a multitude of ways to do it. In this article, we try to explore another possibility based on several newer additions to the C++ standard. (więcej…)
Strona sii.pl/blog/ korzysta z plików Cookies (w celu realizacji usług). Dowiedz się więcej lub zamknij ten komunikat.