std_integer_traits.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ///////////////////////////////////////////////////////////////
  2. // Copyright 2012 John Maddock. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_MP_STD_INTEGER_TRAITS_HPP
  6. #define BOOST_MP_STD_INTEGER_TRAITS_HPP
  7. #include <type_traits>
  8. namespace boost {
  9. namespace multiprecision {
  10. namespace detail {
  11. template <class T>
  12. struct is_signed : public std::is_signed<T> {};
  13. template <class T>
  14. struct is_unsigned : public std::is_unsigned<T> {};
  15. template <class T>
  16. struct is_integral : public std::is_integral<T> {};
  17. template <class T>
  18. struct is_arithmetic : public std::is_arithmetic<T> {};
  19. template <class T>
  20. struct make_unsigned : public std::make_unsigned<T> {};
  21. template <class T>
  22. struct make_signed : public std::make_signed<T> {};
  23. #ifdef BOOST_HAS_INT128
  24. template <>
  25. struct is_signed<__int128> : public std::integral_constant<bool, true> {};
  26. template <>
  27. struct is_signed<unsigned __int128> : public std::integral_constant<bool, false> {};
  28. template <>
  29. struct is_unsigned<__int128> : public std::integral_constant<bool, false> {};
  30. template <>
  31. struct is_unsigned<unsigned __int128> : public std::integral_constant<bool, true> {};
  32. template <>
  33. struct is_integral<__int128> : public std::integral_constant<bool, true> {};
  34. template <>
  35. struct is_integral<unsigned __int128> : public std::integral_constant<bool, true> {};
  36. template <>
  37. struct is_arithmetic<__int128> : public std::integral_constant<bool, true> {};
  38. template <>
  39. struct is_arithmetic<unsigned __int128> : public std::integral_constant<bool, true> {};
  40. template <>
  41. struct make_unsigned<__int128>
  42. {
  43. using type = unsigned __int128;
  44. };
  45. template <>
  46. struct make_unsigned<unsigned __int128>
  47. {
  48. using type = unsigned __int128;
  49. };
  50. template <>
  51. struct make_signed<__int128>
  52. {
  53. using type = __int128;
  54. };
  55. template <>
  56. struct make_signed<unsigned __int128>
  57. {
  58. using type = __int128;
  59. };
  60. #endif
  61. }}} // namespace boost::multiprecision::detail
  62. #endif