std::variant
(C++)
The class template std::variant
represents a type-safe union.
Resources
It’s a great alternative to using std::union and std::any because it provides better type safety and ease of use.
Saw this in CS343.
An example that they gave: