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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [include/] [std/] [type_traits] - Blame information for rev 848

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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