Gottlob Frege wrote:
My gut feeling is that "does this variant
contain a Z" should be a compile time error, because it obviously doesn't contain a Z. (Of course less obvious when variant is spelled 'T'.)
Or when it's spelled variant
And because it *can* be a compile time error.
Well yes, that is why we are having this discussion.
In most C++ code, you need to go out of your way (eg dynamic_cast) to do type-stuff at runtime.
get<> ALWAYS does type-stuff at runtime. It's not going to get any less runtimey. It's just going to catch a few (not very common) errors. It's still a dynamic_cast; the equivalent of the strict get<> would be a dynamic_cast that tells you, at compile time, "this cast will always fail, don't do it." Which, in dynamic_cast's case, is - I suspect - going to be a mixed blessing unless it's a warning, not an error. That said, my recommendation still stands. Make get<> strict, see what happens.