traits.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
  2. #define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
  3. #if defined(_MSC_VER) || \
  4. (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
  5. (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
  6. #pragma once
  7. #endif
  8. namespace YAML {
  9. template <typename>
  10. struct is_numeric {
  11. enum { value = false };
  12. };
  13. template <>
  14. struct is_numeric<char> {
  15. enum { value = true };
  16. };
  17. template <>
  18. struct is_numeric<unsigned char> {
  19. enum { value = true };
  20. };
  21. template <>
  22. struct is_numeric<int> {
  23. enum { value = true };
  24. };
  25. template <>
  26. struct is_numeric<unsigned int> {
  27. enum { value = true };
  28. };
  29. template <>
  30. struct is_numeric<long int> {
  31. enum { value = true };
  32. };
  33. template <>
  34. struct is_numeric<unsigned long int> {
  35. enum { value = true };
  36. };
  37. template <>
  38. struct is_numeric<short int> {
  39. enum { value = true };
  40. };
  41. template <>
  42. struct is_numeric<unsigned short int> {
  43. enum { value = true };
  44. };
  45. #if defined(_MSC_VER) && (_MSC_VER < 1310)
  46. template <>
  47. struct is_numeric<__int64> {
  48. enum { value = true };
  49. };
  50. template <>
  51. struct is_numeric<unsigned __int64> {
  52. enum { value = true };
  53. };
  54. #else
  55. template <>
  56. struct is_numeric<long long> {
  57. enum { value = true };
  58. };
  59. template <>
  60. struct is_numeric<unsigned long long> {
  61. enum { value = true };
  62. };
  63. #endif
  64. template <>
  65. struct is_numeric<float> {
  66. enum { value = true };
  67. };
  68. template <>
  69. struct is_numeric<double> {
  70. enum { value = true };
  71. };
  72. template <>
  73. struct is_numeric<long double> {
  74. enum { value = true };
  75. };
  76. template <bool, class T = void>
  77. struct enable_if_c {
  78. typedef T type;
  79. };
  80. template <class T>
  81. struct enable_if_c<false, T> {};
  82. template <class Cond, class T = void>
  83. struct enable_if : public enable_if_c<Cond::value, T> {};
  84. template <bool, class T = void>
  85. struct disable_if_c {
  86. typedef T type;
  87. };
  88. template <class T>
  89. struct disable_if_c<true, T> {};
  90. template <class Cond, class T = void>
  91. struct disable_if : public disable_if_c<Cond::value, T> {};
  92. }
  93. #endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66