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