79654602

Date: 2025-06-05 13:54:36
Score: 1.5
Natty:
Report link

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.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Arwa Abbas