/Src/Dependencies/Boost/boost/spirit/home/support/numeric_traits.hpp

http://hadesmem.googlecode.com/ · C++ Header · 118 lines · 69 code · 30 blank · 19 comment · 0 complexity · bb787302c4d49e7193b960841e5cbf5f MD5 · raw file

  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #if !defined(BOOST_SPIRIT_NUMERIC_TRAITS_JAN_07_2011_0722AM)
  6. #define BOOST_SPIRIT_NUMERIC_TRAITS_JAN_07_2011_0722AM
  7. #if defined(_MSC_VER)
  8. #pragma once
  9. #endif
  10. #include <boost/config.hpp>
  11. #include <boost/mpl/bool.hpp>
  12. namespace boost { namespace spirit { namespace traits
  13. {
  14. ///////////////////////////////////////////////////////////////////////////
  15. // Determine if T is a boolean type
  16. ///////////////////////////////////////////////////////////////////////////
  17. template <typename T>
  18. struct is_bool : mpl::false_ {};
  19. template <typename T>
  20. struct is_bool<T const> : is_bool<T> {};
  21. template <>
  22. struct is_bool<bool> : mpl::true_ {};
  23. ///////////////////////////////////////////////////////////////////////////
  24. // Determine if T is a signed integer type
  25. ///////////////////////////////////////////////////////////////////////////
  26. template <typename T>
  27. struct is_int : mpl::false_ {};
  28. template <typename T>
  29. struct is_int<T const> : is_int<T> {};
  30. template <>
  31. struct is_int<short> : mpl::true_ {};
  32. template <>
  33. struct is_int<int> : mpl::true_ {};
  34. template <>
  35. struct is_int<long> : mpl::true_ {};
  36. #ifdef BOOST_HAS_LONG_LONG
  37. template <>
  38. struct is_int<boost::long_long_type> : mpl::true_ {};
  39. #endif
  40. ///////////////////////////////////////////////////////////////////////////
  41. // Determine if T is an unsigned integer type
  42. ///////////////////////////////////////////////////////////////////////////
  43. template <typename T>
  44. struct is_uint : mpl::false_ {};
  45. template <typename T>
  46. struct is_uint<T const> : is_uint<T> {};
  47. #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
  48. template <>
  49. struct is_uint<unsigned short> : mpl::true_ {};
  50. #endif
  51. template <>
  52. struct is_uint<unsigned int> : mpl::true_ {};
  53. template <>
  54. struct is_uint<unsigned long> : mpl::true_ {};
  55. #ifdef BOOST_HAS_LONG_LONG
  56. template <>
  57. struct is_uint<boost::ulong_long_type> : mpl::true_ {};
  58. #endif
  59. ///////////////////////////////////////////////////////////////////////////
  60. // Determine if T is a floating point type
  61. ///////////////////////////////////////////////////////////////////////////
  62. template <typename T>
  63. struct is_real : mpl::false_ {};
  64. template <typename T>
  65. struct is_real<T const> : is_uint<T> {};
  66. template <>
  67. struct is_real<float> : mpl::true_ {};
  68. template <>
  69. struct is_real<double> : mpl::true_ {};
  70. template <>
  71. struct is_real<long double> : mpl::true_ {};
  72. ///////////////////////////////////////////////////////////////////////////
  73. // customization points for numeric operations
  74. ///////////////////////////////////////////////////////////////////////////
  75. template <typename T, typename Enable = void>
  76. struct absolute_value;
  77. template <typename T, typename Enable = void>
  78. struct is_negative;
  79. template <typename T, typename Enable = void>
  80. struct is_zero;
  81. template <typename T, typename Enable = void>
  82. struct pow10_helper;
  83. template <typename T, typename Enable = void>
  84. struct is_nan;
  85. template <typename T, typename Enable = void>
  86. struct is_infinite;
  87. }}}
  88. #endif