GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / arm-brcm-linux-uclibcgnueabi / include / c++ / 4.5.3 / bits / cpp_type_traits.h
blob8c5d8e9ca279f73fb387f26b15f3930ea70c9160
1 // The -*- C++ -*- type traits classes for internal use in libstdc++
3 // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
26 /** @file cpp_type_traits.h
27 * This is an internal header file, included by other library headers.
28 * You should not attempt to use it directly.
31 // Written by Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
33 #ifndef _CPP_TYPE_TRAITS_H
34 #define _CPP_TYPE_TRAITS_H 1
36 #pragma GCC system_header
38 #include <bits/c++config.h>
41 // This file provides some compile-time information about various types.
42 // These representations were designed, on purpose, to be constant-expressions
43 // and not types as found in <bits/type_traits.h>. In particular, they
44 // can be used in control structures and the optimizer hopefully will do
45 // the obvious thing.
47 // Why integral expressions, and not functions nor types?
48 // Firstly, these compile-time entities are used as template-arguments
49 // so function return values won't work: We need compile-time entities.
50 // We're left with types and constant integral expressions.
51 // Secondly, from the point of view of ease of use, type-based compile-time
52 // information is -not- *that* convenient. On has to write lots of
53 // overloaded functions and to hope that the compiler will select the right
54 // one. As a net effect, the overall structure isn't very clear at first
55 // glance.
56 // Thirdly, partial ordering and overload resolution (of function templates)
57 // is highly costly in terms of compiler-resource. It is a Good Thing to
58 // keep these resource consumption as least as possible.
60 // See valarray_array.h for a case use.
62 // -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06.
64 // Update 2005: types are also provided and <bits/type_traits.h> has been
65 // removed.
68 // Forward declaration hack, should really include this from somewhere.
69 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
71 template<typename _Iterator, typename _Container>
72 class __normal_iterator;
74 _GLIBCXX_END_NAMESPACE
76 _GLIBCXX_BEGIN_NAMESPACE(std)
78 struct __true_type { };
79 struct __false_type { };
81 template<bool>
82 struct __truth_type
83 { typedef __false_type __type; };
85 template<>
86 struct __truth_type<true>
87 { typedef __true_type __type; };
89 // N.B. The conversions to bool are needed due to the issue
90 // explained in c++/19404.
91 template<class _Sp, class _Tp>
92 struct __traitor
94 enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
95 typedef typename __truth_type<__value>::__type __type;
98 // Compare for equality of types.
99 template<typename, typename>
100 struct __are_same
102 enum { __value = 0 };
103 typedef __false_type __type;
106 template<typename _Tp>
107 struct __are_same<_Tp, _Tp>
109 enum { __value = 1 };
110 typedef __true_type __type;
113 // Holds if the template-argument is a void type.
114 template<typename _Tp>
115 struct __is_void
117 enum { __value = 0 };
118 typedef __false_type __type;
121 template<>
122 struct __is_void<void>
124 enum { __value = 1 };
125 typedef __true_type __type;
129 // Integer types
131 template<typename _Tp>
132 struct __is_integer
134 enum { __value = 0 };
135 typedef __false_type __type;
138 // Thirteen specializations (yes there are eleven standard integer
139 // types; <em>long long</em> and <em>unsigned long long</em> are
140 // supported as extensions)
141 template<>
142 struct __is_integer<bool>
144 enum { __value = 1 };
145 typedef __true_type __type;
148 template<>
149 struct __is_integer<char>
151 enum { __value = 1 };
152 typedef __true_type __type;
155 template<>
156 struct __is_integer<signed char>
158 enum { __value = 1 };
159 typedef __true_type __type;
162 template<>
163 struct __is_integer<unsigned char>
165 enum { __value = 1 };
166 typedef __true_type __type;
169 # ifdef _GLIBCXX_USE_WCHAR_T
170 template<>
171 struct __is_integer<wchar_t>
173 enum { __value = 1 };
174 typedef __true_type __type;
176 # endif
178 #ifdef __GXX_EXPERIMENTAL_CXX0X__
179 template<>
180 struct __is_integer<char16_t>
182 enum { __value = 1 };
183 typedef __true_type __type;
186 template<>
187 struct __is_integer<char32_t>
189 enum { __value = 1 };
190 typedef __true_type __type;
192 #endif
194 template<>
195 struct __is_integer<short>
197 enum { __value = 1 };
198 typedef __true_type __type;
201 template<>
202 struct __is_integer<unsigned short>
204 enum { __value = 1 };
205 typedef __true_type __type;
208 template<>
209 struct __is_integer<int>
211 enum { __value = 1 };
212 typedef __true_type __type;
215 template<>
216 struct __is_integer<unsigned int>
218 enum { __value = 1 };
219 typedef __true_type __type;
222 template<>
223 struct __is_integer<long>
225 enum { __value = 1 };
226 typedef __true_type __type;
229 template<>
230 struct __is_integer<unsigned long>
232 enum { __value = 1 };
233 typedef __true_type __type;
236 template<>
237 struct __is_integer<long long>
239 enum { __value = 1 };
240 typedef __true_type __type;
243 template<>
244 struct __is_integer<unsigned long long>
246 enum { __value = 1 };
247 typedef __true_type __type;
251 // Floating point types
253 template<typename _Tp>
254 struct __is_floating
256 enum { __value = 0 };
257 typedef __false_type __type;
260 // three specializations (float, double and 'long double')
261 template<>
262 struct __is_floating<float>
264 enum { __value = 1 };
265 typedef __true_type __type;
268 template<>
269 struct __is_floating<double>
271 enum { __value = 1 };
272 typedef __true_type __type;
275 template<>
276 struct __is_floating<long double>
278 enum { __value = 1 };
279 typedef __true_type __type;
283 // Pointer types
285 template<typename _Tp>
286 struct __is_pointer
288 enum { __value = 0 };
289 typedef __false_type __type;
292 template<typename _Tp>
293 struct __is_pointer<_Tp*>
295 enum { __value = 1 };
296 typedef __true_type __type;
300 // Normal iterator type
302 template<typename _Tp>
303 struct __is_normal_iterator
305 enum { __value = 0 };
306 typedef __false_type __type;
309 template<typename _Iterator, typename _Container>
310 struct __is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator,
311 _Container> >
313 enum { __value = 1 };
314 typedef __true_type __type;
318 // An arithmetic type is an integer type or a floating point type
320 template<typename _Tp>
321 struct __is_arithmetic
322 : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> >
323 { };
326 // A fundamental type is `void' or and arithmetic type
328 template<typename _Tp>
329 struct __is_fundamental
330 : public __traitor<__is_void<_Tp>, __is_arithmetic<_Tp> >
331 { };
334 // A scalar type is an arithmetic type or a pointer type
336 template<typename _Tp>
337 struct __is_scalar
338 : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> >
339 { };
342 // For use in std::copy and std::find overloads for streambuf iterators.
344 template<typename _Tp>
345 struct __is_char
347 enum { __value = 0 };
348 typedef __false_type __type;
351 template<>
352 struct __is_char<char>
354 enum { __value = 1 };
355 typedef __true_type __type;
358 #ifdef _GLIBCXX_USE_WCHAR_T
359 template<>
360 struct __is_char<wchar_t>
362 enum { __value = 1 };
363 typedef __true_type __type;
365 #endif
367 template<typename _Tp>
368 struct __is_byte
370 enum { __value = 0 };
371 typedef __false_type __type;
374 template<>
375 struct __is_byte<char>
377 enum { __value = 1 };
378 typedef __true_type __type;
381 template<>
382 struct __is_byte<signed char>
384 enum { __value = 1 };
385 typedef __true_type __type;
388 template<>
389 struct __is_byte<unsigned char>
391 enum { __value = 1 };
392 typedef __true_type __type;
396 // Move iterator type
398 template<typename _Tp>
399 struct __is_move_iterator
401 enum { __value = 0 };
402 typedef __false_type __type;
405 #ifdef __GXX_EXPERIMENTAL_CXX0X__
406 template<typename _Iterator>
407 class move_iterator;
409 template<typename _Iterator>
410 struct __is_move_iterator< move_iterator<_Iterator> >
412 enum { __value = 1 };
413 typedef __true_type __type;
415 #endif
417 template<typename _Tp>
418 class __is_iterator_helper
420 typedef char __one;
421 typedef struct { char __arr[2]; } __two;
423 template<typename _Up>
424 struct _Wrap_type
425 { };
427 template<typename _Up>
428 static __one __test(_Wrap_type<typename _Up::iterator_category>*);
430 template<typename _Up>
431 static __two __test(...);
433 public:
434 static const bool __value = (sizeof(__test<_Tp>(0)) == 1
435 || __is_pointer<_Tp>::__value);
438 template<typename _Tp>
439 struct __is_iterator
441 enum { __value = __is_iterator_helper<_Tp>::__value };
442 typedef typename __truth_type<__value>::__type __type;
445 _GLIBCXX_END_NAMESPACE
447 #endif //_CPP_TYPE_TRAITS_H