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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libitm/] [local_type_traits] - Blame information for rev 737

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 737 jeremybenn
// C++0x type_traits -*- C++ -*-
2
 
3
// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 3, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// Under Section 7 of GPL version 3, you are granted additional
17
// permissions described in the GCC Runtime Library Exception, version
18
// 3.1, as published by the Free Software Foundation.
19
 
20
// You should have received a copy of the GNU General Public License and
21
// a copy of the GCC Runtime Library Exception along with this program;
22
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
// .
24
 
25
// ????????????????????????????????????????????????????????????????????
26
//
27
// This is a copy of the libstdc++ header, with the trivial modification
28
// of ignoring the c++config.h include.  If and when the top-level build is
29
// fixed so that target libraries can be built using the newly built, we can
30
// delete this file.
31
//
32
// ????????????????????????????????????????????????????????????????????
33
 
34
/** @file include/type_traits
35
 *  This is a Standard C++ Library header.
36
 */
37
 
38
#ifndef _GLIBCXX_TYPE_TRAITS
39
#define _GLIBCXX_TYPE_TRAITS 1
40
 
41
// #pragma GCC system_header
42
 
43
// #ifndef __GXX_EXPERIMENTAL_CXX0X__
44
// # include 
45
// #else
46
// #include 
47
 
48
namespace std // _GLIBCXX_VISIBILITY(default)
49
{
50
// _GLIBCXX_BEGIN_NAMESPACE_VERSION
51
 
52
  /**
53
   * @addtogroup metaprogramming
54
   * @{
55
   */
56
 
57
  /// integral_constant
58
  template
59
    struct integral_constant
60
    {
61
      static constexpr _Tp                  value = __v;
62
      typedef _Tp                           value_type;
63
      typedef integral_constant<_Tp, __v>   type;
64
      constexpr operator value_type() { return value; }
65
    };
66
 
67
  /// typedef for true_type
68
  typedef integral_constant     true_type;
69
 
70
  /// typedef for false_type
71
  typedef integral_constant    false_type;
72
 
73
  template
74
    constexpr _Tp integral_constant<_Tp, __v>::value;
75
 
76
  // Meta programming helper types.
77
 
78
  template
79
    struct conditional;
80
 
81
  template
82
    struct __or_;
83
 
84
  template<>
85
    struct __or_<>
86
    : public false_type
87
    { };
88
 
89
  template
90
    struct __or_<_B1>
91
    : public _B1
92
    { };
93
 
94
  template
95
    struct __or_<_B1, _B2>
96
    : public conditional<_B1::value, _B1, _B2>::type
97
    { };
98
 
99
  template
100
    struct __or_<_B1, _B2, _B3, _Bn...>
101
    : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
102
    { };
103
 
104
  template
105
    struct __and_;
106
 
107
  template<>
108
    struct __and_<>
109
    : public true_type
110
    { };
111
 
112
  template
113
    struct __and_<_B1>
114
    : public _B1
115
    { };
116
 
117
  template
118
    struct __and_<_B1, _B2>
119
    : public conditional<_B1::value, _B2, _B1>::type
120
    { };
121
 
122
  template
123
    struct __and_<_B1, _B2, _B3, _Bn...>
124
    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
125
    { };
126
 
127
  template
128
    struct __not_
129
    : public integral_constant
130
    { };
131
 
132
  struct __sfinae_types
133
  {
134
    typedef char __one;
135
    typedef struct { char __arr[2]; } __two;
136
  };
137
 
138
  // primary type categories.
139
 
140
  template
141
    struct remove_cv;
142
 
143
  template
144
    struct __is_void_helper
145
    : public false_type { };
146
 
147
  template<>
148
    struct __is_void_helper
149
    : public true_type { };
150
 
151
  /// is_void
152
  template
153
    struct is_void
154
    : public integral_constant
155
                                      remove_cv<_Tp>::type>::value)>
156
    { };
157
 
158
  template
159
    struct __is_integral_helper
160
    : public false_type { };
161
 
162
  template<>
163
    struct __is_integral_helper
164
    : public true_type { };
165
 
166
  template<>
167
    struct __is_integral_helper
168
    : public true_type { };
169
 
170
  template<>
171
    struct __is_integral_helper
172
    : public true_type { };
173
 
174
  template<>
175
    struct __is_integral_helper
176
    : public true_type { };
177
 
178
#ifdef _GLIBCXX_USE_WCHAR_T
179
  template<>
180
    struct __is_integral_helper
181
    : public true_type { };
182
#endif
183
 
184
  template<>
185
    struct __is_integral_helper
186
    : public true_type { };
187
 
188
  template<>
189
    struct __is_integral_helper
190
    : public true_type { };
191
 
192
  template<>
193
    struct __is_integral_helper
194
    : public true_type { };
195
 
196
  template<>
197
    struct __is_integral_helper
198
    : public true_type { };
199
 
200
  template<>
201
    struct __is_integral_helper
202
    : public true_type { };
203
 
204
  template<>
205
    struct __is_integral_helper
206
    : public true_type { };
207
 
208
  template<>
209
    struct __is_integral_helper
210
    : public true_type { };
211
 
212
  template<>
213
    struct __is_integral_helper
214
    : public true_type { };
215
 
216
  template<>
217
    struct __is_integral_helper
218
    : public true_type { };
219
 
220
  template<>
221
    struct __is_integral_helper
222
    : public true_type { };
223
 
224
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
225
  template<>
226
    struct __is_integral_helper<__int128>
227
    : public true_type { };
228
 
229
  template<>
230
    struct __is_integral_helper
231
    : public true_type { };
232
#endif
233
 
234
  /// is_integral
235
  template
236
    struct is_integral
237
    : public integral_constant
238
                                      remove_cv<_Tp>::type>::value)>
239
    { };
240
 
241
  template
242
    struct __is_floating_point_helper
243
    : public false_type { };
244
 
245
  template<>
246
    struct __is_floating_point_helper
247
    : public true_type { };
248
 
249
  template<>
250
    struct __is_floating_point_helper
251
    : public true_type { };
252
 
253
  template<>
254
    struct __is_floating_point_helper
255
    : public true_type { };
256
 
257
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
258
  template<>
259
    struct __is_floating_point_helper<__float128>
260
    : public true_type { };
261
#endif
262
 
263
  /// is_floating_point
264
  template
265
    struct is_floating_point
266
    : public integral_constant
267
                                      remove_cv<_Tp>::type>::value)>
268
    { };
269
 
270
  /// is_array
271
  template
272
    struct is_array
273
    : public false_type { };
274
 
275
  template
276
    struct is_array<_Tp[_Size]>
277
    : public true_type { };
278
 
279
  template
280
    struct is_array<_Tp[]>
281
    : public true_type { };
282
 
283
  template
284
    struct __is_pointer_helper
285
    : public false_type { };
286
 
287
  template
288
    struct __is_pointer_helper<_Tp*>
289
    : public true_type { };
290
 
291
  /// is_pointer
292
  template
293
    struct is_pointer
294
    : public integral_constant
295
                                      remove_cv<_Tp>::type>::value)>
296
    { };
297
 
298
  /// is_lvalue_reference
299
  template
300
    struct is_lvalue_reference
301
    : public false_type { };
302
 
303
  template
304
    struct is_lvalue_reference<_Tp&>
305
    : public true_type { };
306
 
307
  /// is_rvalue_reference
308
  template
309
    struct is_rvalue_reference
310
    : public false_type { };
311
 
312
  template
313
    struct is_rvalue_reference<_Tp&&>
314
    : public true_type { };
315
 
316
  template
317
    struct is_function;
318
 
319
  template
320
    struct __is_member_object_pointer_helper
321
    : public false_type { };
322
 
323
  template
324
    struct __is_member_object_pointer_helper<_Tp _Cp::*>
325
    : public integral_constant::value> { };
326
 
327
  /// is_member_object_pointer
328
  template
329
    struct is_member_object_pointer
330
    : public integral_constant
331
                                      typename remove_cv<_Tp>::type>::value)>
332
    { };
333
 
334
  template
335
    struct __is_member_function_pointer_helper
336
    : public false_type { };
337
 
338
  template
339
    struct __is_member_function_pointer_helper<_Tp _Cp::*>
340
    : public integral_constant::value> { };
341
 
342
  /// is_member_function_pointer
343
  template
344
    struct is_member_function_pointer
345
    : public integral_constant
346
                                      typename remove_cv<_Tp>::type>::value)>
347
    { };
348
 
349
  /// is_enum
350
  template
351
    struct is_enum
352
    : public integral_constant
353
    { };
354
 
355
  /// is_union
356
  template
357
    struct is_union
358
    : public integral_constant
359
    { };
360
 
361
  /// is_class
362
  template
363
    struct is_class
364
    : public integral_constant
365
    { };
366
 
367
  /// is_function
368
  template
369
    struct is_function
370
    : public false_type { };
371
 
372
  template
373
    struct is_function<_Res(_ArgTypes...)>
374
    : public true_type { };
375
 
376
  template
377
    struct is_function<_Res(_ArgTypes......)>
378
    : public true_type { };
379
 
380
  template
381
    struct is_function<_Res(_ArgTypes...) const>
382
    : public true_type { };
383
 
384
  template
385
    struct is_function<_Res(_ArgTypes......) const>
386
    : public true_type { };
387
 
388
  template
389
    struct is_function<_Res(_ArgTypes...) volatile>
390
    : public true_type { };
391
 
392
  template
393
    struct is_function<_Res(_ArgTypes......) volatile>
394
    : public true_type { };
395
 
396
  template
397
    struct is_function<_Res(_ArgTypes...) const volatile>
398
    : public true_type { };
399
 
400
  template
401
    struct is_function<_Res(_ArgTypes......) const volatile>
402
    : public true_type { };
403
 
404
  template
405
    struct __is_nullptr_t_helper
406
    : public false_type { };
407
 
408
#if 0
409
  template<>
410
    struct __is_nullptr_t_helper
411
    : public true_type { };
412
#endif
413
 
414
  // __is_nullptr_t (extension).
415
  template
416
    struct __is_nullptr_t
417
    : public integral_constant
418
                                      remove_cv<_Tp>::type>::value)>
419
    { };
420
 
421
  // composite type categories.
422
 
423
  /// is_reference
424
  template
425
    struct is_reference
426
    : public __or_,
427
                   is_rvalue_reference<_Tp>>::type
428
    { };
429
 
430
  /// is_arithmetic
431
  template
432
    struct is_arithmetic
433
    : public __or_, is_floating_point<_Tp>>::type
434
    { };
435
 
436
  /// is_fundamental
437
  template
438
    struct is_fundamental
439
    : public __or_, is_void<_Tp>>::type
440
    { };
441
 
442
  /// is_object
443
  template
444
    struct is_object
445
    : public __not_<__or_, is_reference<_Tp>,
446
                          is_void<_Tp>>>::type
447
    { };
448
 
449
  template
450
    struct is_member_pointer;
451
 
452
  /// is_scalar
453
  template
454
    struct is_scalar
455
    : public __or_, is_enum<_Tp>, is_pointer<_Tp>,
456
                   is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type
457
    { };
458
 
459
  /// is_compound
460
  template
461
    struct is_compound
462
    : public integral_constant::value> { };
463
 
464
  /// is_member_pointer
465
  template
466
    struct __is_member_pointer_helper
467
    : public false_type { };
468
 
469
  template
470
    struct __is_member_pointer_helper<_Tp _Cp::*>
471
    : public true_type { };
472
 
473
  template
474
    struct is_member_pointer
475
    : public integral_constant
476
                                      typename remove_cv<_Tp>::type>::value)>
477
    { };
478
 
479
  // type properties.
480
 
481
  /// is_const
482
  template
483
    struct is_const
484
    : public false_type { };
485
 
486
  template
487
    struct is_const<_Tp const>
488
    : public true_type { };
489
 
490
  /// is_volatile
491
  template
492
    struct is_volatile
493
    : public false_type { };
494
 
495
  template
496
    struct is_volatile<_Tp volatile>
497
    : public true_type { };
498
 
499
  /// is_trivial
500
  template
501
    struct is_trivial
502
    : public integral_constant
503
    { };
504
 
505
  /// is_trivially_copyable (still unimplemented)
506
 
507
  /// is_standard_layout
508
  template
509
    struct is_standard_layout
510
    : public integral_constant
511
    { };
512
 
513
  /// is_pod
514
  // Could use is_standard_layout && is_trivial instead of the builtin.
515
  template
516
    struct is_pod
517
    : public integral_constant
518
    { };
519
 
520
  /// is_literal_type
521
  template
522
    struct is_literal_type
523
    : public integral_constant
524
    { };
525
 
526
  /// is_empty
527
  template
528
    struct is_empty
529
    : public integral_constant
530
    { };
531
 
532
  /// is_polymorphic
533
  template
534
    struct is_polymorphic
535
    : public integral_constant
536
    { };
537
 
538
  /// is_abstract
539
  template
540
    struct is_abstract
541
    : public integral_constant
542
    { };
543
 
544
  template
545
           bool = is_integral<_Tp>::value,
546
           bool = is_floating_point<_Tp>::value>
547
    struct __is_signed_helper
548
    : public false_type { };
549
 
550
  template
551
    struct __is_signed_helper<_Tp, false, true>
552
    : public true_type { };
553
 
554
  template
555
    struct __is_signed_helper<_Tp, true, false>
556
    : public integral_constant(_Tp(-1) < _Tp(0))>
557
    { };
558
 
