No, that doesn't work either, because T could be const or volatile, in which case you'll
get a compile error on your reinterpret_cast.
You need boost::addressof. :) Or else just duplicate it so you don't have to use boost :)
Also, I don't think the solution works if you have more than one source file.
EDIT:
Well, I suppose it would work if you pre-instantiated all of the statics for all of the types you'll
use in a separate cpp file:
template <class T>
int Type<T>::type;
Last edited on