#include using namespace std; // Some small applications when template exercises, identify basic types and custom types // How to use limited basic types, without his // basic class template enumeration non-basic type Template Class ISFoundationType {public: enum {yes = 0, no = 1};}; // Macro Definition Macro_Foundation_TYPE (T) Chart Sequential Call Feature All // Basic Data Type Enumeration is YES = 1 # define Macro_foundation_type (t) / template <> class isfoundationType / {/ public: / enum {yes = 1, no = 0}; /}; /// use macros to get the most special instance point macro_foundation_type void) MACRO_FOUNDATION_TYPE (bool) MACRO_FOUNDATION_TYPE (char) MACRO_FOUNDATION_TYPE (unsigned char) MACRO_FOUNDATION_TYPE (wchar_t) MACRO_FOUNDATION_TYPE (short) MACRO_FOUNDATION_TYPE (signed int) MACRO_FOUNDATION_TYPE (unsigned int) MACRO_FOUNDATION_TYPE (signed long) MACRO_FOUNDATION_TYPE (unsigned long)
#if longlong_exists macro_foundation_type (Signed long long) macro_foundation_type (unsigned long long) #ENDIF
Macro_foundation_type (double) macro_foundation_type (float) macro_foundation_type (long double) // Test function template, you can see very simple but this kind of thought // is more useful, exhaustive limited number matching. Template Void Test (ISFoundationType :: YES) {cout << "t is fundamental type" <<} else {cout << "t isn't Fundamental Type "<< Endl;} f (isdouble :: yes) {cout <<" t is double type "<< end1;} else {cout <<" t isn't double type "<< Endl;}}