is_integral.hpp 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. //
  6. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  7. #ifndef BOOST_TT_IS_INTEGRAL_HPP_INCLUDED
  8. #define BOOST_TT_IS_INTEGRAL_HPP_INCLUDED
  9. #include <boost/config.hpp>
  10. #include <boost/type_traits/integral_constant.hpp>
  11. namespace boost {
  12. #if defined( __CODEGEARC__ )
  13. template <class T>
  14. struct is_integral : public integral_constant<bool, __is_integral(T)> {};
  15. #else
  16. template <class T> struct is_integral : public false_type {};
  17. template <class T> struct is_integral<const T> : public is_integral<T> {};
  18. template <class T> struct is_integral<volatile const T> : public is_integral<T>{};
  19. template <class T> struct is_integral<volatile T> : public is_integral<T>{};
  20. //* is a type T an [cv-qualified-] integral type described in the standard (3.9.1p3)
  21. // as an extension we include long long, as this is likely to be added to the
  22. // standard at a later date
  23. template<> struct is_integral<unsigned char> : public true_type {};
  24. template<> struct is_integral<unsigned short> : public true_type{};
  25. template<> struct is_integral<unsigned int> : public true_type{};
  26. template<> struct is_integral<unsigned long> : public true_type{};
  27. template<> struct is_integral<signed char> : public true_type{};
  28. template<> struct is_integral<short> : public true_type{};
  29. template<> struct is_integral<int> : public true_type{};
  30. template<> struct is_integral<long> : public true_type{};
  31. template<> struct is_integral<char> : public true_type{};
  32. template<> struct is_integral<bool> : public true_type{};
  33. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  34. // If the following line fails to compile and you're using the Intel
  35. // compiler, see http://lists.boost.org/MailArchives/boost-users/msg06567.php,
  36. // and define BOOST_NO_INTRINSIC_WCHAR_T on the command line.
  37. template<> struct is_integral<wchar_t> : public true_type{};
  38. #endif
  39. // Same set of integral types as in boost/type_traits/integral_promotion.hpp.
  40. // Please, keep in sync. -- Alexander Nasonov
  41. #if (defined(BOOST_INTEL_CXX_VERSION) && defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 600)) \
  42. || (defined(__BORLANDC__) && (__BORLANDC__ == 0x600) && (_MSC_VER < 1300))
  43. template<> struct is_integral<unsigned __int8> : public true_type{};
  44. template<> struct is_integral<unsigned __int16> : public true_type{};
  45. template<> struct is_integral<unsigned __int32> : public true_type{};
  46. template<> struct is_integral<__int8> : public true_type{};
  47. template<> struct is_integral<__int16> : public true_type{};
  48. template<> struct is_integral<__int32> : public true_type{};
  49. #ifdef __BORLANDC__
  50. template<> struct is_integral<unsigned __int64> : public true_type{};
  51. template<> struct is_integral<__int64> : public true_type{};
  52. #endif
  53. #endif
  54. # if defined(BOOST_HAS_LONG_LONG)
  55. template<> struct is_integral< ::boost::ulong_long_type> : public true_type{};
  56. template<> struct is_integral< ::boost::long_long_type> : public true_type{};
  57. #elif defined(BOOST_HAS_MS_INT64)
  58. template<> struct is_integral<unsigned __int64> : public true_type{};
  59. template<> struct is_integral<__int64> : public true_type{};
  60. #endif
  61. #ifdef BOOST_HAS_INT128
  62. template<> struct is_integral<boost::int128_type> : public true_type{};
  63. template<> struct is_integral<boost::uint128_type> : public true_type{};
  64. #endif
  65. #ifndef BOOST_NO_CXX11_CHAR16_T
  66. template<> struct is_integral<char16_t> : public true_type{};
  67. #endif
  68. #ifndef BOOST_NO_CXX11_CHAR32_T
  69. template<> struct is_integral<char32_t> : public true_type{};
  70. #endif
  71. #endif // non-CodeGear implementation
  72. } // namespace boost
  73. #endif // BOOST_TT_IS_INTEGRAL_HPP_INCLUDED