- /// \brief Statically get an integer for a type. For:
- /// @code
- /// PointerUnionTypeNum<PT1, PT2>::template NumFor<T>::Result
- /// @endcode
- /// Result will be 0 if T is PT1, 1 if it is PT2, and -1 otherwise.
- template <typename PT1, typename PT2>
- struct PointerUnionTypeNum {
- private:
- struct IsNeither { char x; };
- struct IsPT1 { char x[2]; };
- struct IsPT2 { char x[3]; };
-
- static IsPT1 determine(PT1 *P);
- static IsPT2 determine(PT2 *P);
- static IsNeither determine(...);
-
- public:
- template <typename T>
- struct NumFor {
- static const int Result = (int)sizeof(determine((T*)0)) - 2;
- };
- };
-