2 // (C) Copyright John Maddock 2005.
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.
10 #ifndef BOOST_TT_IS_UNSIGNED_HPP_INCLUDED
11 #define BOOST_TT_IS_UNSIGNED_HPP_INCLUDED
13 #include <boost/type_traits/is_integral.hpp>
14 #include <boost/type_traits/is_enum.hpp>
15 #include <boost/type_traits/remove_cv.hpp>
21 #if !defined( __CODEGEARC__ )
23 #if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1310) &&\
24 !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238) &&\
25 !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
30 struct is_unsigned_values
33 // Note that we cannot use BOOST_STATIC_CONSTANT here, using enum's
34 // rather than "real" static constants simply doesn't work or give
35 // the correct answer.
37 typedef typename remove_cv<T>::type no_cv_t;
38 static const no_cv_t minus_one = (static_cast<no_cv_t>(-1));
39 static const no_cv_t zero = (static_cast<no_cv_t>(0));
43 struct is_ununsigned_helper
45 BOOST_STATIC_CONSTANT(bool, value = (::boost::detail::is_unsigned_values<T>::minus_one > ::boost::detail::is_unsigned_values<T>::zero));
48 template <bool integral_type>
49 struct is_unsigned_select_helper
54 typedef is_ununsigned_helper<T> type;
59 struct is_unsigned_select_helper<false>
64 typedef false_type type;
71 typedef ::boost::detail::is_unsigned_select_helper< ::boost::is_integral<T>::value || ::boost::is_enum<T>::value > selector;
72 typedef typename selector::template rebind<T> binder;
73 typedef typename binder::type type;
74 BOOST_STATIC_CONSTANT(bool, value = type::value);
79 template <class T> struct is_unsigned : public integral_constant<bool, boost::detail::is_unsigned<T>::value> {};
83 template <class T> struct is_unsigned : public false_type{};
87 #else // defined( __CODEGEARC__ )
88 template <class T> struct is_unsigned : public integral_constant<bool, __is_unsigned(T)> {};
91 template <> struct is_unsigned<unsigned char> : public true_type{};
92 template <> struct is_unsigned<const unsigned char> : public true_type{};
93 template <> struct is_unsigned<volatile unsigned char> : public true_type{};
94 template <> struct is_unsigned<const volatile unsigned char> : public true_type{};
95 template <> struct is_unsigned<unsigned short> : public true_type{};
96 template <> struct is_unsigned<const unsigned short> : public true_type{};
97 template <> struct is_unsigned<volatile unsigned short> : public true_type{};
98 template <> struct is_unsigned<const volatile unsigned short> : public true_type{};
99 template <> struct is_unsigned<unsigned int> : public true_type{};
100 template <> struct is_unsigned<const unsigned int> : public true_type{};
101 template <> struct is_unsigned<volatile unsigned int> : public true_type{};
102 template <> struct is_unsigned<const volatile unsigned int> : public true_type{};
103 template <> struct is_unsigned<unsigned long> : public true_type{};
104 template <> struct is_unsigned<const unsigned long> : public true_type{};
105 template <> struct is_unsigned<volatile unsigned long> : public true_type{};
106 template <> struct is_unsigned<const volatile unsigned long> : public true_type{};
108 template <> struct is_unsigned<signed char> : public false_type{};
109 template <> struct is_unsigned<const signed char> : public false_type{};
110 template <> struct is_unsigned<volatile signed char> : public false_type{};
111 template <> struct is_unsigned<const volatile signed char> : public false_type{};
112 template <> struct is_unsigned< short> : public false_type{};
113 template <> struct is_unsigned<const short> : public false_type{};
114 template <> struct is_unsigned<volatile short> : public false_type{};
115 template <> struct is_unsigned<const volatile short> : public false_type{};
116 template <> struct is_unsigned< int> : public false_type{};
117 template <> struct is_unsigned<const int> : public false_type{};
118 template <> struct is_unsigned<volatile int> : public false_type{};
119 template <> struct is_unsigned<const volatile int> : public false_type{};
120 template <> struct is_unsigned< long> : public false_type{};
121 template <> struct is_unsigned<const long> : public false_type{};
122 template <> struct is_unsigned<volatile long> : public false_type{};
123 template <> struct is_unsigned<const volatile long> : public false_type{};
124 #ifdef BOOST_HAS_LONG_LONG
125 template <> struct is_unsigned< ::boost::ulong_long_type> : public true_type{};
126 template <> struct is_unsigned<const ::boost::ulong_long_type> : public true_type{};
127 template <> struct is_unsigned<volatile ::boost::ulong_long_type> : public true_type{};
128 template <> struct is_unsigned<const volatile ::boost::ulong_long_type> : public true_type{};
130 template <> struct is_unsigned< ::boost::long_long_type> : public false_type{};
131 template <> struct is_unsigned<const ::boost::long_long_type> : public false_type{};
132 template <> struct is_unsigned<volatile ::boost::long_long_type> : public false_type{};
133 template <> struct is_unsigned<const volatile ::boost::long_long_type> : public false_type{};
135 #if defined(CHAR_MIN)
137 template <> struct is_unsigned<char> : public true_type{};
138 template <> struct is_unsigned<const char> : public true_type{};
139 template <> struct is_unsigned<volatile char> : public true_type{};
140 template <> struct is_unsigned<const volatile char> : public true_type{};
142 template <> struct is_unsigned<char> : public false_type{};
143 template <> struct is_unsigned<const char> : public false_type{};
144 template <> struct is_unsigned<volatile char> : public false_type{};
145 template <> struct is_unsigned<const volatile char> : public false_type{};
148 #if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(WCHAR_MIN)
150 template <> struct is_unsigned<wchar_t> : public true_type{};
151 template <> struct is_unsigned<const wchar_t> : public true_type{};
152 template <> struct is_unsigned<volatile wchar_t> : public true_type{};
153 template <> struct is_unsigned<const volatile wchar_t> : public true_type{};
155 template <> struct is_unsigned<wchar_t> : public false_type{};
156 template <> struct is_unsigned<const wchar_t> : public false_type{};
157 template <> struct is_unsigned<volatile wchar_t> : public false_type{};
158 template <> struct is_unsigned<const volatile wchar_t> : public false_type{};
163 #endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED