Hans Åberg wrote: > > So for C++ we could either go back and disable the static type > > checking completely, or do full dynamic checking (which std::variant > > does by itself). I choose the latter. As you said, the performance > > impact should be small, and the safety benefit substantial. (If > > someone doesn't want it, they might be able to use an alternative > > variant implementation without checks, or not use variant at all > > ...) > > That might be the difference: C++, unlike C, needs the types to > select the right constructors. To get those and not only PODs was > one motivation for introducing the variants.
Indeed, if one only wants to use PODs in C++, one can use the C template (which I did until recently), so there's not much point (IMHO) to a C++ template that supports only PODs. Regards, Frank