I think it is the most generic way to do it. It actually looks like something that someone would write in C to implement a dispatch/visitor with `0` being the RTTI field.
I cannot think of a situation where a cast would not be wanted by the user so maybe the switch could be simplified by making the cast implicit.