29 #ifndef _GLIBCXX_TR1_TYPE_TRAITS
30 #define _GLIBCXX_TR1_TYPE_TRAITS 1
32 #pragma GCC system_header
34 #if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
35 # error TR1 header cannot be included from C++0x header
40 #if defined(_GLIBCXX_INCLUDE_AS_TR1)
43 # define _GLIBCXX_INCLUDE_AS_TR1
44 # define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
45 # define _GLIBCXX_END_NAMESPACE_TR1 }
46 # define _GLIBCXX_TR1 tr1::
49 # undef _GLIBCXX_END_NAMESPACE_TR1
50 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1
51 # undef _GLIBCXX_INCLUDE_AS_TR1
58 #define _DEFINE_SPEC(_Trait, _Type) \
60 struct _Trait<_Type> \
61 : public true_type { };
67 template<
typename _Tp>
68 struct is_reference<_Tp&>
71 template<
typename _Tp>
73 :
public integral_constant<bool, __is_pod(_Tp) || is_void<_Tp>::value>
76 template<
typename _Tp>
77 struct has_trivial_constructor
78 :
public integral_constant<bool, is_pod<_Tp>::value>
81 template<
typename _Tp>
82 struct has_trivial_copy
83 :
public integral_constant<bool, is_pod<_Tp>::value>
86 template<
typename _Tp>
87 struct has_trivial_assign
88 :
public integral_constant<bool, is_pod<_Tp>::value>
91 template<
typename _Tp>
92 struct has_trivial_destructor
93 :
public integral_constant<bool, is_pod<_Tp>::value>
96 template<
typename _Tp>
97 struct has_nothrow_constructor
98 :
public integral_constant<bool, is_pod<_Tp>::value>
101 template<
typename _Tp>
102 struct has_nothrow_copy
103 :
public integral_constant<bool, is_pod<_Tp>::value>
106 template<
typename _Tp>
107 struct has_nothrow_assign
108 :
public integral_constant<bool, is_pod<_Tp>::value>
112 struct __is_signed_helper
114 _DEFINE_SPEC(__is_signed_helper,
signed char)
115 _DEFINE_SPEC(__is_signed_helper,
short)
116 _DEFINE_SPEC(__is_signed_helper,
int)
117 _DEFINE_SPEC(__is_signed_helper,
long)
118 _DEFINE_SPEC(__is_signed_helper,
long long)
120 template<typename _Tp>
122 : public integral_constant<
bool, (__is_signed_helper<typename
123 remove_cv<_Tp>::type>::value)>
127 struct __is_unsigned_helper
129 _DEFINE_SPEC(__is_unsigned_helper,
unsigned char)
130 _DEFINE_SPEC(__is_unsigned_helper,
unsigned short)
131 _DEFINE_SPEC(__is_unsigned_helper,
unsigned int)
132 _DEFINE_SPEC(__is_unsigned_helper,
unsigned long)
133 _DEFINE_SPEC(__is_unsigned_helper,
unsigned long long)
135 template<
typename _Tp>
137 :
public integral_constant<bool, (__is_unsigned_helper<typename
138 remove_cv<_Tp>::type>::value)>
141 template<
typename _Base,
typename _Derived>
142 struct __is_base_of_helper
144 typedef typename remove_cv<_Base>::type _NoCv_Base;
145 typedef typename remove_cv<_Derived>::type _NoCv_Derived;
146 static const bool __value = (is_same<_Base, _Derived>::value
147 || (__is_base_of(_Base, _Derived)
148 && !is_same<_NoCv_Base,
149 _NoCv_Derived>::value));
152 template<
typename _Base,
typename _Derived>
154 :
public integral_constant<bool,
155 __is_base_of_helper<_Base, _Derived>::__value>
158 template<
typename _From,
typename _To>
159 struct __is_convertible_simple
160 :
public __sfinae_types
163 static __one __test(_To);
164 static __two __test(...);
165 static _From __makeFrom();
168 static const bool __value =
sizeof(__test(__makeFrom())) == 1;
171 template<
typename _Tp>
172 struct add_reference;
174 template<
typename _Tp>
175 struct __is_int_or_cref
177 typedef typename remove_reference<_Tp>::type __rr_Tp;
178 static const bool __value = (is_integral<_Tp>::value
179 || (is_integral<__rr_Tp>::value
180 && is_const<__rr_Tp>::value
181 && !is_volatile<__rr_Tp>::value));
184 template<
typename _From,
typename _To,
185 bool = (is_void<_From>::value || is_void<_To>::value
186 || is_function<_To>::value || is_array<_To>::value
188 || (is_floating_point<
typename
189 remove_reference<_From>::type>::value
190 && __is_int_or_cref<_To>::__value))>
191 struct __is_convertible_helper
194 static const bool __value = (__is_convertible_simple<
typename
195 add_reference<_From>::type, _To>::__value);
198 template<
typename _From,
typename _To>
199 struct __is_convertible_helper<_From, _To, true>
200 {
static const bool __value = (is_void<_To>::value
201 || (__is_int_or_cref<_To>::__value
202 && !is_void<_From>::value)); };
204 template<
typename _From,
typename _To>
205 struct is_convertible
206 :
public integral_constant<bool,
207 __is_convertible_helper<_From, _To>::__value>
211 template<
typename _Tp>
212 struct remove_reference
213 {
typedef _Tp type; };
215 template<
typename _Tp>
216 struct remove_reference<_Tp&>
217 {
typedef _Tp type; };
220 template<typename _Tp, bool = (is_void<_Tp>::value
221 || is_reference<_Tp>::value)>
222 struct __add_reference_helper
223 {
typedef _Tp& type; };
225 template<
typename _Tp>
226 struct __add_reference_helper<_Tp, true>
227 {
typedef _Tp type; };
229 template<
typename _Tp>
231 :
public __add_reference_helper<_Tp>
235 template<std::
size_t _Len, std::
size_t _Align>
236 struct aligned_storage
240 unsigned char __data[_Len];
241 struct __attribute__((__aligned__((_Align)))) { } __align;
249 #endif // _GLIBCXX_TR1_TYPE_TRAITS