source: NonGTP/Boost/boost/type_traits/is_signed.hpp @ 857

Revision 857, 4.1 KB checked in by igarcia, 18 years ago (diff)
Line 
1
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).
6//
7//  See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
9
10#ifndef BOOST_TT_IS_SIGNED_HPP_INCLUDED
11#define BOOST_TT_IS_SIGNED_HPP_INCLUDED
12
13#include "boost/type_traits/is_integral.hpp"
14#include "boost/type_traits/is_enum.hpp"
15#include "boost/type_traits/detail/ice_or.hpp"
16
17// should be the last #include
18#include "boost/type_traits/detail/bool_trait_def.hpp"
19
20namespace boost {
21
22namespace detail{
23
24#if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238)
25
26template <class T>
27struct is_signed_helper
28{
29   BOOST_STATIC_CONSTANT(bool, value = (static_cast<T>(-1) < 0));
30};
31
32template <bool integral_type>
33struct is_signed_select_helper
34{
35   template <class T>
36   struct rebind
37   {
38      typedef is_signed_helper<T> type;
39   };
40};
41
42template <>
43struct is_signed_select_helper<false>
44{
45   template <class T>
46   struct rebind
47   {
48      typedef false_type type;
49   };
50};
51
52template <class T>
53struct is_signed_imp
54{
55   typedef is_signed_select_helper<
56      ::boost::type_traits::ice_or<
57         ::boost::is_integral<T>::value,
58         ::boost::is_enum<T>::value>::value
59   > selector;
60   typedef typename selector::template rebind<T> binder;
61   typedef typename binder::type type;
62#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
63   BOOST_STATIC_CONSTANT(bool, value = is_signed_imp<T>::type::value);
64#else
65   BOOST_STATIC_CONSTANT(bool, value = type::value);
66#endif
67};
68
69#else
70
71template <class T> struct is_signed_imp : public false_type{};
72template <> struct is_signed_imp<signed char> : public true_type{};
73template <> struct is_signed_imp<const signed char> : public true_type{};
74template <> struct is_signed_imp<volatile signed char> : public true_type{};
75template <> struct is_signed_imp<const volatile signed char> : public true_type{};
76template <> struct is_signed_imp<short> : public true_type{};
77template <> struct is_signed_imp<const short> : public true_type{};
78template <> struct is_signed_imp<volatile short> : public true_type{};
79template <> struct is_signed_imp<const volatile short> : public true_type{};
80template <> struct is_signed_imp<int> : public true_type{};
81template <> struct is_signed_imp<const int> : public true_type{};
82template <> struct is_signed_imp<volatile int> : public true_type{};
83template <> struct is_signed_imp<const volatile int> : public true_type{};
84template <> struct is_signed_imp<long> : public true_type{};
85template <> struct is_signed_imp<const long> : public true_type{};
86template <> struct is_signed_imp<volatile long> : public true_type{};
87template <> struct is_signed_imp<const volatile long> : public true_type{};
88#ifdef BOOST_HAS_LONG_LONG
89template <> struct is_signed_imp<long long> : public true_type{};
90template <> struct is_signed_imp<const long long> : public true_type{};
91template <> struct is_signed_imp<volatile long long> : public true_type{};
92template <> struct is_signed_imp<const volatile long long> : public true_type{};
93#endif
94#if defined(CHAR_MIN) && (CHAR_MIN != 0)
95template <> struct is_signed_imp<char> : public true_type{};
96template <> struct is_signed_imp<const char> : public true_type{};
97template <> struct is_signed_imp<volatile char> : public true_type{};
98template <> struct is_signed_imp<const volatile char> : public true_type{};
99#endif
100#if defined(WCHAR_MIN) && (WCHAR_MIN != 0)
101template <> struct is_signed_imp<wchar_t> : public true_type{};
102template <> struct is_signed_imp<const wchar_t> : public true_type{};
103template <> struct is_signed_imp<volatile wchar_t> : public true_type{};
104template <> struct is_signed_imp<const volatile wchar_t> : public true_type{};
105#endif
106
107#endif
108
109}
110
111BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_signed,T,::boost::detail::is_signed_imp<T>::value)
112
113} // namespace boost
114
115#include "boost/type_traits/detail/bool_trait_undef.hpp"
116
117#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.