Home  Writing  Games  Music  Dev  About 

Unions

https://en.cppreference.com/w/cpp/language/union

Variants

Variants Examples

State Machines

Very nice description of how to use variants instread of enum unions to make more customised state machines: https://www.cppstories.com/2019/06/fsm-variant-game/

Godot Game Engine

https://docs.godotengine.org/en/stable/development/cpp/variant_class.html

So, variants are used everywhere in Godot. Not for storing data permenantly, but to hold them for communication, editing, serialization and generally moving them around in a generic container instead of statically typing everything.

HOWEVER, they don't use the std::variant, but use a class made up of enums.