559
  /// is_signed
560
  template
561
    struct is_signed
562
    : public integral_constant::value>
563
    { };
564
 
565
  /// is_unsigned
566
  template
567
    struct is_unsigned
568
    : public __and_, __not_>>::type
569
    { };
570
 
571
 
572
  // destructible and constructible type properties
573
 
574
  template
575
    struct add_rvalue_reference;
576
 
577
  template
578
    typename add_rvalue_reference<_Tp>::type declval() noexcept;
579
 
580
  template
581
    struct extent;
582
 
583
  template
584
    struct remove_all_extents;
585
 
586
  template
587
    struct __is_array_known_bounds
588
    : public integral_constant::value > 0)>
589
    { };
590
 
591
  template
592
    struct __is_array_unknown_bounds
593
    : public __and_, __not_>>::type
594
    { };
595
 
596
  // In N3290 is_destructible does not say anything about function
597
  // types and abstract types, see LWG 2049. This implementation
598
  // describes function types as trivially nothrow destructible and
599
  // abstract types as destructible, iff the  explicit destructor
600
  // call expression is wellformed.
601
  struct __do_is_destructible_impl_1
602
  {
603
    template
604
      struct __w { _Up __u; };
605
 
606
    template
607
             = decltype(declval<__w<_Tp>&>().~__w<_Tp>())>
608
      static true_type __test(int);
609
 
610
    template
611
      static false_type __test(...);
612
  };
613
 
614
  template
615
    struct __is_destructible_impl_1
616
    : public __do_is_destructible_impl_1
617
    {
618
      typedef decltype(__test<_Tp>(0)) type;
619
    };
620
 
621
  // Special implementation for abstract types
622
  struct __do_is_destructible_impl_2
623
  {
624
    template().~_Tp())>
625
      static true_type __test(int);
626
 
627
    template
628
      static false_type __test(...);
629
  };
630
 
631
  template
632
    struct __is_destructible_impl_2
633
    : public __do_is_destructible_impl_2
634
    {
635
      typedef decltype(__test<_Tp>(0)) type;
636
    };
637
 
638
  template
639
           bool = __or_,
640
                        __is_array_unknown_bounds<_Tp>>::value,
641
           bool = __or_, is_function<_Tp>>::value>
642
    struct __is_destructible_safe;
643
 
644
  template
645
    struct __is_destructible_safe<_Tp, false, false>
646
    : public conditional::value,
647
                         __is_destructible_impl_2<_Tp>,
648
                         __is_destructible_impl_1<_Tp>>::type::type
649
    { };
650
 
651
  template
652
    struct __is_destructible_safe<_Tp, true, false>
653
    : public false_type { };
654
 
655
  template
656
    struct __is_destructible_safe<_Tp, false, true>
657
    : public true_type { };
658
 
659
  /// is_destructible
660
  template
661
    struct is_destructible
662
    : public integral_constant::value)>
663
    { };
664
 
665
  struct __do_is_default_constructible_impl
666
  {
667
    template
668
      static true_type __test(int);
669
 
670
    template
671
      static false_type __test(...);
672
  };
673
 
674
  template
675
    struct __is_default_constructible_impl
676
    : public __do_is_default_constructible_impl
677
    {
678
      typedef decltype(__test<_Tp>(0)) type;
679
    };
680
 
681
  template
682
    struct __is_default_constructible_atom
683
    : public __and_<__not_>,
684
                    __is_default_constructible_impl<_Tp>>::type
685
    { };
686
 
687
  template::value>
688
    struct __is_default_constructible_safe;
689
 
690
  // The following technique is a workaround for a current core language
691
  // restriction, which does not allow for array types to occur in
692
  // functional casts of the form T().  Complete arrays can be default-
693
  // constructed, if the element type is default-constructible, but
694
  // arrays with unknown bounds are not.
695
  template
696
    struct __is_default_constructible_safe<_Tp, true>
697
    : public __and_<__is_array_known_bounds<_Tp>,
698
                    __is_default_constructible_atom
699
                      remove_all_extents<_Tp>::type>>::type
700
    { };
701
 
702
  template
703
    struct __is_default_constructible_safe<_Tp, false>
704
    : public __is_default_constructible_atom<_Tp>::type
705
    { };
706
 
707
  /// is_default_constructible
708
  template
709
    struct is_default_constructible
710
    : public integral_constant
711
                                      _Tp>::value)>
712
    { };
713
 
714
 
715
  // Implementation of is_constructible.
716
 
717
  // The hardest part of this trait is the binary direct-initialization
718
  // case, because we hit into a functional cast of the form T(arg).
719
  // This implementation uses different strategies depending on the
720
  // target type to reduce the test overhead as much as possible:
721
  //
722
  // a) For a reference target type, we use a static_cast expression
723
  //    modulo its extra cases.
724
  //
725
  // b) For a non-reference target type we use a ::new expression.
726
  struct __do_is_static_castable_impl
727
  {
728
    template
729
             = decltype(static_cast<_To>(declval<_From>()))>
730
      static true_type __test(int);
731
 
732
    template
733
      static false_type __test(...);
734
  };
735
 
736
  template
737
    struct __is_static_castable_impl
738
    : public __do_is_static_castable_impl
739
    {
740
      typedef decltype(__test<_From, _To>(0)) type;
741
    };
742
 
743
  template
744
    struct __is_static_castable_safe
745
    : public __is_static_castable_impl<_From, _To>::type
746
    { };
747
 
748
  // __is_static_castable
749
  template
750
    struct __is_static_castable
751
    : public integral_constant
752
                                      _From, _To>::value)>
753
    { };
754
 
755
  // Implementation for non-reference types. To meet the proper
756
  // variable definition semantics, we also need to test for
757
  // is_destructible in this case.
758
  struct __do_is_direct_constructible_impl
759
  {
760
    template
761
             = decltype(::new _Tp(declval<_Arg>()))>
762
      static true_type __test(int);
763
 
764
    template
765
      static false_type __test(...);
766
  };
767
 
768
  template
769
    struct __is_direct_constructible_impl
770
    : public __do_is_direct_constructible_impl
771
    {
772
      typedef decltype(__test<_Tp, _Arg>(0)) type;
773
    };
774
 
775
  template
776
    struct __is_direct_constructible_new_safe
777
    : public __and_,
778
                    __is_direct_constructible_impl<_Tp, _Arg>>::type
779
    { };
780
 
781
  template
782
    struct is_same;
783
 
784
  template
785
    struct is_base_of;
786
 
787
  template
788
    struct remove_reference;
789
 
790
  template
791
           = is_reference<_From>::value>
792
    struct __is_base_to_derived_ref;
793
 
794
  template
795
    struct __is_base_to_derived_ref<_From, _To, true>
