Guest User

Untitled

a guest
Jun 29th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1.  
  2. #ifndef __E_KT_H
  3. #define __E_KT_H
  4.  
  5. #include <math.h>
  6.  
  7. template<typename T> T *kT(K x);
  8. template<typename T> int KTY();
  9. template<typename T> T KNULL();
  10. template<typename T> bool KISNULL(T v);
  11. template<typename T> char *strT(T x);
  12.  
  13. template<> inline I *kT<I>(K x) { return kI(x); }
  14. template<> inline J *kT<J>(K x) { return kJ(x); }
  15. template<> inline F *kT<F>(K x) { return kF(x); }
  16.  
  17. template<> inline int KTY<I>() { return KI; }
  18. template<> inline int KTY<J>() { return KJ; }
  19. template<> inline int KTY<F>() { return KF; }
  20. template<> inline char * strT<I>(I x) {
  21.     static char b[100];
  22.     sprintf(b,"%d",x);
  23.     return b;
  24.  }
  25.  
  26. template<int ty> class KTy {};
  27. template<> class KTy<KJ> { using type = J; };
  28. template<> class KTy<KI> { using type = I; };
  29. template<> class KTy<KF> { using type = F; };
  30.  
  31. template<> inline F KNULL<F>() { return nf; }
  32. template<> inline I KNULL<I>() { return 0x7FFFFFFF; }
  33. template<> inline J KNULL<J>() { return 0x7FFFFFFFFFFFFFFFL; }
  34. template<> inline bool KISNULL<F>(F v) { return isnan(v); }
  35. template<> inline bool KISNULL<I>(I v) { return v == KNULL<I>(); }
  36. template<> inline bool KISNULL<J>(J v) { return v == KNULL<J>(); }
  37.  
  38. #endif
Advertisement
Add Comment
Please, Sign In to add comment