std::variant is designed as a type-safe union, it does not support direct polymorphism or implicit upcasting to a common base. And then the issue is that you are trying to cast the active variant value to the Base class using reinterpret_cast, which is unsafe. Also, u are avoiding std::visit so instead make all variant types inherit from the same base class which contains the shared member "i". This way, you can safely work with pointers or references to the base class without needing unsafe casts or runtime checks.