Type extraction #pragma once#include<iostream>using namespace std;struct __truetype//define class normal type (base type) {bool Get () {return true;}}; struct __falsetype//defines class non-basic type {bool Get () {return false;}}; Template <class _tp>//Templates class (type extraction) struct typetraits//non-basic type {typedef __falsetype __ispodtype;}; When you rename a base type class to a non-basic type Class (typedef) to the same name//call __ispodtype.get (), the compiler calls//__falsetype or Typetraits<class t> T's actual type. Truetype get () function to get different bool values
struct typetraits< bool> //the following are common basic types of special {typedef __truetype __IsPODType;}; template <>struct typetraits< char>{typedef __truetype __IsPODType;}; Template <>struct typetraits< unsigned char >{typedef __truetype __IsPODType;}; template <>struct typetraits< short>{typedef __truetype __IsPODType;}; Template <>struct typetraits< unsigned short >{typedef __truetype __IsPODType;}; template <>struct typetraits< int>{typedef __truetype __IsPODType;}; Template <>struct typetraits< unsigned int >{typedef __truetype __IsPODType;}; Template <>struct typetraits< long>{typedef __truetype __ispodtype;}; Template <>struct typetraits< unsigned long >{typedef __truetype __IsPODType;}; template <>struct typetraits< long long >{typedef __truetype __IsPODType;}; Template <>struct typetraits< unsigned long long>{typedef __truetype __IsPODType;}; template <>struct typetraits< float>{typedef __truetype __IsPODType;}; template <>struct typetraits< double>{typedef __truetype __IsPODType;}; template <>struct typetraits< long double >{typedef __truetype __IsPODType;}; Template <class _tp>struct typetraits< _tp*>{typedef __truetype __ispodtype;};
C + + Type extraction (template type application)