OpenCores
URL https://opencores.org/ocsvn/altor32/altor32/trunk

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [or1knd-elf/] [include/] [c++/] [4.8.0/] [tr1/] [type_traits] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 ultra_embe
// TR1 type_traits -*- C++ -*-
2
 
3
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
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.
11
 
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.
16
 
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.
20
 
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
// .
25
 
26
/** @file tr1/type_traits
27
 *  This is a TR1 C++ Library header.
28
 */
29
 
30
#ifndef _GLIBCXX_TR1_TYPE_TRAITS
31
#define _GLIBCXX_TR1_TYPE_TRAITS 1
32
 
33
#pragma GCC system_header
34
 
35
#include 
36
 
37
namespace std _GLIBCXX_VISIBILITY(default)
38
{
39
namespace tr1
40
{
41
_GLIBCXX_BEGIN_NAMESPACE_VERSION
42
 
43
  /**
44
   * @addtogroup metaprogramming
45
   * @{
46
   */
47
 
48
  struct __sfinae_types
49
  {
50
    typedef char __one;
51
    typedef struct { char __arr[2]; } __two;
52
  };
53
 
54
#define _DEFINE_SPEC_0_HELPER                          \
55
  template<>
56
 
57
#define _DEFINE_SPEC_1_HELPER                          \
58
  template
59
 
60
#define _DEFINE_SPEC_2_HELPER                          \
61
  template
62
 
63
#define _DEFINE_SPEC(_Order, _Trait, _Type, _Value)    \
64
  _DEFINE_SPEC_##_Order##_HELPER                       \
65
    struct _Trait<_Type>                               \
66
    : public integral_constant { };
67
 
68
  // helper classes [4.3].
69
 
70
  /// integral_constant
71
  template
72
    struct integral_constant
73
    {
74
      static const _Tp                      value = __v;
75
      typedef _Tp                           value_type;
76
      typedef integral_constant<_Tp, __v>   type;
77
    };
78
 
79
  /// typedef for true_type
80
  typedef integral_constant     true_type;
81
 
82
  /// typedef for false_type
83
  typedef integral_constant    false_type;
84
 
85
  template
86
    const _Tp integral_constant<_Tp, __v>::value;
87
 
88
  /// remove_cv
89
  template
90
    struct remove_cv;
91
 
92
  template
93
    struct __is_void_helper
94
    : public false_type { };
95
  _DEFINE_SPEC(0, __is_void_helper, void, true)
96
 
97
  // primary type categories [4.5.1].
98
 
99
  /// is_void
100
  template
101
    struct is_void
102
    : public integral_constant
103
                                      remove_cv<_Tp>::type>::value)>
104
    { };
105
 
106
  template
107
    struct __is_integral_helper
108
    : public false_type { };
109
  _DEFINE_SPEC(0, __is_integral_helper, bool, true)
110
  _DEFINE_SPEC(0, __is_integral_helper, char, true)
111
  _DEFINE_SPEC(0, __is_integral_helper, signed char, true)
112
  _DEFINE_SPEC(0, __is_integral_helper, unsigned char, true)
113
#ifdef _GLIBCXX_USE_WCHAR_T
114
  _DEFINE_SPEC(0, __is_integral_helper, wchar_t, true)
115
#endif
116
  _DEFINE_SPEC(0, __is_integral_helper, short, true)
117
  _DEFINE_SPEC(0, __is_integral_helper, unsigned short, true)
118
  _DEFINE_SPEC(0, __is_integral_helper, int, true)
119
  _DEFINE_SPEC(0, __is_integral_helper, unsigned int, true)
120
  _DEFINE_SPEC(0, __is_integral_helper, long, true)
121
  _DEFINE_SPEC(0, __is_integral_helper, unsigned long, true)
122
  _DEFINE_SPEC(0, __is_integral_helper, long long, true)
123
  _DEFINE_SPEC(0, __is_integral_helper, unsigned long long, true)
124
 
125
  /// is_integral
126
  template
127
    struct is_integral
128
    : public integral_constant
129
                                      remove_cv<_Tp>::type>::value)>
130
    { };
131
 
132
  template
133
    struct __is_floating_point_helper
134
    : public false_type { };
135
  _DEFINE_SPEC(0, __is_floating_point_helper, float, true)
136
  _DEFINE_SPEC(0, __is_floating_point_helper, double, true)
137
  _DEFINE_SPEC(0, __is_floating_point_helper, long double, true)
138
 
139
  /// is_floating_point
140
  template
141
    struct is_floating_point
142
    : public integral_constant
143
                                      remove_cv<_Tp>::type>::value)>
144
    { };
145
 
146
  /// is_array
147
  template
148
    struct is_array
149
    : public false_type { };
150
 
151
  template
152
    struct is_array<_Tp[_Size]>
153
    : public true_type { };
154
 
155
  template
156
    struct is_array<_Tp[]>
157
    : public true_type { };
158
 
159
  template
160
    struct __is_pointer_helper
161
    : public false_type { };
162
  _DEFINE_SPEC(1, __is_pointer_helper, _Tp*, true)
163
 
164
  /// is_pointer
165
  template
166
    struct is_pointer
167
    : public integral_constant
168
                                      remove_cv<_Tp>::type>::value)>
169
    { };
170
 
171
  /// is_reference
172
  template
173
    struct is_reference;
174
 
175
  /// is_function
176
  template
177
    struct is_function;
178
 
179
  template
180
    struct __is_member_object_pointer_helper
181
    : public false_type { };
182
  _DEFINE_SPEC(2, __is_member_object_pointer_helper, _Tp _Cp::*,
183
               !is_function<_Tp>::value)
184
 
185
  /// is_member_object_pointer
186
  template
187
    struct is_member_object_pointer
188
    : public integral_constant
189
                                      typename remove_cv<_Tp>::type>::value)>
190
    { };
191
 
192
  template
193
    struct __is_member_function_pointer_helper
194
    : public false_type { };
195
  _DEFINE_SPEC(2, __is_member_function_pointer_helper, _Tp _Cp::*,
196
               is_function<_Tp>::value)
197
 
198
  /// is_member_function_pointer
199
  template
200
    struct is_member_function_pointer
201
    : public integral_constant
202
                                      typename remove_cv<_Tp>::type>::value)>
203
    { };
204
 
205
  /// is_enum
206
  template
207
    struct is_enum
208
    : public integral_constant
209
    { };
210
 
211
  /// is_union
212
  template
213
    struct is_union
214
    : public integral_constant
215
    { };
216
 
217
  /// is_class
218
  template
219
    struct is_class
220
    : public integral_constant
221
    { };
222
 
223
  /// is_function
224
  template
225
    struct is_function
226
    : public false_type { };
227
  template
228
    struct is_function<_Res(_ArgTypes...)>
229
    : public true_type { };
230
  template
231
    struct is_function<_Res(_ArgTypes......)>
232
    : public true_type { };
233
  template
234
    struct is_function<_Res(_ArgTypes...) const>
235
    : public true_type { };
236
  template
237
    struct is_function<_Res(_ArgTypes......) const>
238
    : public true_type { };
239
  template
240
    struct is_function<_Res(_ArgTypes...) volatile>
241
    : public true_type { };
242
  template
243
    struct is_function<_Res(_ArgTypes......) volatile>
244
    : public true_type { };
245
  template
246
    struct is_function<_Res(_ArgTypes...) const volatile>
247
    : public true_type { };
248
  template
249
    struct is_function<_Res(_ArgTypes......) const volatile>
250
    : public true_type { };
251
 
252
  // composite type traits [4.5.2].
253
 
254
  /// is_arithmetic
255
  template
256
    struct is_arithmetic
257
    : public integral_constant::value
258
                                      || is_floating_point<_Tp>::value)>
259
    { };
260
 
261
  /// is_fundamental
262
  template
263
    struct is_fundamental
264
    : public integral_constant::value
265
                                      || is_void<_Tp>::value)>
