4 * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>,
5 * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
6 * economic rights: Technische Universität Dresden (Germany)
8 * This file is part of TUD:OS and distributed under the terms of the
9 * GNU General Public License 2.
10 * Please see the COPYING-GPL-2 file for details.
12 * As a special exception, you may use this file as part of a free software
13 * library without restriction. Specifically, if other files instantiate
14 * templates or use macros or inline functions from this file, or you compile
15 * this file and link it with other files to produce an executable, this
16 * file does not by itself cause the resulting executable to be covered by
17 * the GNU General Public License. This exception does not however
18 * invalidate any other reasons why the executable file might be covered by
19 * the GNU General Public License.
25 #include "bits/type_traits.h"
28 #define CXX_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
33 template< typename T, T V >
34 struct integral_constant
36 static T const value = V;
38 typedef integral_constant<T, V> type;
41 typedef integral_constant<bool, true> true_type;
42 typedef integral_constant<bool, false> false_type;
44 template< typename T > struct remove_reference;
46 template< typename T > struct idendity { typedef T type; };
48 template< typename T1, typename T2 > struct is_same;
50 template< typename T > struct remove_const;
52 template< typename T > struct remove_volatile;
54 template< typename T > struct remove_cv;
56 template< typename T > struct remove_pointer;
60 template< typename, typename >
61 struct is_same : public false_type {};
63 template< typename T >
64 struct is_same<T, T> : public true_type {};
66 template< typename T >
67 struct remove_reference { typedef T type; };
69 template< typename T >
70 struct remove_reference<T &> { typedef T type; };
72 #ifdef __GXX_EXPERIMENTAL_CXX0X__
73 template< typename T >
74 struct remove_reference<T &&> { typedef T type; };
77 template< typename T > struct remove_const { typedef T type; };
78 template< typename T > struct remove_const<T const> { typedef T type; };
80 template< typename T > struct remove_volatile { typedef T type; };
81 template< typename T > struct remove_volatile<T volatile> { typedef T type; };
83 template< typename T >
84 struct remove_cv { typedef typename remove_const<typename remove_volatile<T>::type>::type type; };
86 template< typename T, typename >
87 struct __remove_pointer_h { typedef T type; };
89 template< typename T, typename I >
90 struct __remove_pointer_h<T, I*> { typedef I type; };
92 template< typename T >
93 struct remove_pointer : public __remove_pointer_h<T, typename remove_cv<T>::type> {};
95 #ifdef __GXX_EXPERIMENTAL_CXX0X__
96 #if CXX_GCC_VERSION >= 405
98 template< typename T >
100 forward(typename cxx::remove_reference<T>::type &t)
101 { return static_cast<T &&>(t); }
103 template< typename T >
105 forward(typename cxx::remove_reference<T>::type &&t)
106 { return static_cast<T &&>(t); }
110 template< typename T >
112 forward(typename cxx::idendity<T>::type &&t)
117 template< typename T >
118 inline typename cxx::remove_reference<T>::type &&
119 move(T &t) { return static_cast<typename cxx::remove_reference<T>::type &&>(t); }
122 template< bool, typename T = void >
125 template< typename T >
126 struct enable_if<true, T> { typedef T type; };