796
    {
797
      typedef typename remove_cv
798
        >::type>::type __src_t;
799
      typedef typename remove_cv
800
        >::type>::type __dst_t;
801
      typedef __and_<__not_>,
802
                     is_base_of<__src_t, __dst_t>> type;
803
      static constexpr bool value = type::value;
804
    };
805
 
806
  template
807
    struct __is_base_to_derived_ref<_From, _To, false>
808
    : public false_type
809
    { };
810
 
811
  template
812
           = __and_,
813
                    is_rvalue_reference<_To>>::value>
814
    struct __is_lvalue_to_rvalue_ref;
815
 
816
  template
817
    struct __is_lvalue_to_rvalue_ref<_From, _To, true>
818
    {
819
      typedef typename remove_cv
820
        _From>::type>::type __src_t;
821
      typedef typename remove_cv
822
        _To>::type>::type __dst_t;
823
      typedef __or_,
824
                    is_base_of<__dst_t, __src_t>> type;
825
      static constexpr bool value = type::value;
826
    };
827
 
828
  template
829
    struct __is_lvalue_to_rvalue_ref<_From, _To, false>
830
    : public false_type
831
    { };
832
 
833
  // Here we handle direct-initialization to a reference type as
834
  // equivalent to a static_cast modulo overshooting conversions.
835
  // These are restricted to the following conversions:
836
  //    a) A glvalue of a base class to a derived class reference
837
  //    b) An lvalue to an rvalue-reference of reference-compatible
838
  //       types
839
  template
840
    struct __is_direct_constructible_ref_cast
841
    : public __and_<__is_static_castable<_Arg, _Tp>,
842
                    __not_<__or_<__is_base_to_derived_ref<_Arg, _Tp>,
843
                                 __is_lvalue_to_rvalue_ref<_Arg, _Tp>
844
                   >>>::type
845
    { };
846
 
847
  template
848
    struct __is_direct_constructible_new
849
    : public conditional::value,
850
                         __is_direct_constructible_ref_cast<_Tp, _Arg>,
851
                         __is_direct_constructible_new_safe<_Tp, _Arg>
852
                         >::type
853
    { };
854
 
855
  template
856
    struct __is_direct_constructible
857
    : public integral_constant
858
                                      _Tp, _Arg>::value)>
859
    { };
860
 
861
  // Since default-construction and binary direct-initialization have
862
  // been handled separately, the implementation of the remaining
863
  // n-ary construction cases is rather straightforward.
864
  struct __do_is_nary_constructible_impl
865
  {
866
    template
867
             = decltype(_Tp(declval<_Args>()...))>
868
      static true_type __test(int);
869
 
870
    template
871
      static false_type __test(...);
872
  };
873
 
874
  template
875
    struct __is_nary_constructible_impl
876
    : public __do_is_nary_constructible_impl
877
    {
878
      typedef decltype(__test<_Tp, _Args...>(0)) type;
879
    };
880
 
881
  template
882
    struct __is_nary_constructible
883
    : public __is_nary_constructible_impl<_Tp, _Args...>::type
884
    {
885
      static_assert(sizeof...(_Args) > 1,
886
                    "Only useful for > 1 arguments");
887
    };
888
 
889
  template
890
    struct __is_constructible_impl
891
    : public __is_nary_constructible<_Tp, _Args...>
892
    { };
893
 
894
  template
895
    struct __is_constructible_impl<_Tp, _Arg>
896
    : public __is_direct_constructible<_Tp, _Arg>
897
    { };
898
 
899
  template
900
    struct __is_constructible_impl<_Tp>
901
    : public is_default_constructible<_Tp>
902
    { };
903
 
904
  /// is_constructible
905
  template
906
    struct is_constructible
907
    : public integral_constant
908
                                      _Args...>::value)>
909
    { };
910
 
911
  template::value>
912
    struct __is_copy_constructible_impl;
913
 
914
  template
915
    struct __is_copy_constructible_impl<_Tp, true>
916
    : public false_type { };
917
 
918
  template
919
    struct __is_copy_constructible_impl<_Tp, false>
920
    : public is_constructible<_Tp, const _Tp&>
921
    { };
922
 
923
  /// is_copy_constructible
924
  template
925
    struct is_copy_constructible
926
    : public __is_copy_constructible_impl<_Tp>
927
    { };
928
 
929
  template::value>
930
    struct __is_move_constructible_impl;
931
 
932
  template
933
    struct __is_move_constructible_impl<_Tp, true>
934
    : public false_type { };
935
 
936
  template
937
    struct __is_move_constructible_impl<_Tp, false>
938
    : public is_constructible<_Tp, _Tp&&>
939
    { };
940
 
941
  /// is_move_constructible
942
  template
943
    struct is_move_constructible
944
    : public __is_move_constructible_impl<_Tp>
945
    { };
946
 
947
  template
948
    struct __is_nt_default_constructible_atom
949
    : public integral_constant
950
    { };
951
 
952
  template::value>
953
    struct __is_nt_default_constructible_impl;
954
 
955
  template
956
    struct __is_nt_default_constructible_impl<_Tp, true>
957
    : public __and_<__is_array_known_bounds<_Tp>,
958
                    __is_nt_default_constructible_atom
959
                      remove_all_extents<_Tp>::type>>::type
960
    { };
961
 
962
  template
963
    struct __is_nt_default_constructible_impl<_Tp, false>
964
    : public __is_nt_default_constructible_atom<_Tp>
965
    { };
966
 
967
  /// is_nothrow_default_constructible
968
  template
969
    struct is_nothrow_default_constructible
970
    : public __and_,
971
                    __is_nt_default_constructible_impl<_Tp>>::type
972
    { };
973
 
974
  template
975
    struct __is_nt_constructible_impl
976
    : public integral_constant()...))>
977
    { };
978
 
979
  template
980
    struct __is_nt_constructible_impl<_Tp, _Arg>
981
    : public integral_constant
982
                               noexcept(static_cast<_Tp>(declval<_Arg>()))>
983
    { };
984
 
985
  template
986
    struct __is_nt_constructible_impl<_Tp>
987
    : public is_nothrow_default_constructible<_Tp>
988
    { };
989
 
990
  /// is_nothrow_constructible
991
  template
992
    struct is_nothrow_constructible
993
    : public __and_,
994
                    __is_nt_constructible_impl<_Tp, _Args...>>::type
995
    { };
996
 
997
  template::value>
998
    struct __is_nothrow_copy_constructible_impl;
999
 
1000
  template
1001
    struct __is_nothrow_copy_constructible_impl<_Tp, true>
1002
    : public false_type { };
1003
 
1004
  template
1005
    struct __is_nothrow_copy_constructible_impl<_Tp, false>
1006
    : public is_nothrow_constructible<_Tp, const _Tp&>
1007
    { };
1008
 
1009
  /// is_nothrow_copy_constructible
1010
  template
1011
    struct is_nothrow_copy_constructible