266
    { };
267
 
268
  /// is_object
269
  template
270
    struct is_object
271
    : public integral_constant::value
272
                                       || is_reference<_Tp>::value
273
                                       || is_void<_Tp>::value)>
274
    { };
275
 
276
  /// is_member_pointer
277
  template
278
    struct is_member_pointer;
279
 
280
  /// is_scalar
281
  template
282
    struct is_scalar
283
    : public integral_constant::value
284
                                      || is_enum<_Tp>::value
285
                                      || is_pointer<_Tp>::value
286
                                      || is_member_pointer<_Tp>::value)>
287
    { };
288
 
289
  /// is_compound
290
  template
291
    struct is_compound
292
    : public integral_constant::value> { };
293
 
294
  /// is_member_pointer
295
  template
296
    struct __is_member_pointer_helper
297
    : public false_type { };
298
  _DEFINE_SPEC(2, __is_member_pointer_helper, _Tp _Cp::*, true)
299
 
300
  template
301
  struct is_member_pointer
302
    : public integral_constant
303
                                      typename remove_cv<_Tp>::type>::value)>
304
    { };
305
 
306
  // type properties [4.5.3].
307
  /// is_const
308
  template
309
    struct is_const
310
    : public false_type { };
311
 
312
  template
313
    struct is_const<_Tp const>
314
    : public true_type { };
315
 
316
  /// is_volatile
317
  template
318
    struct is_volatile
319
    : public false_type { };
320
 
321
  template
322
    struct is_volatile<_Tp volatile>
323
    : public true_type { };
324
 
325
  /// is_empty
326
  template
327
    struct is_empty
328
    : public integral_constant
329
    { };
330
 
331
  /// is_polymorphic
332
  template
333
    struct is_polymorphic
334
    : public integral_constant
335
    { };
336
 
337
  /// is_abstract
338
  template
339
    struct is_abstract
340
    : public integral_constant
341
    { };
342
 
343
  /// has_virtual_destructor
344
  template
345
    struct has_virtual_destructor
346
    : public integral_constant
347
    { };
348
 
349
  /// alignment_of
350
  template
351
    struct alignment_of
352
    : public integral_constant { };
353
 
354
  /// rank
355
  template
356
    struct rank
357
    : public integral_constant { };
358
 
359
  template
360
    struct rank<_Tp[_Size]>
361
    : public integral_constant::value> { };
362
 
363
  template
364
    struct rank<_Tp[]>
365
    : public integral_constant::value> { };
366
 
367
  /// extent
368
  template
369
    struct extent
370
    : public integral_constant { };
371
 
372
  template
373
    struct extent<_Tp[_Size], _Uint>
374
    : public integral_constant
375
                               _Uint == 0 ? _Size : extent<_Tp,
376
                                                           _Uint - 1>::value>
377
    { };
378
 
379
  template
380
    struct extent<_Tp[], _Uint>
381
    : public integral_constant
382
                               _Uint == 0 ? 0 : extent<_Tp,
383
                                                       _Uint - 1>::value>
384
    { };
385
 
386
  // relationships between types [4.6].
387
 
388
  /// is_same
389
  template
390
    struct is_same
391
    : public false_type { };
392
 
393
  template
394
    struct is_same<_Tp, _Tp>
395
    : public true_type { };
396
 
397
  // const-volatile modifications [4.7.1].
398
 
399
  /// remove_const
400
  template
401
    struct remove_const
402
    { typedef _Tp     type; };
403
 
404
  template
405
    struct remove_const<_Tp const>
406
    { typedef _Tp     type; };
407
 
408
  /// remove_volatile
409
  template
410
    struct remove_volatile
411
    { typedef _Tp     type; };
412
 
413
  template
414
    struct remove_volatile<_Tp volatile>
415
    { typedef _Tp     type; };
416
 
417
  /// remove_cv
418
  template
419
    struct remove_cv
420
    {
421
      typedef typename
422
      remove_const::type>::type     type;
423
    };
424
 
425
  /// add_const
426
  template
427
    struct add_const
428
    { typedef _Tp const     type; };
429
 
430
  /// add_volatile
431
  template
432
    struct add_volatile
433
    { typedef _Tp volatile     type; };
434
 
435
  /// add_cv
436
  template
437
    struct add_cv
438
    {
439
      typedef typename
440
      add_const::type>::type     type;
441
    };
442
 
443
  // array modifications [4.7.3].
444
 
445
  /// remove_extent
446
  template
447
    struct remove_extent
448
    { typedef _Tp     type; };
449
 
450
  template
451
    struct remove_extent<_Tp[_Size]>
452
    { typedef _Tp     type; };
453
 
454
  template
455
    struct remove_extent<_Tp[]>
456
    { typedef _Tp     type; };
457
 
458
  /// remove_all_extents
459
  template
460
    struct remove_all_extents
461
    { typedef _Tp     type; };
462
 
463
  template
464
    struct remove_all_extents<_Tp[_Size]>
465
    { typedef typename remove_all_extents<_Tp>::type     type; };
466
 
467
  template
468
    struct remove_all_extents<_Tp[]>
469
    { typedef typename remove_all_extents<_Tp>::type     type; };
470
 
471
  // pointer modifications [4.7.4].
472
 
473
  template
474
    struct __remove_pointer_helper
475
    { typedef _Tp     type; };
476
 
477
  template
478
    struct __remove_pointer_helper<_Tp, _Up*>
479
    { typedef _Up     type; };
480
 
481
  /// remove_pointer
482
  template
483
    struct remove_pointer
484
    : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
485
    { };
486
 
487
  template
488
    struct remove_reference;
489
 
490
  /// add_pointer
491
  template
492
    struct add_pointer
493
    { typedef typename remove_reference<_Tp>::type*     type; };
494
 
495
  template
496
    struct is_reference
497
    : public false_type { };
498
 
499
  template
500
    struct is_reference<_Tp&>
501
    : public true_type { };
502
 
503
  template
504
    struct is_pod
505
    : public integral_constant::value>
506
    { };
507
 
508
  template
509
    struct has_trivial_constructor
510
    : public integral_constant::value>
511
    { };
512
 
513
  template
514
    struct has_trivial_copy
515
    : public integral_constant::value>
516
    { };
517
 
518
  template
519
    struct has_trivial_assign
520
    : public integral_constant::value>
521
    { };
522
 
523
  template
524
    struct has_trivial_destructor
525
    : public integral_constant::value>
526
    { };
527
 
528
  template
529
    struct has_nothrow_constructor
530
    : public integral_constant::value>
531
    { };
532
 
533
  template
534
    struct has_nothrow_copy
535
    : public integral_constant::value>
536
    { };
537
 
538
  template
539
    struct has_nothrow_assign
540
    : public integral_constant::value>
541
    { };
542
 
543
  template
544
    struct __is_signed_helper
545
    : public false_type { };
546
  _DEFINE_SPEC(0, __is_signed_helper, signed char, true)
547
  _DEFINE_SPEC(0, __is_signed_helper, short, true)
548
  _DEFINE_SPEC(0, __is_signed_helper, int, true)
549
  _DEFINE_SPEC(0, __is_signed_helper, long, true)
550
  _DEFINE_SPEC(0, __is_signed_helper, long long, true)
551
 
552
  template
553
    struct is_signed
554
    : public integral_constant
555
                                      remove_cv<_Tp>::type>::value)>
556
    { };
557
 
558
  template
559
    struct __is_unsigned_helper
560
    : public false_type { };
561
  _DEFINE_SPEC(0, __is_unsigned_helper, unsigned char, true)
562
  _DEFINE_SPEC(0, __is_unsigned_helper, unsigned short, true)
563
  _DEFINE_SPEC(0, __is_unsigned_helper, unsigned int, true)
564
  _DEFINE_SPEC(0, __is_unsigned_helper, unsigned long, true)
565
  _DEFINE_SPEC(0, __is_unsigned_helper, unsigned long long, true)
