In this blog post, I’ll show you how to convert a “regular” enum-style finite state machine into a modern version based on std::variant from C++17. This technique allows you to improve design, work with value types and enhance code quality.
States Let’s start with a basic example:
we want to track a game player’s health status we’d like to respond to events like “Hit by a monster” or “Healing bonus.