1012
    : public __is_nothrow_copy_constructible_impl<_Tp>
1013
    { };
1014
 
1015
  template::value>
1016
    struct __is_nothrow_move_constructible_impl;
1017
 
1018
  template
1019
    struct __is_nothrow_move_constructible_impl<_Tp, true>
1020
    : public false_type { };
1021
 
1022
  template
1023
    struct __is_nothrow_move_constructible_impl<_Tp, false>
1024
    : public is_nothrow_constructible<_Tp, _Tp&&>
1025
    { };
1026
 
1027
  /// is_nothrow_move_constructible
1028
  template
1029
    struct is_nothrow_move_constructible
1030
    : public __is_nothrow_move_constructible_impl<_Tp>
1031
    { };
1032
 
1033
  template
1034
    class __is_assignable_helper
1035
    : public __sfinae_types
1036
    {
1037
      template
1038
        static decltype(declval<_Tp1>() = declval<_Up1>(), __one())
1039
        __test(int);
1040
 
1041
      template
1042
        static __two __test(...);
1043
 
1044
    public:
1045
      static constexpr bool value = sizeof(__test<_Tp, _Up>(0)) == 1;
1046
    };
1047
 
1048
  /// is_assignable
1049
  template
1050
    struct is_assignable
1051
    : public integral_constant
1052
                               __is_assignable_helper<_Tp, _Up>::value>
1053
    { };
1054
 
1055
  template::value>
1056
    struct __is_copy_assignable_impl;
1057
 
1058
  template
1059
    struct __is_copy_assignable_impl<_Tp, true>
1060
    : public false_type { };
1061
 
1062
  template
1063
    struct __is_copy_assignable_impl<_Tp, false>
1064
    : public is_assignable<_Tp&, const _Tp&>
1065
    { };
1066
 
1067
  /// is_copy_assignable
1068
  template
1069
    struct is_copy_assignable
1070
    : public __is_copy_assignable_impl<_Tp>
1071
    { };
1072
 
1073
  template::value>
1074
    struct __is_move_assignable_impl;
1075
 
1076
  template
1077
    struct __is_move_assignable_impl<_Tp, true>
1078
    : public false_type { };
1079
 
1080
  template
1081
    struct __is_move_assignable_impl<_Tp, false>
1082
    : public is_assignable<_Tp&, _Tp&&>
1083
    { };
1084
 
1085
  /// is_move_assignable
1086
  template
1087
    struct is_move_assignable
1088
    : public __is_move_assignable_impl<_Tp>
1089
    { };
1090
 
1091
  template
1092
    struct __is_nt_assignable_impl
1093
    : public integral_constant() = declval<_Up>())>
1094
    { };
1095
 
1096
  /// is_nothrow_assignable
1097
  template
1098
    struct is_nothrow_assignable
1099
    : public __and_,
1100
                    __is_nt_assignable_impl<_Tp, _Up>>::type
1101
    { };
1102
 
1103
  template::value>
1104
    struct __is_nt_copy_assignable_impl;
1105
 
1106
  template
1107
    struct __is_nt_copy_assignable_impl<_Tp, true>
1108
    : public false_type { };
1109
 
1110
  template
1111
    struct __is_nt_copy_assignable_impl<_Tp, false>
1112
    : public is_nothrow_assignable<_Tp&, const _Tp&>
1113
    { };
1114
 
1115
  /// is_nothrow_copy_assignable
1116
  template
1117
    struct is_nothrow_copy_assignable
1118
    : public __is_nt_copy_assignable_impl<_Tp>
1119
    { };
1120
 
1121
  template::value>
1122
    struct __is_nt_move_assignable_impl;
1123
 
1124
  template
1125
    struct __is_nt_move_assignable_impl<_Tp, true>
1126
    : public false_type { };
1127
 
1128
  template
1129
    struct __is_nt_move_assignable_impl<_Tp, false>
1130
    : public is_nothrow_assignable<_Tp&, _Tp&&>
1131
    { };
1132
 
1133
  /// is_nothrow_move_assignable
1134
  template
1135
    struct is_nothrow_move_assignable
1136
    : public __is_nt_move_assignable_impl<_Tp>
1137
    { };
1138
 
1139
  /// has_trivial_default_constructor
1140
  template
1141
    struct has_trivial_default_constructor
1142
    : public integral_constant
1143
    { };
1144
 
1145
  /// has_trivial_copy_constructor
1146
  template
1147
    struct has_trivial_copy_constructor
1148
    : public integral_constant
1149
    { };
1150
 
1151
  /// has_trivial_copy_assign
1152
  template
1153
    struct has_trivial_copy_assign
1154
    : public integral_constant
1155
    { };
1156
 
1157
  /// has_trivial_destructor
1158
  template
1159
    struct has_trivial_destructor
1160
    : public integral_constant
1161
    { };
1162
 
1163
  /// has_virtual_destructor
1164
  template
1165
    struct has_virtual_destructor
1166
    : public integral_constant
1167
    { };
1168
 
1169
 
1170
  // type property queries.
1171
 
1172
  /// alignment_of
1173
  template
1174
    struct alignment_of
1175
    : public integral_constant { };
1176
 
1177
  /// rank
1178
  template
1179
    struct rank
1180
    : public integral_constant { };
1181
 
1182
  template
1183
    struct rank<_Tp[_Size]>
1184
    : public integral_constant::value> { };
1185
 
1186
  template
1187
    struct rank<_Tp[]>
1188
    : public integral_constant::value> { };
1189
 
1190
  /// extent
1191
  template
1192
    struct extent
1193
    : public integral_constant { };
1194
 
1195
  template
1196
    struct extent<_Tp[_Size], _Uint>
1197
    : public integral_constant
1198
                               _Uint == 0 ? _Size : extent<_Tp,
1199
                                                           _Uint - 1>::value>
1200
    { };
1201
 
1202
  template
1203
    struct extent<_Tp[], _Uint>
1204
    : public integral_constant
1205
                               _Uint == 0 ? 0 : extent<_Tp,
1206
                                                       _Uint - 1>::value>
1207
    { };
1208
 
1209
 
1210
  // type relations.
1211
 
1212
  /// is_same
1213
  template
1214
    struct is_same
1215
    : public false_type { };
1216
 
1217
  template
1218
    struct is_same<_Tp, _Tp>
1219
    : public true_type { };
1220
 
1221
  /// is_base_of
1222
  template
1223
    struct is_base_of
1224
    : public integral_constant
1225
    { };
1226
 
1227
  template
1228
           bool = __or_, is_function<_To>,
1229
                        is_array<_To>>::value>
1230
    struct __is_convertible_helper
1231
    { static constexpr bool value = is_void<_To>::value; };
1232
 
1233
  template
1234
    class __is_convertible_helper<_From, _To, false>
1235
    : public __sfinae_types
