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>
16 #include <boost/type_traits/detail/ice_or.hpp>
18 // should be the last #include
19 #include <boost/type_traits/detail/bool_trait_def.hpp>
23 #if !defined( __CODEGEARC__ )
27 #if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238) && !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_ununsigned_select_helper
54 typedef is_ununsigned_helper<T> type;
59 struct is_ununsigned_select_helper<false>
64 typedef false_type type;
69 struct is_unsigned_imp
71 typedef is_ununsigned_select_helper<
72 ::boost::type_traits::ice_or<
73 ::boost::is_integral<T>::value,
74 ::boost::is_enum<T>::value>::value
76 typedef typename selector::template rebind<T> binder;
77 typedef typename binder::type type;
78 BOOST_STATIC_CONSTANT(bool, value = type::value);
83 template <class T> struct is_unsigned_imp : public false_type{};
84 template <> struct is_unsigned_imp<unsigned char> : public true_type{};
85 template <> struct is_unsigned_imp<const unsigned char> : public true_type{};
86 template <> struct is_unsigned_imp<volatile unsigned char> : public true_type{};
87 template <> struct is_unsigned_imp<const volatile unsigned char> : public true_type{};
88 template <> struct is_unsigned_imp<unsigned short> : public true_type{};
89 template <> struct is_unsigned_imp<const unsigned short> : public true_type{};
90 template <> struct is_unsigned_imp<volatile unsigned short> : public true_type{};
91 template <> struct is_unsigned_imp<const volatile unsigned short> : public true_type{};
92 template <> struct is_unsigned_imp<unsigned int> : public true_type{};
93 template <> struct is_unsigned_imp<const unsigned int> : public true_type{};
94 template <> struct is_unsigned_imp<volatile unsigned int> : public true_type{};
95 template <> struct is_unsigned_imp<const volatile unsigned int> : public true_type{};
96 template <> struct is_unsigned_imp<unsigned long> : public true_type{};
97 template <> struct is_unsigned_imp<const unsigned long> : public true_type{};
98 template <> struct is_unsigned_imp<volatile unsigned long> : public true_type{};
99 template <> struct is_unsigned_imp<const volatile unsigned long> : public true_type{};
100 #ifdef BOOST_HAS_LONG_LONG
101 template <> struct is_unsigned_imp<unsigned long long> : public true_type{};
102 template <> struct is_unsigned_imp<const unsigned long long> : public true_type{};
103 template <> struct is_unsigned_imp<volatile unsigned long long> : public true_type{};
104 template <> struct is_unsigned_imp<const volatile unsigned long long> : public true_type{};
106 #if defined(CHAR_MIN) && (CHAR_MIN == 0)
107 template <> struct is_unsigned_imp<char> : public true_type{};
108 template <> struct is_unsigned_imp<const char> : public true_type{};
109 template <> struct is_unsigned_imp<volatile char> : public true_type{};
110 template <> struct is_unsigned_imp<const volatile char> : public true_type{};
112 #if defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
113 template <> struct is_unsigned_imp<wchar_t> : public true_type{};
114 template <> struct is_unsigned_imp<const wchar_t> : public true_type{};
115 template <> struct is_unsigned_imp<volatile wchar_t> : public true_type{};
116 template <> struct is_unsigned_imp<const volatile wchar_t> : public true_type{};
123 #endif // !defined( __CODEGEARC__ )
125 #if defined( __CODEGEARC__ )
126 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_unsigned,T,__is_unsigned(T))
128 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_unsigned,T,::boost::detail::is_unsigned_imp<T>::value)
133 #include <boost/type_traits/detail/bool_trait_undef.hpp>
135 #endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED