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.
Yes, the way I presented it, it's very generic, indeed. Maybe a bit too much.
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.
The idea was that the dispatch doesn't need to know about "union" or about the use of field 0. But indeed, that's a bit "too generic" for convenience.
Maybe it could be streamlined into a "switch e" which hard-codes the fact that the "tag" is in field 0. Hmm... I guess that could work.
Stefan