File indexing completed on 2025-01-18 09:53:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_TT_MAKE_UNSIGNED_HPP_INCLUDED
0010 #define BOOST_TT_MAKE_UNSIGNED_HPP_INCLUDED
0011
0012 #include <boost/type_traits/conditional.hpp>
0013 #include <boost/type_traits/is_integral.hpp>
0014 #include <boost/type_traits/is_signed.hpp>
0015 #include <boost/type_traits/is_unsigned.hpp>
0016 #include <boost/type_traits/is_enum.hpp>
0017 #include <boost/type_traits/is_same.hpp>
0018 #include <boost/type_traits/remove_cv.hpp>
0019 #include <boost/type_traits/is_const.hpp>
0020 #include <boost/type_traits/is_volatile.hpp>
0021 #include <boost/type_traits/add_const.hpp>
0022 #include <boost/type_traits/add_volatile.hpp>
0023 #include <boost/static_assert.hpp>
0024
0025 namespace boost {
0026
0027 template <class T>
0028 struct make_unsigned
0029 {
0030 private:
0031 BOOST_STATIC_ASSERT_MSG((::boost::is_integral<T>::value || ::boost::is_enum<T>::value), "The template argument to make_unsigned must be an integer or enum type.");
0032 BOOST_STATIC_ASSERT_MSG((! ::boost::is_same<typename remove_cv<T>::type, bool>::value), "The template argument to make_unsigned must not be the type bool");
0033
0034 typedef typename remove_cv<T>::type t_no_cv;
0035 typedef typename conditional<
0036 (::boost::is_unsigned<T>::value && ::boost::is_integral<T>::value
0037 && ! ::boost::is_same<t_no_cv, char>::value
0038 && ! ::boost::is_same<t_no_cv, wchar_t>::value
0039 && ! ::boost::is_same<t_no_cv, bool>::value),
0040 T,
0041 typename conditional<
0042 (::boost::is_integral<T>::value
0043 && ! ::boost::is_same<t_no_cv, char>::value
0044 && ! ::boost::is_same<t_no_cv, wchar_t>::value
0045 && ! ::boost::is_same<t_no_cv, bool>::value),
0046 typename conditional<
0047 is_same<t_no_cv, signed char>::value,
0048 unsigned char,
0049 typename conditional<
0050 is_same<t_no_cv, short>::value,
0051 unsigned short,
0052 typename conditional<
0053 is_same<t_no_cv, int>::value,
0054 unsigned int,
0055 typename conditional<
0056 is_same<t_no_cv, long>::value,
0057 unsigned long,
0058 #if defined(BOOST_HAS_LONG_LONG)
0059 #ifdef BOOST_HAS_INT128
0060 typename conditional<
0061 sizeof(t_no_cv) == sizeof(boost::ulong_long_type),
0062 boost::ulong_long_type,
0063 boost::uint128_type
0064 >::type
0065 #else
0066 boost::ulong_long_type
0067 #endif
0068 #elif defined(BOOST_HAS_MS_INT64)
0069 unsigned __int64
0070 #else
0071 unsigned long
0072 #endif
0073 >::type
0074 >::type
0075 >::type
0076 >::type,
0077
0078 typename conditional<
0079 sizeof(t_no_cv) == sizeof(unsigned char),
0080 unsigned char,
0081 typename conditional<
0082 sizeof(t_no_cv) == sizeof(unsigned short),
0083 unsigned short,
0084 typename conditional<
0085 sizeof(t_no_cv) == sizeof(unsigned int),
0086 unsigned int,
0087 typename conditional<
0088 sizeof(t_no_cv) == sizeof(unsigned long),
0089 unsigned long,
0090 #if defined(BOOST_HAS_LONG_LONG)
0091 #ifdef BOOST_HAS_INT128
0092 typename conditional<
0093 sizeof(t_no_cv) == sizeof(boost::ulong_long_type),
0094 boost::ulong_long_type,
0095 boost::uint128_type
0096 >::type
0097 #else
0098 boost::ulong_long_type
0099 #endif
0100 #elif defined(BOOST_HAS_MS_INT64)
0101 unsigned __int64
0102 #else
0103 unsigned long
0104 #endif
0105 >::type
0106 >::type
0107 >::type
0108 >::type
0109 >::type
0110 >::type base_integer_type;
0111
0112
0113 typedef typename conditional<
0114 is_const<T>::value,
0115 typename add_const<base_integer_type>::type,
0116 base_integer_type
0117 >::type const_base_integer_type;
0118 public:
0119
0120 typedef typename conditional<
0121 is_volatile<T>::value,
0122 typename add_volatile<const_base_integer_type>::type,
0123 const_base_integer_type
0124 >::type type;
0125 };
0126
0127 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
0128
0129 template <class T> using make_unsigned_t = typename make_unsigned<T>::type;
0130
0131 #endif
0132
0133 }
0134
0135 #endif
0136