566
 
567
  template
568
    struct is_unsigned
569
    : public integral_constant
570
                                      remove_cv<_Tp>::type>::value)>
571
    { };
572
 
573
  template
574
    struct __is_base_of_helper
575
    {
576
      typedef typename remove_cv<_Base>::type    _NoCv_Base;
577
      typedef typename remove_cv<_Derived>::type _NoCv_Derived;
578
      static const bool __value = (is_same<_Base, _Derived>::value
579
                                   || (__is_base_of(_Base, _Derived)
580
                                       && !is_same<_NoCv_Base,
581
                                                   _NoCv_Derived>::value));
582
    };
583
 
584
  template
585
    struct is_base_of
586
    : public integral_constant
587
                               __is_base_of_helper<_Base, _Derived>::__value>
588
    { };
589
 
590
  template
591
    struct __is_convertible_simple
592
    : public __sfinae_types
593
    {
594
    private:
595
      static __one __test(_To);
596
      static __two __test(...);
597
      static _From __makeFrom();
598
 
599
    public:
600
      static const bool __value = sizeof(__test(__makeFrom())) == 1;
601
    };
602
 
603
  template
604
    struct add_reference;
605
 
606
  template
607
    struct __is_int_or_cref
608
    {
609
      typedef typename remove_reference<_Tp>::type __rr_Tp;
610
      static const bool __value = (is_integral<_Tp>::value
611
                                   || (is_integral<__rr_Tp>::value
612
                                       && is_const<__rr_Tp>::value
613
                                       && !is_volatile<__rr_Tp>::value));
614
    };
615
 
616
  template
617
           bool = (is_void<_From>::value || is_void<_To>::value
618
                   || is_function<_To>::value || is_array<_To>::value
619
                   // This special case is here only to avoid warnings.
620
                   || (is_floating_point
621
                       remove_reference<_From>::type>::value
622
                       && __is_int_or_cref<_To>::__value))>
623
    struct __is_convertible_helper
624
    {
625
      // "An imaginary lvalue of type From...".
626
      static const bool __value = (__is_convertible_simple
627
                                   add_reference<_From>::type, _To>::__value);
628
    };
629
 
630
  template
631
    struct __is_convertible_helper<_From, _To, true>
632
    { static const bool __value = (is_void<_To>::value
633
                                   || (__is_int_or_cref<_To>::__value
634
                                       && !is_void<_From>::value)); };
635
 
636
  template
637
    struct is_convertible
638
    : public integral_constant
639
                               __is_convertible_helper<_From, _To>::__value>
640
    { };
641
 
642
  // reference modifications [4.7.2].
643
  template
644
    struct remove_reference
645
    { typedef _Tp     type; };
646
 
647
  template
648
    struct remove_reference<_Tp&>
649
    { typedef _Tp     type; };
650
 
651
  // NB: Careful with reference to void.
652
  template::value
653
                                 || is_reference<_Tp>::value)>
654
    struct __add_reference_helper
655
    { typedef _Tp&    type; };
656
 
657
  template
658
    struct __add_reference_helper<_Tp, true>
659
    { typedef _Tp     type; };
660
 
661
  template
662
    struct add_reference
663
    : public __add_reference_helper<_Tp>
664
    { };
665
 
666
  // other transformations [4.8].
667
  template
668
    struct aligned_storage
669
    {
670
      union type
671
      {
672
        unsigned char __data[_Len];
673
        struct __attribute__((__aligned__((_Align)))) { } __align;
674
      };
675
    };
676
 
677
#undef _DEFINE_SPEC_0_HELPER
678
#undef _DEFINE_SPEC_1_HELPER
679
#undef _DEFINE_SPEC_2_HELPER
680
#undef _DEFINE_SPEC
681
 
682
  /// @} group metaprogramming
683
 
684
_GLIBCXX_END_NAMESPACE_VERSION
685
}
686
}
687
 
688
#endif // _GLIBCXX_TR1_TYPE_TRAITS

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.