1236
    {
1237
      template
1238
        static void __test_aux(_To1);
1239
 
1240
      template
1241
        static decltype(__test_aux<_To1>(declval<_From1>()), __one())
1242
        __test(int);
1243
 
1244
      template
1245
        static __two __test(...);
1246
 
1247
    public:
1248
      static constexpr bool value = sizeof(__test<_From, _To>(0)) == 1;
1249
    };
1250
 
1251
  /// is_convertible
1252
  template
1253
    struct is_convertible
1254
    : public integral_constant
1255
                               __is_convertible_helper<_From, _To>::value>
1256
    { };
1257
 
1258
  /// is_explicitly_convertible
1259
  template
1260
    struct is_explicitly_convertible
1261
    : public is_constructible<_To, _From>
1262
    { };
1263
 
1264
 
1265
  // const-volatile modifications.
1266
 
1267
  /// remove_const
1268
  template
1269
    struct remove_const
1270
    { typedef _Tp     type; };
1271
 
1272
  template
1273
    struct remove_const<_Tp const>
1274
    { typedef _Tp     type; };
1275
 
1276
  /// remove_volatile
1277
  template
1278
    struct remove_volatile
1279
    { typedef _Tp     type; };
1280
 
1281
  template
1282
    struct remove_volatile<_Tp volatile>
1283
    { typedef _Tp     type; };
1284
 
1285
  /// remove_cv
1286
  template
1287
    struct remove_cv
1288
    {
1289
      typedef typename
1290
      remove_const::type>::type     type;
1291
    };
1292
 
1293
  /// add_const
1294
  template
1295
    struct add_const
1296
    { typedef _Tp const     type; };
1297
 
1298
  /// add_volatile
1299
  template
1300
    struct add_volatile
1301
    { typedef _Tp volatile     type; };
1302
 
1303
  /// add_cv
1304
  template
1305
    struct add_cv
1306
    {
1307
      typedef typename
1308
      add_const::type>::type     type;
1309
    };
1310
 
1311
 
1312
  // Reference transformations.
1313
 
1314
  /// remove_reference
1315
  template
1316
    struct remove_reference
1317
    { typedef _Tp   type; };
1318
 
1319
  template
1320
    struct remove_reference<_Tp&>
1321
    { typedef _Tp   type; };
1322
 
1323
  template
1324
    struct remove_reference<_Tp&&>
1325
    { typedef _Tp   type; };
1326
 
1327
  template
1328
           bool = __and_<__not_>,
1329
                         __not_>>::value,
1330
           bool = is_rvalue_reference<_Tp>::value>
1331
    struct __add_lvalue_reference_helper
1332
    { typedef _Tp   type; };
1333
 
1334
  template
1335
    struct __add_lvalue_reference_helper<_Tp, true, false>
1336
    { typedef _Tp&   type; };
1337
 
1338
  template
1339
    struct __add_lvalue_reference_helper<_Tp, false, true>
1340
    { typedef typename remove_reference<_Tp>::type&   type; };
1341
 
1342
  /// add_lvalue_reference
1343
  template
1344
    struct add_lvalue_reference
1345
    : public __add_lvalue_reference_helper<_Tp>
1346
    { };
1347
 
1348
  template
1349
           bool = __and_<__not_>,
1350
                         __not_>>::value>
1351
    struct __add_rvalue_reference_helper
1352
    { typedef _Tp   type; };
1353
 
1354
  template
1355
    struct __add_rvalue_reference_helper<_Tp, true>
1356
    { typedef _Tp&&   type; };
1357
 
1358
  /// add_rvalue_reference
1359
  template
1360
    struct add_rvalue_reference
1361
    : public __add_rvalue_reference_helper<_Tp>
1362
    { };
1363
 
1364
 
1365
  // sign modifications.
1366
 
1367
  // Utility for constructing identically cv-qualified types.
1368
  template
1369
    struct __cv_selector;
1370
 
1371
  template
1372
    struct __cv_selector<_Unqualified, false, false>
1373
    { typedef _Unqualified __type; };
1374
 
1375
  template
1376
    struct __cv_selector<_Unqualified, false, true>
1377
    { typedef volatile _Unqualified __type; };
1378
 
1379
  template
1380
    struct __cv_selector<_Unqualified, true, false>
1381
    { typedef const _Unqualified __type; };
1382
 
1383
  template
1384
    struct __cv_selector<_Unqualified, true, true>
1385
    { typedef const volatile _Unqualified __type; };
1386
 
1387
  template
1388
           bool _IsConst = is_const<_Qualified>::value,
1389
           bool _IsVol = is_volatile<_Qualified>::value>
1390
    class __match_cv_qualifiers
1391
    {
1392
      typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1393
 
1394
    public:
1395
      typedef typename __match::__type __type;
1396
    };
1397
 
1398
  // Utility for finding the unsigned versions of signed integral types.
1399
  template
1400
    struct __make_unsigned
1401
    { typedef _Tp __type; };
1402
 
1403
  template<>
1404
    struct __make_unsigned
1405
    { typedef unsigned char __type; };
1406
 
1407
  template<>
1408
    struct __make_unsigned
1409
    { typedef unsigned char __type; };
1410
 
1411
  template<>
1412
    struct __make_unsigned
1413
    { typedef unsigned short __type; };
1414
 
1415
  template<>
1416
    struct __make_unsigned
1417
    { typedef unsigned int __type; };
1418
 
1419
  template<>
1420
    struct __make_unsigned
1421
    { typedef unsigned long __type; };
1422
 
1423
  template<>
1424
    struct __make_unsigned
1425
    { typedef unsigned long long __type; };
1426
 
1427
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1428
  template<>
1429
    struct __make_unsigned<__int128>
1430
    { typedef unsigned __int128 __type; };
1431
#endif
1432
 
1433
  // Select between integral and enum: not possible to be both.
1434
  template
1435
           bool _IsInt = is_integral<_Tp>::value,
1436
           bool _IsEnum = is_enum<_Tp>::value>
1437
    class __make_unsigned_selector;
1438
 
1439
  template
1440
    class __make_unsigned_selector<_Tp, true, false>
1441
    {
1442
      typedef __make_unsigned::type> __unsignedt;
1443
      typedef typename __unsignedt::__type __unsigned_type;
1444
      typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1445
 
1446
    public:
1447
      typedef typename __cv_unsigned::__type __type;
1448
    };
1449
 
1450
  template
1451
    class __make_unsigned_selector<_Tp, false, true>
1452
    {
1453
      // With -fshort-enums, an enum may be as small as a char.
1454
      typedef unsigned char __smallest;
1455
      static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1456
      static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short);
1457
      static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int);
1458
      typedef conditional<__b2, unsigned int, unsigned long> __cond2;
1459
      typedef typename __cond2::type __cond2_type;
1460
      typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
1461
      typedef typename __cond1::type __cond1_type;
1462
 
1463
    public:
