2 // (C) Copyright John Maddock 2007.
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
9 #ifndef BOOST_TT_MAKE_UNSIGNED_HPP_INCLUDED
10 #define BOOST_TT_MAKE_UNSIGNED_HPP_INCLUDED
12 #include <boost/mpl/if.hpp>
13 #include <boost/type_traits/is_integral.hpp>
14 #include <boost/type_traits/is_signed.hpp>
15 #include <boost/type_traits/is_unsigned.hpp>
16 #include <boost/type_traits/is_enum.hpp>
17 #include <boost/type_traits/is_same.hpp>
18 #include <boost/type_traits/remove_cv.hpp>
19 #include <boost/type_traits/is_const.hpp>
20 #include <boost/type_traits/is_volatile.hpp>
21 #include <boost/type_traits/add_const.hpp>
22 #include <boost/type_traits/add_volatile.hpp>
23 #include <boost/type_traits/detail/ice_or.hpp>
24 #include <boost/type_traits/detail/ice_and.hpp>
25 #include <boost/type_traits/detail/ice_not.hpp>
26 #include <boost/static_assert.hpp>
28 // should be the last #include
29 #include <boost/type_traits/detail/type_trait_def.hpp>
36 struct make_unsigned_imp
39 (::boost::type_traits::ice_or< ::boost::is_integral<T>::value, ::boost::is_enum<T>::value>::value));
40 #if !BOOST_WORKAROUND(BOOST_MSVC, <=1300)
42 (::boost::type_traits::ice_not< ::boost::is_same<
43 typename remove_cv<T>::type, bool>::value>::value));
46 typedef typename remove_cv<T>::type t_no_cv;
47 typedef typename mpl::if_c<
48 (::boost::type_traits::ice_and<
49 ::boost::is_unsigned<T>::value,
50 ::boost::is_integral<T>::value,
51 ::boost::type_traits::ice_not< ::boost::is_same<t_no_cv, char>::value>::value,
52 ::boost::type_traits::ice_not< ::boost::is_same<t_no_cv, wchar_t>::value>::value,
53 ::boost::type_traits::ice_not< ::boost::is_same<t_no_cv, bool>::value>::value >::value),
56 (::boost::type_traits::ice_and<
57 ::boost::is_integral<T>::value,
58 ::boost::type_traits::ice_not< ::boost::is_same<t_no_cv, char>::value>::value,
59 ::boost::type_traits::ice_not< ::boost::is_same<t_no_cv, wchar_t>::value>::value,
60 ::boost::type_traits::ice_not< ::boost::is_same<t_no_cv, bool>::value>::value>
63 is_same<t_no_cv, signed char>,
66 is_same<t_no_cv, short>,
69 is_same<t_no_cv, int>,
72 is_same<t_no_cv, long>,
74 #if defined(BOOST_HAS_LONG_LONG)
75 #ifdef BOOST_HAS_INT128
77 sizeof(t_no_cv) == sizeof(boost::ulong_long_type),
78 boost::ulong_long_type,
82 boost::ulong_long_type
84 #elif defined(BOOST_HAS_MS_INT64)
93 // Not a regular integer type:
95 sizeof(t_no_cv) == sizeof(unsigned char),
98 sizeof(t_no_cv) == sizeof(unsigned short),
101 sizeof(t_no_cv) == sizeof(unsigned int),
104 sizeof(t_no_cv) == sizeof(unsigned long),
106 #if defined(BOOST_HAS_LONG_LONG)
107 #ifdef BOOST_HAS_INT128
109 sizeof(t_no_cv) == sizeof(boost::ulong_long_type),
110 boost::ulong_long_type,
114 boost::ulong_long_type
116 #elif defined(BOOST_HAS_MS_INT64)
126 >::type base_integer_type;
128 // Add back any const qualifier:
129 typedef typename mpl::if_<
131 typename add_const<base_integer_type>::type,
133 >::type const_base_integer_type;
135 // Add back any volatile qualifier:
136 typedef typename mpl::if_<
138 typename add_volatile<const_base_integer_type>::type,
139 const_base_integer_type
144 } // namespace detail
146 BOOST_TT_AUX_TYPE_TRAIT_DEF1(make_unsigned,T,typename boost::detail::make_unsigned_imp<T>::type)
150 #include <boost/type_traits/detail/type_trait_undef.hpp>
152 #endif // BOOST_TT_ADD_REFERENCE_HPP_INCLUDED