Considering the amount of pain I had trying to work out how to do this; I thought I’d write up something lengthy to explain how it works. It also helps me find if there’s anything in it that I don’t fully understand, else I wouldn’t be able to explain it.
The full Variant types header file has already been posted. This is the code I’m going off of.