Stxxl  1.3.2
type_traits.h
1 /***************************************************************************
2  * include/stxxl/bits/compat/type_traits.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2009-2011 Andreas Beckmann <[email protected]>
7  *
8  * Distributed under the Boost Software License, Version 1.0.
9  * (See accompanying file LICENSE_1_0.txt or copy at
10  * http://www.boost.org/LICENSE_1_0.txt)
11  **************************************************************************/
12 
13 #ifndef STXXL_HEADER__COMPAT_TYPE_TRAITS_H_
14 #define STXXL_HEADER__COMPAT_TYPE_TRAITS_H_
15 
16 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
17 #include <type_traits>
18 #elif defined(__GNUG__) && (__GNUC__ >= 4)
19 #include <tr1/type_traits>
20 #elif defined(STXXL_BOOST_CONFIG)
21 #include <boost/type_traits/remove_const.hpp>
22 #endif
23 
24 #include <stxxl/bits/namespace.h>
25 
26 
27 __STXXL_BEGIN_NAMESPACE
28 
29 namespace compat
30 {
31 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
32  using std::remove_const;
33 #elif defined(__GNUG__) && (__GNUC__ >= 4)
34  using std::tr1::remove_const;
35 #elif defined(STXXL_BOOST_CONFIG)
36  using boost::remove_const;
37 #else
38  template <typename _Tp>
39  struct remove_const
40  {
41  typedef _Tp type;
42  };
43 
44  template <typename _Tp>
45  struct remove_const<_Tp const>
46  {
47  typedef _Tp type;
48  };
49 #endif
50 
51 #if defined(__GNUG__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) < 40300)
52 // That is a small subset of what GCC 4.3 does:
53 
54 // Utility for finding the signed versions of unsigned integral types.
55  template <typename _Tp>
56  struct __make_signed
57  {
58  typedef _Tp __type;
59  };
60 
61  template <>
62  struct __make_signed<char>
63  {
64  typedef signed char __type;
65  };
66 
67  template <>
68  struct __make_signed<unsigned char>
69  {
70  typedef signed char __type;
71  };
72 
73  template <>
74  struct __make_signed<unsigned short>
75  {
76  typedef signed short __type;
77  };
78 
79  template <>
80  struct __make_signed<unsigned int>
81  {
82  typedef signed int __type;
83  };
84 
85  template <>
86  struct __make_signed<unsigned long>
87  {
88  typedef signed long __type;
89  };
90 
91  template <>
92  struct __make_signed<unsigned long long>
93  {
94  typedef signed long long __type;
95  };
96 
97 
98  template <typename _Tp>
99  struct make_signed
100  {
101  typedef typename __make_signed<_Tp>::__type type;
102  };
103 #endif
104 } // namespace compat
105 
106 __STXXL_END_NAMESPACE
107 
108 #endif // !STXXL_HEADER__COMPAT_TYPE_TRAITS_H_