1464
      typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
1465
    };
1466
 
1467
  // Given an integral/enum type, return the corresponding unsigned
1468
  // integer type.
1469
  // Primary template.
1470
  /// make_unsigned
1471
  template
1472
    struct make_unsigned
1473
    { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1474
 
1475
  // Integral, but don't define.
1476
  template<>
1477
    struct make_unsigned;
1478
 
1479
 
1480
  // Utility for finding the signed versions of unsigned integral types.
1481
  template
1482
    struct __make_signed
1483
    { typedef _Tp __type; };
1484
 
1485
  template<>
1486
    struct __make_signed
1487
    { typedef signed char __type; };
1488
 
1489
  template<>
1490
    struct __make_signed
1491
    { typedef signed char __type; };
1492
 
1493
  template<>
1494
    struct __make_signed
1495
    { typedef signed short __type; };
1496
 
1497
  template<>
1498
    struct __make_signed
1499
    { typedef signed int __type; };
1500
 
1501
  template<>
1502
    struct __make_signed
1503
    { typedef signed long __type; };
1504
 
1505
  template<>
1506
    struct __make_signed
1507
    { typedef signed long long __type; };
1508
 
1509
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1510
  template<>
1511
    struct __make_signed
1512
    { typedef __int128 __type; };
1513
#endif
1514
 
1515
  // Select between integral and enum: not possible to be both.
1516
  template
1517
           bool _IsInt = is_integral<_Tp>::value,
1518
           bool _IsEnum = is_enum<_Tp>::value>
1519
    class __make_signed_selector;
1520
 
1521
  template
1522
    class __make_signed_selector<_Tp, true, false>
1523
    {
1524
      typedef __make_signed::type> __signedt;
1525
      typedef typename __signedt::__type __signed_type;
1526
      typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed;
1527
 
1528
    public:
1529
      typedef typename __cv_signed::__type __type;
1530
    };
1531
 
1532
  template
1533
    class __make_signed_selector<_Tp, false, true>
1534
    {
1535
      // With -fshort-enums, an enum may be as small as a char.
1536
      typedef signed char __smallest;
1537
      static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1538
      static const bool __b1 = sizeof(_Tp) <= sizeof(signed short);
1539
      static const bool __b2 = sizeof(_Tp) <= sizeof(signed int);
1540
      typedef conditional<__b2, signed int, signed long> __cond2;
1541
      typedef typename __cond2::type __cond2_type;
1542
      typedef conditional<__b1, signed short, __cond2_type> __cond1;
1543
      typedef typename __cond1::type __cond1_type;
1544
 
1545
    public:
1546
      typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
1547
    };
1548
 
1549
  // Given an integral/enum type, return the corresponding signed
1550
  // integer type.
1551
  // Primary template.
1552
  /// make_signed
1553
  template
1554
    struct make_signed
1555
    { typedef typename __make_signed_selector<_Tp>::__type type; };
1556
 
1557
  // Integral, but don't define.
1558
  template<>
1559
    struct make_signed;
1560
 
1561
 
1562
  // array modifications.
1563
 
1564
  /// remove_extent
1565
  template
1566
    struct remove_extent
1567
    { typedef _Tp     type; };
1568
 
1569
  template
1570
    struct remove_extent<_Tp[_Size]>
1571
    { typedef _Tp     type; };
1572
 
1573
  template
1574
    struct remove_extent<_Tp[]>
1575
    { typedef _Tp     type; };
1576
 
1577
  /// remove_all_extents
1578
  template
1579
    struct remove_all_extents
1580
    { typedef _Tp     type; };
1581
 
1582
  template
1583
    struct remove_all_extents<_Tp[_Size]>
1584
    { typedef typename remove_all_extents<_Tp>::type     type; };
1585
 
1586
  template
1587
    struct remove_all_extents<_Tp[]>
1588
    { typedef typename remove_all_extents<_Tp>::type     type; };
1589
 
1590
 
1591
  // pointer modifications.
1592
 
1593
  template
1594
    struct __remove_pointer_helper
1595
    { typedef _Tp     type; };
1596
 
1597
  template
1598
    struct __remove_pointer_helper<_Tp, _Up*>
1599
    { typedef _Up     type; };
1600
 
1601
  /// remove_pointer
1602
  template
1603
    struct remove_pointer
1604
    : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1605
    { };
1606
 
1607
  /// add_pointer
1608
  template
1609
    struct add_pointer
1610
    { typedef typename remove_reference<_Tp>::type*     type; };
1611
 
1612
 
1613
  template
1614
    struct __aligned_storage_msa
1615
    {
1616
      union __type
1617
      {
1618
        unsigned char __data[_Len];
1619
        struct __attribute__((__aligned__)) { } __align;
1620
      };
1621
    };
1622
 
1623
  /**
1624
   *  @brief Alignment type.
1625
   *
1626
   *  The value of _Align is a default-alignment which shall be the
1627
   *  most stringent alignment requirement for any C++ object type
1628
   *  whose size is no greater than _Len (3.9). The member typedef
1629
   *  type shall be a POD type suitable for use as uninitialized
1630
   *  storage for any object whose size is at most _Len and whose
1631
   *  alignment is a divisor of _Align.
1632
  */
1633
  template
1634
           __alignof__(typename __aligned_storage_msa<_Len>::__type)>
1635
    struct aligned_storage
1636
    {
1637
      union type
1638
      {
1639
        unsigned char __data[_Len];
1640
        struct __attribute__((__aligned__((_Align)))) { } __align;
1641
      };
1642
    };
1643
 
1644
 
1645
  // Decay trait for arrays and functions, used for perfect forwarding
1646
  // in make_pair, make_tuple, etc.
1647
  template
1648
           bool _IsArray = is_array<_Up>::value,
1649
           bool _IsFunction = is_function<_Up>::value>
1650
    struct __decay_selector;
1651
 
1652
  // NB: DR 705.
1653
  template
1654
    struct __decay_selector<_Up, false, false>
1655
    { typedef typename remove_cv<_Up>::type __type; };
1656
 
1657
  template
1658
    struct __decay_selector<_Up, true, false>
1659
    { typedef typename remove_extent<_Up>::type* __type; };
1660
 
1661
  template
1662
    struct __decay_selector<_Up, false, true>
1663
    { typedef typename add_pointer<_Up>::type __type; };
1664
 
1665
  /// decay
1666
  template
1667
    class decay
1668
    {
1669
      typedef typename remove_reference<_Tp>::type __remove_type;
1670
 
1671
    public:
1672
      typedef typename __decay_selector<__remove_type>::__type type;
1673
    };
1674
 
1675
  template
1676
    class reference_wrapper;
1677
 
1678
  // Helper which adds a reference to a type when given a reference_wrapper
1679
  template
1680
    struct __strip_reference_wrapper
1681
    {
1682
      typedef _Tp __type;
1683
    };
1684
 
1685
  template
1686
    struct __strip_reference_wrapper >
1687
    {
1688
      typedef _Tp& __type;
1689
    };
1690
 
1691
  template
1692
    struct __strip_reference_wrapper >
1693
    {
1694
      typedef _Tp& __type;
1695
    };
1696
 
1697
  template
1698
    struct __decay_and_strip
1699
    {
1700
      typedef typename __strip_reference_wrapper<
1701
        typename decay<_Tp>::type>::__type __type;
1702
    };
1703
 
1704
 
1705
  // Define a nested type if some predicate holds.
1706
  // Primary template.
1707
  /// enable_if
1708
  template
1709
    struct enable_if
1710
    { };
1711
 
1712
  // Partial specialization for true.
1713
  template
1714
    struct enable_if
1715
    { typedef _Tp type; };
1716
 
1717
 
1718
  // A conditional expression, but for types. If true, first, if false, second.
1719
  // Primary template.
1720
  /// conditional
1721
  template
1722
    struct conditional
1723
    { typedef _Iftrue type; };
1724
 
1725
  // Partial specialization for false.
1726
  template
1727
    struct conditional
1728
    { typedef _Iffalse type; };
1729
 
1730
 
1731
  /// common_type
1732
  template
1733
    struct common_type;
1734
 
1735
  template
1736
    struct common_type<_Tp>
1737
    { typedef _Tp type; };
1738
 
1739
  template
1740
    struct common_type<_Tp, _Up>
1741
    { typedef decltype(true ? declval<_Tp>() : declval<_Up>()) type; };
1742
 
1743
  template
1744
    struct common_type<_Tp, _Up, _Vp...>
1745
    {
1746
      typedef typename
1747
        common_type::type, _Vp...>::type type;
1748
    };
1749
 
1750
  /// underlying_type
1751
  template
1752
    struct underlying_type
1753
    {
1754
      typedef __underlying_type(_Tp) type;
1755
    };
1756
 
1757
  /// declval
1758
  template
1759
    struct __declval_protector
1760
    {
1761
      static const bool __stop = false;
1762
      static typename add_rvalue_reference<_Tp>::type __delegate();
1763
    };
1764
 
1765
  template
1766
    inline typename add_rvalue_reference<_Tp>::type
1767
    declval() noexcept
1768
    {
1769
      static_assert(__declval_protector<_Tp>::__stop,
1770
                    "declval() must not be used!");
1771
      return __declval_protector<_Tp>::__delegate();
1772
    }
1773
 
1774
  /// result_of
1775
  template
1776
    class result_of;
1777
 
1778
  template
1779
    struct _Result_of_memobj;
1780
 
1781
  template
1782
    struct _Result_of_memobj<_Res _Class::*, _Arg>
1783
    {
1784
    private:
1785
      typedef _Res _Class::* _Func;
1786
 
1787
      template
1788
        static _Tp _S_get(const _Class&);
1789
      template
1790
        static decltype(*declval<_Tp>()) _S_get(...);
1791
 
1792
    public:
1793
      typedef
1794
        decltype(_S_get<_Arg>(declval<_Arg>()).*declval<_Func>())
1795
        __type;
1796
    };
1797
 
1798
  template
1799
    struct _Result_of_memfun;
1800
 
1801
  template
1802
    struct _Result_of_memfun<_Res _Class::*, _Arg, _Args...>
1803
    {
1804
    private:
1805
      typedef _Res _Class::* _Func;
1806
 
1807
      template
1808
        static _Tp _S_get(const _Class&);
1809
      template
1810
        static decltype(*declval<_Tp>()) _S_get(...);
1811
 
1812
    public:
1813
      typedef
1814
        decltype((_S_get<_Arg>(declval<_Arg>()).*declval<_Func>())
1815
            (declval<_Args>()...) )
1816
        __type;
1817
    };
1818
 
1819
  template
1820
    struct _Result_of_impl;
1821
 
1822
  template
1823
    struct _Result_of_impl
1824
    {
1825
      typedef
1826
        decltype( declval<_Functor>()(declval<_ArgTypes>()...) )
1827
        __type;
1828
    };
1829
 
1830
  template
1831
    struct _Result_of_impl
1832
    : _Result_of_memobj::type, _Arg>
1833
    {
1834
      typedef typename _Result_of_memobj<
1835
        typename remove_reference<_MemPtr>::type, _Arg>::__type
1836
        __type;
1837
    };
1838
 
1839
  template
1840
    struct _Result_of_impl
1841
    : _Result_of_memfun::type, _Arg,
1842
                        _ArgTypes...>
1843
    {
1844
      typedef typename _Result_of_memfun<
1845
        typename remove_reference<_MemPtr>::type, _Arg, _ArgTypes...>::__type
1846
        __type;
1847
    };
1848
 
1849
  template
1850
    struct result_of<_Functor(_ArgTypes...)>
1851
    : _Result_of_impl
1852
                        typename remove_reference<_Functor>::type >::value,
1853
                      is_member_function_pointer<
1854
                        typename remove_reference<_Functor>::type >::value,
1855
                      _Functor, _ArgTypes...>
1856
    {
1857
      typedef typename _Result_of_impl<
1858
        is_member_object_pointer<
1859
          typename remove_reference<_Functor>::type >::value,
1860
        is_member_function_pointer<
1861
          typename remove_reference<_Functor>::type >::value,
1862
        _Functor, _ArgTypes...>::__type
1863
        type;
1864
    };
1865
 
1866
  /**
1867
   *  Use SFINAE to determine if the type _Tp has a publicly-accessible
1868
   *  member type _NTYPE.
1869
   */
1870
#define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE)                         \
1871
  template                                         \
1872
    class __has_##_NTYPE##_helper                                \
1873
    : __sfinae_types                                             \
1874
    {                                                            \
1875
      template                                     \
1876
        struct _Wrap_type                                        \
1877
        { };                                                     \
1878
                                                                 \
1879
      template                                     \
1880
        static __one __test(_Wrap_type*);  \
1881
                                                                 \
1882
      template                                     \
1883
        static __two __test(...);                                \
1884
                                                                 \
1885
    public:                                                      \
1886
      static constexpr bool value = sizeof(__test<_Tp>(0)) == 1; \
1887
    };                                                           \
1888
                                                                 \
1889
  template                                         \
1890
    struct __has_##_NTYPE                                        \
1891
    : integral_constant
1892
                        ::type>::value>  \
1893
    { };
1894
 
1895
  // @} group metaprogramming
1896
// _GLIBCXX_END_NAMESPACE_VERSION
1897
} // namespace
1898
 
1899
// #endif  // __GXX_EXPERIMENTAL_CXX0X__
1900
 
1901
#endif  // _GLIBCXX_TYPE_TRAITS

powered by: WebSVN 2.1.0

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