libstdc++
type_traits
1 // C++11 <type_traits> -*- C++ -*-
2 
3 // Copyright (C) 2007-2014 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 // <http://www.gnu.org/licenses/>.
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 #if __cplusplus < 201103L
35 # include <bits/c++0x_warning.h>
36 #else
37 
38 #include <bits/c++config.h>
39 
40 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
41 # if defined (__UINT_LEAST16_TYPE__) && defined(__UINT_LEAST32_TYPE__)
42 namespace std
43 {
44  typedef __UINT_LEAST16_TYPE__ uint_least16_t;
45  typedef __UINT_LEAST32_TYPE__ uint_least32_t;
46 }
47 # else
48 # include <cstdint>
49 # endif
50 #endif
51 
52 namespace std _GLIBCXX_VISIBILITY(default)
53 {
54 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 
56  /**
57  * @defgroup metaprogramming Metaprogramming
58  * @ingroup utilities
59  *
60  * Template utilities for compile-time introspection and modification,
61  * including type classification traits, type property inspection traits
62  * and type transformation traits.
63  *
64  * @{
65  */
66 
67  /// integral_constant
68  template<typename _Tp, _Tp __v>
69  struct integral_constant
70  {
71  static constexpr _Tp value = __v;
72  typedef _Tp value_type;
73  typedef integral_constant<_Tp, __v> type;
74  constexpr operator value_type() const { return value; }
75 #if __cplusplus > 201103L
76 
77 #define __cpp_lib_integral_constant_callable 201304
78 
79  constexpr value_type operator()() const { return value; }
80 #endif
81  };
82 
83  template<typename _Tp, _Tp __v>
84  constexpr _Tp integral_constant<_Tp, __v>::value;
85 
86  /// The type used as a compile-time boolean with true value.
87  typedef integral_constant<bool, true> true_type;
88 
89  /// The type used as a compile-time boolean with false value.
90  typedef integral_constant<bool, false> false_type;
91 
92  // Meta programming helper types.
93 
94  template<bool, typename, typename>
95  struct conditional;
96 
97  template<typename...>
98  struct __or_;
99 
100  template<>
101  struct __or_<>
102  : public false_type
103  { };
104 
105  template<typename _B1>
106  struct __or_<_B1>
107  : public _B1
108  { };
109 
110  template<typename _B1, typename _B2>
111  struct __or_<_B1, _B2>
112  : public conditional<_B1::value, _B1, _B2>::type
113  { };
114 
115  template<typename _B1, typename _B2, typename _B3, typename... _Bn>
116  struct __or_<_B1, _B2, _B3, _Bn...>
117  : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
118  { };
119 
120  template<typename...>
121  struct __and_;
122 
123  template<>
124  struct __and_<>
125  : public true_type
126  { };
127 
128  template<typename _B1>
129  struct __and_<_B1>
130  : public _B1
131  { };
132 
133  template<typename _B1, typename _B2>
134  struct __and_<_B1, _B2>
135  : public conditional<_B1::value, _B2, _B1>::type
136  { };
137 
138  template<typename _B1, typename _B2, typename _B3, typename... _Bn>
139  struct __and_<_B1, _B2, _B3, _Bn...>
140  : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
141  { };
142 
143  template<typename _Pp>
144  struct __not_
145  : public integral_constant<bool, !_Pp::value>
146  { };
147 
148  // For several sfinae-friendly trait implementations we transport both the
149  // result information (as the member type) and the failure information (no
150  // member type). This is very similar to std::enable_if, but we cannot use
151  // them, because we need to derive from them as an implementation detail.
152 
153  template<typename _Tp>
154  struct __success_type
155  { typedef _Tp type; };
156 
157  struct __failure_type
158  { };
159 
160  // Primary type categories.
161 
162  template<typename>
163  struct remove_cv;
164 
165  template<typename>
166  struct __is_void_helper
167  : public false_type { };
168 
169  template<>
170  struct __is_void_helper<void>
171  : public true_type { };
172 
173  /// is_void
174  template<typename _Tp>
175  struct is_void
176  : public __is_void_helper<typename remove_cv<_Tp>::type>::type
177  { };
178 
179  template<typename>
180  struct __is_integral_helper
181  : public false_type { };
182 
183  template<>
184  struct __is_integral_helper<bool>
185  : public true_type { };
186 
187  template<>
188  struct __is_integral_helper<char>
189  : public true_type { };
190 
191  template<>
192  struct __is_integral_helper<signed char>
193  : public true_type { };
194 
195  template<>
196  struct __is_integral_helper<unsigned char>
197  : public true_type { };
198 
199 #ifdef _GLIBCXX_USE_WCHAR_T
200  template<>
201  struct __is_integral_helper<wchar_t>
202  : public true_type { };
203 #endif
204 
205  template<>
206  struct __is_integral_helper<char16_t>
207  : public true_type { };
208 
209  template<>
210  struct __is_integral_helper<char32_t>
211  : public true_type { };
212 
213  template<>
214  struct __is_integral_helper<short>
215  : public true_type { };
216 
217  template<>
218  struct __is_integral_helper<unsigned short>
219  : public true_type { };
220 
221  template<>
222  struct __is_integral_helper<int>
223  : public true_type { };
224 
225  template<>
226  struct __is_integral_helper<unsigned int>
227  : public true_type { };
228 
229  template<>
230  struct __is_integral_helper<long>
231  : public true_type { };
232 
233  template<>
234  struct __is_integral_helper<unsigned long>
235  : public true_type { };
236 
237  template<>
238  struct __is_integral_helper<long long>
239  : public true_type { };
240 
241  template<>
242  struct __is_integral_helper<unsigned long long>
243  : public true_type { };
244 
245 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
246  template<>
247  struct __is_integral_helper<__int128>
248  : public true_type { };
249 
250  template<>
251  struct __is_integral_helper<unsigned __int128>
252  : public true_type { };
253 #endif
254 
255  /// is_integral
256  template<typename _Tp>
257  struct is_integral
258  : public __is_integral_helper<typename remove_cv<_Tp>::type>::type
259  { };
260 
261  template<typename>
262  struct __is_floating_point_helper
263  : public false_type { };
264 
265  template<>
266  struct __is_floating_point_helper<float>
267  : public true_type { };
268 
269  template<>
270  struct __is_floating_point_helper<double>
271  : public true_type { };
272 
273  template<>
274  struct __is_floating_point_helper<long double>
275  : public true_type { };
276 
277 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
278  template<>
279  struct __is_floating_point_helper<__float128>
280  : public true_type { };
281 #endif
282 
283  /// is_floating_point
284  template<typename _Tp>
285  struct is_floating_point
286  : public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type
287  { };
288 
289  /// is_array
290  template<typename>
291  struct is_array
292  : public false_type { };
293 
294  template<typename _Tp, std::size_t _Size>
295  struct is_array<_Tp[_Size]>
296  : public true_type { };
297 
298  template<typename _Tp>
299  struct is_array<_Tp[]>
300  : public true_type { };
301 
302  template<typename>
303  struct __is_pointer_helper
304  : public false_type { };
305 
306  template<typename _Tp>
307  struct __is_pointer_helper<_Tp*>
308  : public true_type { };
309 
310  /// is_pointer
311  template<typename _Tp>
312  struct is_pointer
313  : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type
314  { };
315 
316  /// is_lvalue_reference
317  template<typename>
318  struct is_lvalue_reference
319  : public false_type { };
320 
321  template<typename _Tp>
322  struct is_lvalue_reference<_Tp&>
323  : public true_type { };
324 
325  /// is_rvalue_reference
326  template<typename>
327  struct is_rvalue_reference
328  : public false_type { };
329 
330  template<typename _Tp>
331  struct is_rvalue_reference<_Tp&&>
332  : public true_type { };
333 
334  template<typename>
335  struct is_function;
336 
337  template<typename>
338  struct __is_member_object_pointer_helper
339  : public false_type { };
340 
341  template<typename _Tp, typename _Cp>
342  struct __is_member_object_pointer_helper<_Tp _Cp::*>
343  : public integral_constant<bool, !is_function<_Tp>::value> { };
344 
345  /// is_member_object_pointer
346  template<typename _Tp>
347  struct is_member_object_pointer
348  : public __is_member_object_pointer_helper<
349  typename remove_cv<_Tp>::type>::type
350  { };
351 
352  template<typename>
353  struct __is_member_function_pointer_helper
354  : public false_type { };
355 
356  template<typename _Tp, typename _Cp>
357  struct __is_member_function_pointer_helper<_Tp _Cp::*>
358  : public integral_constant<bool, is_function<_Tp>::value> { };
359 
360  /// is_member_function_pointer
361  template<typename _Tp>
362  struct is_member_function_pointer
363  : public __is_member_function_pointer_helper<
364  typename remove_cv<_Tp>::type>::type
365  { };
366 
367  /// is_enum
368  template<typename _Tp>
369  struct is_enum
370  : public integral_constant<bool, __is_enum(_Tp)>
371  { };
372 
373  /// is_union
374  template<typename _Tp>
375  struct is_union
376  : public integral_constant<bool, __is_union(_Tp)>
377  { };
378 
379  /// is_class
380  template<typename _Tp>
381  struct is_class
382  : public integral_constant<bool, __is_class(_Tp)>
383  { };
384 
385  /// is_function
386  template<typename>
387  struct is_function
388  : public false_type { };
389 
390  template<typename _Res, typename... _ArgTypes>
391  struct is_function<_Res(_ArgTypes...)>
392  : public true_type { };
393 
394  template<typename _Res, typename... _ArgTypes>
395  struct is_function<_Res(_ArgTypes...) &>
396  : public true_type { };
397 
398  template<typename _Res, typename... _ArgTypes>
399  struct is_function<_Res(_ArgTypes...) &&>
400  : public true_type { };
401 
402  template<typename _Res, typename... _ArgTypes>
403  struct is_function<_Res(_ArgTypes......)>
404  : public true_type { };
405 
406  template<typename _Res, typename... _ArgTypes>
407  struct is_function<_Res(_ArgTypes......) &>
408  : public true_type { };
409 
410  template<typename _Res, typename... _ArgTypes>
411  struct is_function<_Res(_ArgTypes......) &&>
412  : public true_type { };
413 
414  template<typename _Res, typename... _ArgTypes>
415  struct is_function<_Res(_ArgTypes...) const>
416  : public true_type { };
417 
418  template<typename _Res, typename... _ArgTypes>
419  struct is_function<_Res(_ArgTypes...) const &>
420  : public true_type { };
421 
422  template<typename _Res, typename... _ArgTypes>
423  struct is_function<_Res(_ArgTypes...) const &&>
424  : public true_type { };
425 
426  template<typename _Res, typename... _ArgTypes>
427  struct is_function<_Res(_ArgTypes......) const>
428  : public true_type { };
429 
430  template<typename _Res, typename... _ArgTypes>
431  struct is_function<_Res(_ArgTypes......) const &>
432  : public true_type { };
433 
434  template<typename _Res, typename... _ArgTypes>
435  struct is_function<_Res(_ArgTypes......) const &&>
436  : public true_type { };
437 
438  template<typename _Res, typename... _ArgTypes>
439  struct is_function<_Res(_ArgTypes...) volatile>
440  : public true_type { };
441 
442  template<typename _Res, typename... _ArgTypes>
443  struct is_function<_Res(_ArgTypes...) volatile &>
444  : public true_type { };
445 
446  template<typename _Res, typename... _ArgTypes>
447  struct is_function<_Res(_ArgTypes...) volatile &&>
448  : public true_type { };
449 
450  template<typename _Res, typename... _ArgTypes>
451  struct is_function<_Res(_ArgTypes......) volatile>
452  : public true_type { };
453 
454  template<typename _Res, typename... _ArgTypes>
455  struct is_function<_Res(_ArgTypes......) volatile &>
456  : public true_type { };
457 
458  template<typename _Res, typename... _ArgTypes>
459  struct is_function<_Res(_ArgTypes......) volatile &&>
460  : public true_type { };
461 
462  template<typename _Res, typename... _ArgTypes>
463  struct is_function<_Res(_ArgTypes...) const volatile>
464  : public true_type { };
465 
466  template<typename _Res, typename... _ArgTypes>
467  struct is_function<_Res(_ArgTypes...) const volatile &>
468  : public true_type { };
469 
470  template<typename _Res, typename... _ArgTypes>
471  struct is_function<_Res(_ArgTypes...) const volatile &&>
472  : public true_type { };
473 
474  template<typename _Res, typename... _ArgTypes>
475  struct is_function<_Res(_ArgTypes......) const volatile>
476  : public true_type { };
477 
478  template<typename _Res, typename... _ArgTypes>
479  struct is_function<_Res(_ArgTypes......) const volatile &>
480  : public true_type { };
481 
482  template<typename _Res, typename... _ArgTypes>
483  struct is_function<_Res(_ArgTypes......) const volatile &&>
484  : public true_type { };
485 
486 #define __cpp_lib_is_null_pointer 201309
487 
488  template<typename>
489  struct __is_null_pointer_helper
490  : public false_type { };
491 
492  template<>
493  struct __is_null_pointer_helper<std::nullptr_t>
494  : public true_type { };
495 
496  /// is_null_pointer (LWG 2247).
497  template<typename _Tp>
498  struct is_null_pointer
499  : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type
500  { };
501 
502  /// __is_nullptr_t (extension).
503  template<typename _Tp>
504  struct __is_nullptr_t
505  : public is_null_pointer<_Tp>
506  { };
507 
508  // Composite type categories.
509 
510  /// is_reference
511  template<typename _Tp>
512  struct is_reference
513  : public __or_<is_lvalue_reference<_Tp>,
514  is_rvalue_reference<_Tp>>::type
515  { };
516 
517  /// is_arithmetic
518  template<typename _Tp>
519  struct is_arithmetic
520  : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
521  { };
522 
523  /// is_fundamental
524  template<typename _Tp>
525  struct is_fundamental
526  : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
527  is_null_pointer<_Tp>>::type
528  { };
529 
530  /// is_object
531  template<typename _Tp>
532  struct is_object
533  : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
534  is_void<_Tp>>>::type
535  { };
536 
537  template<typename>
538  struct is_member_pointer;
539 
540  /// is_scalar
541  template<typename _Tp>
542  struct is_scalar
543  : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
544  is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
545  { };
546 
547  /// is_compound
548  template<typename _Tp>
549  struct is_compound
550  : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
551 
552  template<typename _Tp>
553  struct __is_member_pointer_helper
554  : public false_type { };
555 
556  template<typename _Tp, typename _Cp>
557  struct __is_member_pointer_helper<_Tp _Cp::*>
558  : public true_type { };
559 
560  /// is_member_pointer
561  template<typename _Tp>
562  struct is_member_pointer
563  : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type
564  { };
565 
566  // Utility to detect referenceable types ([defns.referenceable]).
567 
568  template<typename _Tp>
569  struct __is_referenceable
570  : public __or_<is_object<_Tp>, is_reference<_Tp>>::type
571  { };
572 
573  template<typename _Res, typename... _Args>
574  struct __is_referenceable<_Res(_Args...)>
575  : public true_type
576  { };
577 
578  template<typename _Res, typename... _Args>
579  struct __is_referenceable<_Res(_Args......)>
580  : public true_type
581  { };
582 
583  // Type properties.
584 
585  /// is_const
586  template<typename>
587  struct is_const
588  : public false_type { };
589 
590  template<typename _Tp>
591  struct is_const<_Tp const>
592  : public true_type { };
593 
594  /// is_volatile
595  template<typename>
596  struct is_volatile
597  : public false_type { };
598 
599  template<typename _Tp>
600  struct is_volatile<_Tp volatile>
601  : public true_type { };
602 
603  /// is_trivial
604  template<typename _Tp>
605  struct is_trivial
606  : public integral_constant<bool, __is_trivial(_Tp)>
607  { };
608 
609  // is_trivially_copyable (still unimplemented)
610 
611  /// is_standard_layout
612  template<typename _Tp>
613  struct is_standard_layout
614  : public integral_constant<bool, __is_standard_layout(_Tp)>
615  { };
616 
617  /// is_pod
618  // Could use is_standard_layout && is_trivial instead of the builtin.
619  template<typename _Tp>
620  struct is_pod
621  : public integral_constant<bool, __is_pod(_Tp)>
622  { };
623 
624  /// is_literal_type
625  template<typename _Tp>
626  struct is_literal_type
627  : public integral_constant<bool, __is_literal_type(_Tp)>
628  { };
629 
630  /// is_empty
631  template<typename _Tp>
632  struct is_empty
633  : public integral_constant<bool, __is_empty(_Tp)>
634  { };
635 
636  /// is_polymorphic
637  template<typename _Tp>
638  struct is_polymorphic
639  : public integral_constant<bool, __is_polymorphic(_Tp)>
640  { };
641 
642 #if __cplusplus > 201103L
643  /// is_final
644  #define __cpp_lib_is_final 201402L
645  template<typename _Tp>
646  struct is_final
647  : public integral_constant<bool, __is_final(_Tp)>
648  { };
649 #endif
650 
651  /// is_abstract
652  template<typename _Tp>
653  struct is_abstract
654  : public integral_constant<bool, __is_abstract(_Tp)>
655  { };
656 
657  template<typename _Tp,
658  bool = is_arithmetic<_Tp>::value>
659  struct __is_signed_helper
660  : public false_type { };
661 
662  template<typename _Tp>
663  struct __is_signed_helper<_Tp, true>
664  : public integral_constant<bool, _Tp(-1) < _Tp(0)>
665  { };
666 
667  /// is_signed
668  template<typename _Tp>
669  struct is_signed
670  : public __is_signed_helper<_Tp>::type
671  { };
672 
673  /// is_unsigned
674  template<typename _Tp>
675  struct is_unsigned
676  : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>::type
677  { };
678 
679 
680  // Destructible and constructible type properties.
681 
682  template<typename>
683  struct add_rvalue_reference;
684 
685  /**
686  * @brief Utility to simplify expressions used in unevaluated operands
687  * @ingroup utilities
688  */
689  template<typename _Tp>
690  typename add_rvalue_reference<_Tp>::type declval() noexcept;
691 
692  template<typename, unsigned = 0>
693  struct extent;
694 
695  template<typename>
696  struct remove_all_extents;
697 
698  template<typename _Tp>
699  struct __is_array_known_bounds
700  : public integral_constant<bool, (extent<_Tp>::value > 0)>
701  { };
702 
703  template<typename _Tp>
704  struct __is_array_unknown_bounds
705  : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>::type
706  { };
707 
708  // In N3290 is_destructible does not say anything about function
709  // types and abstract types, see LWG 2049. This implementation
710  // describes function types as non-destructible and all complete
711  // object types as destructible, iff the explicit destructor
712  // call expression is wellformed.
713  struct __do_is_destructible_impl
714  {
715  template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
716  static true_type __test(int);
717 
718  template<typename>
719  static false_type __test(...);
720  };
721 
722  template<typename _Tp>
723  struct __is_destructible_impl
724  : public __do_is_destructible_impl
725  {
726  typedef decltype(__test<_Tp>(0)) type;
727  };
728 
729  template<typename _Tp,
730  bool = __or_<is_void<_Tp>,
731  __is_array_unknown_bounds<_Tp>,
732  is_function<_Tp>>::value,
733  bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
734  struct __is_destructible_safe;
735 
736  template<typename _Tp>
737  struct __is_destructible_safe<_Tp, false, false>
738  : public __is_destructible_impl<typename
739  remove_all_extents<_Tp>::type>::type
740  { };
741 
742  template<typename _Tp>
743  struct __is_destructible_safe<_Tp, true, false>
744  : public false_type { };
745 
746  template<typename _Tp>
747  struct __is_destructible_safe<_Tp, false, true>
748  : public true_type { };
749 
750  /// is_destructible
751  template<typename _Tp>
752  struct is_destructible
753  : public __is_destructible_safe<_Tp>::type
754  { };
755 
756  // is_nothrow_destructible requires that is_destructible is
757  // satisfied as well. We realize that by mimicing the
758  // implementation of is_destructible but refer to noexcept(expr)
759  // instead of decltype(expr).
760  struct __do_is_nt_destructible_impl
761  {
762  template<typename _Tp>
763  static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
764  __test(int);
765 
766  template<typename>
767  static false_type __test(...);
768  };
769 
770  template<typename _Tp>
771  struct __is_nt_destructible_impl
772  : public __do_is_nt_destructible_impl
773  {
774  typedef decltype(__test<_Tp>(0)) type;
775  };
776 
777  template<typename _Tp,
778  bool = __or_<is_void<_Tp>,
779  __is_array_unknown_bounds<_Tp>,
780  is_function<_Tp>>::value,
781  bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
782  struct __is_nt_destructible_safe;
783 
784  template<typename _Tp>
785  struct __is_nt_destructible_safe<_Tp, false, false>
786  : public __is_nt_destructible_impl<typename
787  remove_all_extents<_Tp>::type>::type
788  { };
789 
790  template<typename _Tp>
791  struct __is_nt_destructible_safe<_Tp, true, false>
792  : public false_type { };
793 
794  template<typename _Tp>
795  struct __is_nt_destructible_safe<_Tp, false, true>
796  : public true_type { };
797 
798  /// is_nothrow_destructible
799  template<typename _Tp>
800  struct is_nothrow_destructible
801  : public __is_nt_destructible_safe<_Tp>::type
802  { };
803 
804  struct __do_is_default_constructible_impl
805  {
806  template<typename _Tp, typename = decltype(_Tp())>
807  static true_type __test(int);
808 
809  template<typename>
810  static false_type __test(...);
811  };
812 
813  template<typename _Tp>
814  struct __is_default_constructible_impl
815  : public __do_is_default_constructible_impl
816  {
817  typedef decltype(__test<_Tp>(0)) type;
818  };
819 
820  template<typename _Tp>
821  struct __is_default_constructible_atom
822  : public __and_<__not_<is_void<_Tp>>,
823  __is_default_constructible_impl<_Tp>>::type
824  { };
825 
826  template<typename _Tp, bool = is_array<_Tp>::value>
827  struct __is_default_constructible_safe;
828 
829  // The following technique is a workaround for a current core language
830  // restriction, which does not allow for array types to occur in
831  // functional casts of the form T(). Complete arrays can be default-
832  // constructed, if the element type is default-constructible, but
833  // arrays with unknown bounds are not.
834  template<typename _Tp>
835  struct __is_default_constructible_safe<_Tp, true>
836  : public __and_<__is_array_known_bounds<_Tp>,
837  __is_default_constructible_atom<typename
838  remove_all_extents<_Tp>::type>>::type
839  { };
840 
841  template<typename _Tp>
842  struct __is_default_constructible_safe<_Tp, false>
843  : public __is_default_constructible_atom<_Tp>::type
844  { };
845 
846  /// is_default_constructible
847  template<typename _Tp>
848  struct is_default_constructible
849  : public __is_default_constructible_safe<_Tp>::type
850  { };
851 
852 
853  // Implementation of is_constructible.
854 
855  // The hardest part of this trait is the binary direct-initialization
856  // case, because we hit into a functional cast of the form T(arg).
857  // This implementation uses different strategies depending on the
858  // target type to reduce the test overhead as much as possible:
859  //
860  // a) For a reference target type, we use a static_cast expression
861  // modulo its extra cases.
862  //
863  // b) For a non-reference target type we use a ::new expression.
864  struct __do_is_static_castable_impl
865  {
866  template<typename _From, typename _To, typename
867  = decltype(static_cast<_To>(declval<_From>()))>
868  static true_type __test(int);
869 
870  template<typename, typename>
871  static false_type __test(...);
872  };
873 
874  template<typename _From, typename _To>
875  struct __is_static_castable_impl
876  : public __do_is_static_castable_impl
877  {
878  typedef decltype(__test<_From, _To>(0)) type;
879  };
880 
881  template<typename _From, typename _To>
882  struct __is_static_castable_safe
883  : public __is_static_castable_impl<_From, _To>::type
884  { };
885 
886  // __is_static_castable
887  template<typename _From, typename _To>
888  struct __is_static_castable
889  : public integral_constant<bool, (__is_static_castable_safe<
890  _From, _To>::value)>
891  { };
892 
893  // Implementation for non-reference types. To meet the proper
894  // variable definition semantics, we also need to test for
895  // is_destructible in this case.
896  // This form should be simplified by a single expression:
897  // ::delete ::new _Tp(declval<_Arg>()), see c++/51222.
898  struct __do_is_direct_constructible_impl
899  {
900  template<typename _Tp, typename _Arg, typename
901  = decltype(::new _Tp(declval<_Arg>()))>
902  static true_type __test(int);
903 
904  template<typename, typename>
905  static false_type __test(...);
906  };
907 
908  template<typename _Tp, typename _Arg>
909  struct __is_direct_constructible_impl
910  : public __do_is_direct_constructible_impl
911  {
912  typedef decltype(__test<_Tp, _Arg>(0)) type;
913  };
914 
915  template<typename _Tp, typename _Arg>
916  struct __is_direct_constructible_new_safe
917  : public __and_<is_destructible<_Tp>,
918  __is_direct_constructible_impl<_Tp, _Arg>>::type
919  { };
920 
921  template<typename, typename>
922  struct is_same;
923 
924  template<typename, typename>
925  struct is_base_of;
926 
927  template<typename>
928  struct remove_reference;
929 
930  template<typename _From, typename _To, bool
931  = __not_<__or_<is_void<_From>,
932  is_function<_From>>>::value>
933  struct __is_base_to_derived_ref;
934 
935  // Detect whether we have a downcast situation during
936  // reference binding.
937  template<typename _From, typename _To>
938  struct __is_base_to_derived_ref<_From, _To, true>
939  {
940  typedef typename remove_cv<typename remove_reference<_From
941  >::type>::type __src_t;
942  typedef typename remove_cv<typename remove_reference<_To
943  >::type>::type __dst_t;
944  typedef __and_<__not_<is_same<__src_t, __dst_t>>,
945  is_base_of<__src_t, __dst_t>> type;
946  static constexpr bool value = type::value;
947  };
948 
949  template<typename _From, typename _To>
950  struct __is_base_to_derived_ref<_From, _To, false>
951  : public false_type
952  { };
953 
954  template<typename _From, typename _To, bool
955  = __and_<is_lvalue_reference<_From>,
956  is_rvalue_reference<_To>>::value>
957  struct __is_lvalue_to_rvalue_ref;
958 
959  // Detect whether we have an lvalue of non-function type
960  // bound to a reference-compatible rvalue-reference.
961  template<typename _From, typename _To>
962  struct __is_lvalue_to_rvalue_ref<_From, _To, true>
963  {
964  typedef typename remove_cv<typename remove_reference<
965  _From>::type>::type __src_t;
966  typedef typename remove_cv<typename remove_reference<
967  _To>::type>::type __dst_t;
968  typedef __and_<__not_<is_function<__src_t>>,
969  __or_<is_same<__src_t, __dst_t>,
970  is_base_of<__dst_t, __src_t>>> type;
971  static constexpr bool value = type::value;
972  };
973 
974  template<typename _From, typename _To>
975  struct __is_lvalue_to_rvalue_ref<_From, _To, false>
976  : public false_type
977  { };
978 
979  // Here we handle direct-initialization to a reference type as
980  // equivalent to a static_cast modulo overshooting conversions.
981  // These are restricted to the following conversions:
982  // a) A base class value to a derived class reference
983  // b) An lvalue to an rvalue-reference of reference-compatible
984  // types that are not functions
985  template<typename _Tp, typename _Arg>
986  struct __is_direct_constructible_ref_cast
987  : public __and_<__is_static_castable<_Arg, _Tp>,
988  __not_<__or_<__is_base_to_derived_ref<_Arg, _Tp>,
989  __is_lvalue_to_rvalue_ref<_Arg, _Tp>
990  >>>::type
991  { };
992 
993  template<typename _Tp, typename _Arg>
994  struct __is_direct_constructible_new
995  : public conditional<is_reference<_Tp>::value,
996  __is_direct_constructible_ref_cast<_Tp, _Arg>,
997  __is_direct_constructible_new_safe<_Tp, _Arg>
998  >::type
999  { };
1000 
1001  template<typename _Tp, typename _Arg>
1002  struct __is_direct_constructible
1003  : public __is_direct_constructible_new<_Tp, _Arg>::type
1004  { };
1005 
1006  // Since default-construction and binary direct-initialization have
1007  // been handled separately, the implementation of the remaining
1008  // n-ary construction cases is rather straightforward. We can use
1009  // here a functional cast, because array types are excluded anyway
1010  // and this form is never interpreted as a C cast.
1011  struct __do_is_nary_constructible_impl
1012  {
1013  template<typename _Tp, typename... _Args, typename
1014  = decltype(_Tp(declval<_Args>()...))>
1015  static true_type __test(int);
1016 
1017  template<typename, typename...>
1018  static false_type __test(...);
1019  };
1020 
1021  template<typename _Tp, typename... _Args>
1022  struct __is_nary_constructible_impl
1023  : public __do_is_nary_constructible_impl
1024  {
1025  typedef decltype(__test<_Tp, _Args...>(0)) type;
1026  };
1027 
1028  template<typename _Tp, typename... _Args>
1029  struct __is_nary_constructible
1030  : public __is_nary_constructible_impl<_Tp, _Args...>::type
1031  {
1032  static_assert(sizeof...(_Args) > 1,
1033  "Only useful for > 1 arguments");
1034  };
1035 
1036  template<typename _Tp, typename... _Args>
1037  struct __is_constructible_impl
1038  : public __is_nary_constructible<_Tp, _Args...>
1039  { };
1040 
1041  template<typename _Tp, typename _Arg>
1042  struct __is_constructible_impl<_Tp, _Arg>
1043  : public __is_direct_constructible<_Tp, _Arg>
1044  { };
1045 
1046  template<typename _Tp>
1047  struct __is_constructible_impl<_Tp>
1048  : public is_default_constructible<_Tp>
1049  { };
1050 
1051  /// is_constructible
1052  template<typename _Tp, typename... _Args>
1053  struct is_constructible
1054  : public __is_constructible_impl<_Tp, _Args...>::type
1055  { };
1056 
1057  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1058  struct __is_copy_constructible_impl;
1059 
1060  template<typename _Tp>
1061  struct __is_copy_constructible_impl<_Tp, false>
1062  : public false_type { };
1063 
1064  template<typename _Tp>
1065  struct __is_copy_constructible_impl<_Tp, true>
1066  : public is_constructible<_Tp, const _Tp&>
1067  { };
1068 
1069  /// is_copy_constructible
1070  template<typename _Tp>
1071  struct is_copy_constructible
1072  : public __is_copy_constructible_impl<_Tp>
1073  { };
1074 
1075  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1076  struct __is_move_constructible_impl;
1077 
1078  template<typename _Tp>
1079  struct __is_move_constructible_impl<_Tp, false>
1080  : public false_type { };
1081 
1082  template<typename _Tp>
1083  struct __is_move_constructible_impl<_Tp, true>
1084  : public is_constructible<_Tp, _Tp&&>
1085  { };
1086 
1087  /// is_move_constructible
1088  template<typename _Tp>
1089  struct is_move_constructible
1090  : public __is_move_constructible_impl<_Tp>
1091  { };
1092 
1093  template<typename _Tp>
1094  struct __is_nt_default_constructible_atom
1095  : public integral_constant<bool, noexcept(_Tp())>
1096  { };
1097 
1098  template<typename _Tp, bool = is_array<_Tp>::value>
1099  struct __is_nt_default_constructible_impl;
1100 
1101  template<typename _Tp>
1102  struct __is_nt_default_constructible_impl<_Tp, true>
1103  : public __and_<__is_array_known_bounds<_Tp>,
1104  __is_nt_default_constructible_atom<typename
1105  remove_all_extents<_Tp>::type>>::type
1106  { };
1107 
1108  template<typename _Tp>
1109  struct __is_nt_default_constructible_impl<_Tp, false>
1110  : public __is_nt_default_constructible_atom<_Tp>
1111  { };
1112 
1113  /// is_nothrow_default_constructible
1114  template<typename _Tp>
1115  struct is_nothrow_default_constructible
1116  : public __and_<is_default_constructible<_Tp>,
1117  __is_nt_default_constructible_impl<_Tp>>::type
1118  { };
1119 
1120  template<typename _Tp, typename... _Args>
1121  struct __is_nt_constructible_impl
1122  : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
1123  { };
1124 
1125  template<typename _Tp, typename _Arg>
1126  struct __is_nt_constructible_impl<_Tp, _Arg>
1127  : public integral_constant<bool,
1128  noexcept(static_cast<_Tp>(declval<_Arg>()))>
1129  { };
1130 
1131  template<typename _Tp>
1132  struct __is_nt_constructible_impl<_Tp>
1133  : public is_nothrow_default_constructible<_Tp>
1134  { };
1135 
1136  /// is_nothrow_constructible
1137  template<typename _Tp, typename... _Args>
1138  struct is_nothrow_constructible
1139  : public __and_<is_constructible<_Tp, _Args...>,
1140  __is_nt_constructible_impl<_Tp, _Args...>>::type
1141  { };
1142 
1143  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1144  struct __is_nothrow_copy_constructible_impl;
1145 
1146  template<typename _Tp>
1147  struct __is_nothrow_copy_constructible_impl<_Tp, false>
1148  : public false_type { };
1149 
1150  template<typename _Tp>
1151  struct __is_nothrow_copy_constructible_impl<_Tp, true>
1152  : public is_nothrow_constructible<_Tp, const _Tp&>
1153  { };
1154 
1155  /// is_nothrow_copy_constructible
1156  template<typename _Tp>
1157  struct is_nothrow_copy_constructible
1158  : public __is_nothrow_copy_constructible_impl<_Tp>
1159  { };
1160 
1161  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1162  struct __is_nothrow_move_constructible_impl;
1163 
1164  template<typename _Tp>
1165  struct __is_nothrow_move_constructible_impl<_Tp, false>
1166  : public false_type { };
1167 
1168  template<typename _Tp>
1169  struct __is_nothrow_move_constructible_impl<_Tp, true>
1170  : public is_nothrow_constructible<_Tp, _Tp&&>
1171  { };
1172 
1173  /// is_nothrow_move_constructible
1174  template<typename _Tp>
1175  struct is_nothrow_move_constructible
1176  : public __is_nothrow_move_constructible_impl<_Tp>
1177  { };
1178 
1179  template<typename _Tp, typename _Up>
1180  class __is_assignable_helper
1181  {
1182  template<typename _Tp1, typename _Up1,
1183  typename = decltype(declval<_Tp1>() = declval<_Up1>())>
1184  static true_type
1185  __test(int);
1186 
1187  template<typename, typename>
1188  static false_type
1189  __test(...);
1190 
1191  public:
1192  typedef decltype(__test<_Tp, _Up>(0)) type;
1193  };
1194 
1195  /// is_assignable
1196  template<typename _Tp, typename _Up>
1197  struct is_assignable
1198  : public __is_assignable_helper<_Tp, _Up>::type
1199  { };
1200 
1201  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1202  struct __is_copy_assignable_impl;
1203 
1204  template<typename _Tp>
1205  struct __is_copy_assignable_impl<_Tp, false>
1206  : public false_type { };
1207 
1208  template<typename _Tp>
1209  struct __is_copy_assignable_impl<_Tp, true>
1210  : public is_assignable<_Tp&, const _Tp&>
1211  { };
1212 
1213  /// is_copy_assignable
1214  template<typename _Tp>
1215  struct is_copy_assignable
1216  : public __is_copy_assignable_impl<_Tp>
1217  { };
1218 
1219  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1220  struct __is_move_assignable_impl;
1221 
1222  template<typename _Tp>
1223  struct __is_move_assignable_impl<_Tp, false>
1224  : public false_type { };
1225 
1226  template<typename _Tp>
1227  struct __is_move_assignable_impl<_Tp, true>
1228  : public is_assignable<_Tp&, _Tp&&>
1229  { };
1230 
1231  /// is_move_assignable
1232  template<typename _Tp>
1233  struct is_move_assignable
1234  : public __is_move_assignable_impl<_Tp>
1235  { };
1236 
1237  template<typename _Tp, typename _Up>
1238  struct __is_nt_assignable_impl
1239  : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
1240  { };
1241 
1242  /// is_nothrow_assignable
1243  template<typename _Tp, typename _Up>
1244  struct is_nothrow_assignable
1245  : public __and_<is_assignable<_Tp, _Up>,
1246  __is_nt_assignable_impl<_Tp, _Up>>::type
1247  { };
1248 
1249  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1250  struct __is_nt_copy_assignable_impl;
1251 
1252  template<typename _Tp>
1253  struct __is_nt_copy_assignable_impl<_Tp, false>
1254  : public false_type { };
1255 
1256  template<typename _Tp>
1257  struct __is_nt_copy_assignable_impl<_Tp, true>
1258  : public is_nothrow_assignable<_Tp&, const _Tp&>
1259  { };
1260 
1261  /// is_nothrow_copy_assignable
1262  template<typename _Tp>
1263  struct is_nothrow_copy_assignable
1264  : public __is_nt_copy_assignable_impl<_Tp>
1265  { };
1266 
1267  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1268  struct __is_nt_move_assignable_impl;
1269 
1270  template<typename _Tp>
1271  struct __is_nt_move_assignable_impl<_Tp, false>
1272  : public false_type { };
1273 
1274  template<typename _Tp>
1275  struct __is_nt_move_assignable_impl<_Tp, true>
1276  : public is_nothrow_assignable<_Tp&, _Tp&&>
1277  { };
1278 
1279  /// is_nothrow_move_assignable
1280  template<typename _Tp>
1281  struct is_nothrow_move_assignable
1282  : public __is_nt_move_assignable_impl<_Tp>
1283  { };
1284 
1285  /// is_trivially_constructible (still unimplemented)
1286 
1287  /// is_trivially_default_constructible (still unimplemented)
1288 
1289  /// is_trivially_copy_constructible (still unimplemented)
1290 
1291  /// is_trivially_move_constructible (still unimplemented)
1292 
1293  /// is_trivially_assignable (still unimplemented)
1294 
1295  /// is_trivially_copy_assignable (still unimplemented)
1296 
1297  /// is_trivially_move_assignable (still unimplemented)
1298 
1299  /// is_trivially_destructible
1300  template<typename _Tp>
1301  struct is_trivially_destructible
1302  : public __and_<is_destructible<_Tp>, integral_constant<bool,
1303  __has_trivial_destructor(_Tp)>>::type
1304  { };
1305 
1306  /// has_trivial_default_constructor (temporary legacy)
1307  template<typename _Tp>
1308  struct has_trivial_default_constructor
1309  : public integral_constant<bool, __has_trivial_constructor(_Tp)>
1310  { };
1311 
1312  /// has_trivial_copy_constructor (temporary legacy)
1313  template<typename _Tp>
1314  struct has_trivial_copy_constructor
1315  : public integral_constant<bool, __has_trivial_copy(_Tp)>
1316  { };
1317 
1318  /// has_trivial_copy_assign (temporary legacy)
1319  template<typename _Tp>
1320  struct has_trivial_copy_assign
1321  : public integral_constant<bool, __has_trivial_assign(_Tp)>
1322  { };
1323 
1324  /// has_virtual_destructor
1325  template<typename _Tp>
1326  struct has_virtual_destructor
1327  : public integral_constant<bool, __has_virtual_destructor(_Tp)>
1328  { };
1329 
1330 
1331  // type property queries.
1332 
1333  /// alignment_of
1334  template<typename _Tp>
1335  struct alignment_of
1336  : public integral_constant<std::size_t, __alignof__(_Tp)> { };
1337 
1338  /// rank
1339  template<typename>
1340  struct rank
1341  : public integral_constant<std::size_t, 0> { };
1342 
1343  template<typename _Tp, std::size_t _Size>
1344  struct rank<_Tp[_Size]>
1345  : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1346 
1347  template<typename _Tp>
1348  struct rank<_Tp[]>
1349  : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1350 
1351  /// extent
1352  template<typename, unsigned _Uint>
1353  struct extent
1354  : public integral_constant<std::size_t, 0> { };
1355 
1356  template<typename _Tp, unsigned _Uint, std::size_t _Size>
1357  struct extent<_Tp[_Size], _Uint>
1358  : public integral_constant<std::size_t,
1359  _Uint == 0 ? _Size : extent<_Tp,
1360  _Uint - 1>::value>
1361  { };
1362 
1363  template<typename _Tp, unsigned _Uint>
1364  struct extent<_Tp[], _Uint>
1365  : public integral_constant<std::size_t,
1366  _Uint == 0 ? 0 : extent<_Tp,
1367  _Uint - 1>::value>
1368  { };
1369 
1370 
1371  // Type relations.
1372 
1373  /// is_same
1374  template<typename, typename>
1375  struct is_same
1376  : public false_type { };
1377 
1378  template<typename _Tp>
1379  struct is_same<_Tp, _Tp>
1380  : public true_type { };
1381 
1382  /// is_base_of
1383  template<typename _Base, typename _Derived>
1384  struct is_base_of
1385  : public integral_constant<bool, __is_base_of(_Base, _Derived)>
1386  { };
1387 
1388  template<typename _From, typename _To,
1389  bool = __or_<is_void<_From>, is_function<_To>,
1390  is_array<_To>>::value>
1391  struct __is_convertible_helper
1392  { typedef typename is_void<_To>::type type; };
1393 
1394  template<typename _From, typename _To>
1395  class __is_convertible_helper<_From, _To, false>
1396  {
1397  template<typename _To1>
1398  static void __test_aux(_To1);
1399 
1400  template<typename _From1, typename _To1,
1401  typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
1402  static true_type
1403  __test(int);
1404 
1405  template<typename, typename>
1406  static false_type
1407  __test(...);
1408 
1409  public:
1410  typedef decltype(__test<_From, _To>(0)) type;
1411  };
1412 
1413 
1414  /// is_convertible
1415  template<typename _From, typename _To>
1416  struct is_convertible
1417  : public __is_convertible_helper<_From, _To>::type
1418  { };
1419 
1420 
1421  // Const-volatile modifications.
1422 
1423  /// remove_const
1424  template<typename _Tp>
1425  struct remove_const
1426  { typedef _Tp type; };
1427 
1428  template<typename _Tp>
1429  struct remove_const<_Tp const>
1430  { typedef _Tp type; };
1431 
1432  /// remove_volatile
1433  template<typename _Tp>
1434  struct remove_volatile
1435  { typedef _Tp type; };
1436 
1437  template<typename _Tp>
1438  struct remove_volatile<_Tp volatile>
1439  { typedef _Tp type; };
1440 
1441  /// remove_cv
1442  template<typename _Tp>
1443  struct remove_cv
1444  {
1445  typedef typename
1446  remove_const<typename remove_volatile<_Tp>::type>::type type;
1447  };
1448 
1449  /// add_const
1450  template<typename _Tp>
1451  struct add_const
1452  { typedef _Tp const type; };
1453 
1454  /// add_volatile
1455  template<typename _Tp>
1456  struct add_volatile
1457  { typedef _Tp volatile type; };
1458 
1459  /// add_cv
1460  template<typename _Tp>
1461  struct add_cv
1462  {
1463  typedef typename
1464  add_const<typename add_volatile<_Tp>::type>::type type;
1465  };
1466 
1467 #if __cplusplus > 201103L
1468 
1469 #define __cpp_lib_transformation_trait_aliases 201304
1470 
1471  /// Alias template for remove_const
1472  template<typename _Tp>
1473  using remove_const_t = typename remove_const<_Tp>::type;
1474 
1475  /// Alias template for remove_volatile
1476  template<typename _Tp>
1477  using remove_volatile_t = typename remove_volatile<_Tp>::type;
1478 
1479  /// Alias template for remove_cv
1480  template<typename _Tp>
1481  using remove_cv_t = typename remove_cv<_Tp>::type;
1482 
1483  /// Alias template for add_const
1484  template<typename _Tp>
1485  using add_const_t = typename add_const<_Tp>::type;
1486 
1487  /// Alias template for add_volatile
1488  template<typename _Tp>
1489  using add_volatile_t = typename add_volatile<_Tp>::type;
1490 
1491  /// Alias template for add_cv
1492  template<typename _Tp>
1493  using add_cv_t = typename add_cv<_Tp>::type;
1494 #endif
1495 
1496  // Reference transformations.
1497 
1498  /// remove_reference
1499  template<typename _Tp>
1500  struct remove_reference
1501  { typedef _Tp type; };
1502 
1503  template<typename _Tp>
1504  struct remove_reference<_Tp&>
1505  { typedef _Tp type; };
1506 
1507  template<typename _Tp>
1508  struct remove_reference<_Tp&&>
1509  { typedef _Tp type; };
1510 
1511  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1512  struct __add_lvalue_reference_helper
1513  { typedef _Tp type; };
1514 
1515  template<typename _Tp>
1516  struct __add_lvalue_reference_helper<_Tp, true>
1517  { typedef _Tp& type; };
1518 
1519  /// add_lvalue_reference
1520  template<typename _Tp>
1521  struct add_lvalue_reference
1522  : public __add_lvalue_reference_helper<_Tp>
1523  { };
1524 
1525  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1526  struct __add_rvalue_reference_helper
1527  { typedef _Tp type; };
1528 
1529  template<typename _Tp>
1530  struct __add_rvalue_reference_helper<_Tp, true>
1531  { typedef _Tp&& type; };
1532 
1533  /// add_rvalue_reference
1534  template<typename _Tp>
1535  struct add_rvalue_reference
1536  : public __add_rvalue_reference_helper<_Tp>
1537  { };
1538 
1539 #if __cplusplus > 201103L
1540  /// Alias template for remove_reference
1541  template<typename _Tp>
1542  using remove_reference_t = typename remove_reference<_Tp>::type;
1543 
1544  /// Alias template for add_lvalue_reference
1545  template<typename _Tp>
1546  using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1547 
1548  /// Alias template for add_rvalue_reference
1549  template<typename _Tp>
1550  using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1551 #endif
1552 
1553  // Sign modifications.
1554 
1555  // Utility for constructing identically cv-qualified types.
1556  template<typename _Unqualified, bool _IsConst, bool _IsVol>
1557  struct __cv_selector;
1558 
1559  template<typename _Unqualified>
1560  struct __cv_selector<_Unqualified, false, false>
1561  { typedef _Unqualified __type; };
1562 
1563  template<typename _Unqualified>
1564  struct __cv_selector<_Unqualified, false, true>
1565  { typedef volatile _Unqualified __type; };
1566 
1567  template<typename _Unqualified>
1568  struct __cv_selector<_Unqualified, true, false>
1569  { typedef const _Unqualified __type; };
1570 
1571  template<typename _Unqualified>
1572  struct __cv_selector<_Unqualified, true, true>
1573  { typedef const volatile _Unqualified __type; };
1574 
1575  template<typename _Qualified, typename _Unqualified,
1576  bool _IsConst = is_const<_Qualified>::value,
1577  bool _IsVol = is_volatile<_Qualified>::value>
1578  class __match_cv_qualifiers
1579  {
1580  typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1581 
1582  public:
1583  typedef typename __match::__type __type;
1584  };
1585 
1586  // Utility for finding the unsigned versions of signed integral types.
1587  template<typename _Tp>
1588  struct __make_unsigned
1589  { typedef _Tp __type; };
1590 
1591  template<>
1592  struct __make_unsigned<char>
1593  { typedef unsigned char __type; };
1594 
1595  template<>
1596  struct __make_unsigned<signed char>
1597  { typedef unsigned char __type; };
1598 
1599  template<>
1600  struct __make_unsigned<short>
1601  { typedef unsigned short __type; };
1602 
1603  template<>
1604  struct __make_unsigned<int>
1605  { typedef unsigned int __type; };
1606 
1607  template<>
1608  struct __make_unsigned<long>
1609  { typedef unsigned long __type; };
1610 
1611  template<>
1612  struct __make_unsigned<long long>
1613  { typedef unsigned long long __type; };
1614 
1615 #if defined(_GLIBCXX_USE_WCHAR_T) && !defined(__WCHAR_UNSIGNED__)
1616  template<>
1617  struct __make_unsigned<wchar_t> : __make_unsigned<__WCHAR_TYPE__>
1618  { };
1619 #endif
1620 
1621 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1622  template<>
1623  struct __make_unsigned<__int128>
1624  { typedef unsigned __int128 __type; };
1625 #endif
1626 
1627  // Select between integral and enum: not possible to be both.
1628  template<typename _Tp,
1629  bool _IsInt = is_integral<_Tp>::value,
1630  bool _IsEnum = is_enum<_Tp>::value>
1631  class __make_unsigned_selector;
1632 
1633  template<typename _Tp>
1634  class __make_unsigned_selector<_Tp, true, false>
1635  {
1636  typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt;
1637  typedef typename __unsignedt::__type __unsigned_type;
1638  typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1639 
1640  public:
1641  typedef typename __cv_unsigned::__type __type;
1642  };
1643 
1644  template<typename _Tp>
1645  class __make_unsigned_selector<_Tp, false, true>
1646  {
1647  // With -fshort-enums, an enum may be as small as a char.
1648  typedef unsigned char __smallest;
1649  static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1650  static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short);
1651  static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int);
1652  typedef conditional<__b2, unsigned int, unsigned long> __cond2;
1653  typedef typename __cond2::type __cond2_type;
1654  typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
1655  typedef typename __cond1::type __cond1_type;
1656 
1657  public:
1658  typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
1659  };
1660 
1661  // Given an integral/enum type, return the corresponding unsigned
1662  // integer type.
1663  // Primary template.
1664  /// make_unsigned
1665  template<typename _Tp>
1666  struct make_unsigned
1667  { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1668 
1669  // Integral, but don't define.
1670  template<>
1671  struct make_unsigned<bool>;
1672 
1673 
1674  // Utility for finding the signed versions of unsigned integral types.
1675  template<typename _Tp>
1676  struct __make_signed
1677  { typedef _Tp __type; };
1678 
1679  template<>
1680  struct __make_signed<char>
1681  { typedef signed char __type; };
1682 
1683  template<>
1684  struct __make_signed<unsigned char>
1685  { typedef signed char __type; };
1686 
1687  template<>
1688  struct __make_signed<unsigned short>
1689  { typedef signed short __type; };
1690 
1691  template<>
1692  struct __make_signed<unsigned int>
1693  { typedef signed int __type; };
1694 
1695  template<>
1696  struct __make_signed<unsigned long>
1697  { typedef signed long __type; };
1698 
1699  template<>
1700  struct __make_signed<unsigned long long>
1701  { typedef signed long long __type; };
1702 
1703 #if defined(_GLIBCXX_USE_WCHAR_T) && defined(__WCHAR_UNSIGNED__)
1704  template<>
1705  struct __make_signed<wchar_t> : __make_signed<__WCHAR_TYPE__>
1706  { };
1707 #endif
1708 
1709 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
1710  template<>
1711  struct __make_signed<char16_t> : __make_signed<uint_least16_t>
1712  { };
1713  template<>
1714  struct __make_signed<char32_t> : __make_signed<uint_least32_t>
1715  { };
1716 #endif
1717 
1718 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1719  template<>
1720  struct __make_signed<unsigned __int128>
1721  { typedef __int128 __type; };
1722 #endif
1723 
1724  // Select between integral and enum: not possible to be both.
1725  template<typename _Tp,
1726  bool _IsInt = is_integral<_Tp>::value,
1727  bool _IsEnum = is_enum<_Tp>::value>
1728  class __make_signed_selector;
1729 
1730  template<typename _Tp>
1731  class __make_signed_selector<_Tp, true, false>
1732  {
1733  typedef __make_signed<typename remove_cv<_Tp>::type> __signedt;
1734  typedef typename __signedt::__type __signed_type;
1735  typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed;
1736 
1737  public:
1738  typedef typename __cv_signed::__type __type;
1739  };
1740 
1741  template<typename _Tp>
1742  class __make_signed_selector<_Tp, false, true>
1743  {
1744  // With -fshort-enums, an enum may be as small as a char.
1745  typedef signed char __smallest;
1746  static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1747  static const bool __b1 = sizeof(_Tp) <= sizeof(signed short);
1748  static const bool __b2 = sizeof(_Tp) <= sizeof(signed int);
1749  typedef conditional<__b2, signed int, signed long> __cond2;
1750  typedef typename __cond2::type __cond2_type;
1751  typedef conditional<__b1, signed short, __cond2_type> __cond1;
1752  typedef typename __cond1::type __cond1_type;
1753 
1754  public:
1755  typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
1756  };
1757 
1758  // Given an integral/enum type, return the corresponding signed
1759  // integer type.
1760  // Primary template.
1761  /// make_signed
1762  template<typename _Tp>
1763  struct make_signed
1764  { typedef typename __make_signed_selector<_Tp>::__type type; };
1765 
1766  // Integral, but don't define.
1767  template<>
1768  struct make_signed<bool>;
1769 
1770 #if __cplusplus > 201103L
1771  /// Alias template for make_signed
1772  template<typename _Tp>
1773  using make_signed_t = typename make_signed<_Tp>::type;
1774 
1775  /// Alias template for make_unsigned
1776  template<typename _Tp>
1777  using make_unsigned_t = typename make_unsigned<_Tp>::type;
1778 #endif
1779 
1780  // Array modifications.
1781 
1782  /// remove_extent
1783  template<typename _Tp>
1784  struct remove_extent
1785  { typedef _Tp type; };
1786 
1787  template<typename _Tp, std::size_t _Size>
1788  struct remove_extent<_Tp[_Size]>
1789  { typedef _Tp type; };
1790 
1791  template<typename _Tp>
1792  struct remove_extent<_Tp[]>
1793  { typedef _Tp type; };
1794 
1795  /// remove_all_extents
1796  template<typename _Tp>
1797  struct remove_all_extents
1798  { typedef _Tp type; };
1799 
1800  template<typename _Tp, std::size_t _Size>
1801  struct remove_all_extents<_Tp[_Size]>
1802  { typedef typename remove_all_extents<_Tp>::type type; };
1803 
1804  template<typename _Tp>
1805  struct remove_all_extents<_Tp[]>
1806  { typedef typename remove_all_extents<_Tp>::type type; };
1807 
1808 #if __cplusplus > 201103L
1809  /// Alias template for remove_extent
1810  template<typename _Tp>
1811  using remove_extent_t = typename remove_extent<_Tp>::type;
1812 
1813  /// Alias template for remove_all_extents
1814  template<typename _Tp>
1815  using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1816 #endif
1817 
1818  // Pointer modifications.
1819 
1820  template<typename _Tp, typename>
1821  struct __remove_pointer_helper
1822  { typedef _Tp type; };
1823 
1824  template<typename _Tp, typename _Up>
1825  struct __remove_pointer_helper<_Tp, _Up*>
1826  { typedef _Up type; };
1827 
1828  /// remove_pointer
1829  template<typename _Tp>
1830  struct remove_pointer
1831  : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1832  { };
1833 
1834  /// add_pointer
1835  template<typename _Tp, bool = __or_<__is_referenceable<_Tp>,
1836  is_void<_Tp>>::value>
1837  struct __add_pointer_helper
1838  { typedef _Tp type; };
1839 
1840  template<typename _Tp>
1841  struct __add_pointer_helper<_Tp, true>
1842  { typedef typename remove_reference<_Tp>::type* type; };
1843 
1844  template<typename _Tp>
1845  struct add_pointer
1846  : public __add_pointer_helper<_Tp>
1847  { };
1848 
1849 #if __cplusplus > 201103L
1850  /// Alias template for remove_pointer
1851  template<typename _Tp>
1852  using remove_pointer_t = typename remove_pointer<_Tp>::type;
1853 
1854  /// Alias template for add_pointer
1855  template<typename _Tp>
1856  using add_pointer_t = typename add_pointer<_Tp>::type;
1857 #endif
1858 
1859  template<std::size_t _Len>
1860  struct __aligned_storage_msa
1861  {
1862  union __type
1863  {
1864  unsigned char __data[_Len];
1865  struct __attribute__((__aligned__)) { } __align;
1866  };
1867  };
1868 
1869  /**
1870  * @brief Alignment type.
1871  *
1872  * The value of _Align is a default-alignment which shall be the
1873  * most stringent alignment requirement for any C++ object type
1874  * whose size is no greater than _Len (3.9). The member typedef
1875  * type shall be a POD type suitable for use as uninitialized
1876  * storage for any object whose size is at most _Len and whose
1877  * alignment is a divisor of _Align.
1878  */
1879  template<std::size_t _Len, std::size_t _Align =
1880  __alignof__(typename __aligned_storage_msa<_Len>::__type)>
1881  struct aligned_storage
1882  {
1883  union type
1884  {
1885  unsigned char __data[_Len];
1886  struct __attribute__((__aligned__((_Align)))) { } __align;
1887  };
1888  };
1889 
1890 
1891  // Decay trait for arrays and functions, used for perfect forwarding
1892  // in make_pair, make_tuple, etc.
1893  template<typename _Up,
1894  bool _IsArray = is_array<_Up>::value,
1895  bool _IsFunction = is_function<_Up>::value>
1896  struct __decay_selector;
1897 
1898  // NB: DR 705.
1899  template<typename _Up>
1900  struct __decay_selector<_Up, false, false>
1901  { typedef typename remove_cv<_Up>::type __type; };
1902 
1903  template<typename _Up>
1904  struct __decay_selector<_Up, true, false>
1905  { typedef typename remove_extent<_Up>::type* __type; };
1906 
1907  template<typename _Up>
1908  struct __decay_selector<_Up, false, true>
1909  { typedef typename add_pointer<_Up>::type __type; };
1910 
1911  /// decay
1912  template<typename _Tp>
1913  class decay
1914  {
1915  typedef typename remove_reference<_Tp>::type __remove_type;
1916 
1917  public:
1918  typedef typename __decay_selector<__remove_type>::__type type;
1919  };
1920 
1921  template<typename _Tp>
1922  class reference_wrapper;
1923 
1924  // Helper which adds a reference to a type when given a reference_wrapper
1925  template<typename _Tp>
1926  struct __strip_reference_wrapper
1927  {
1928  typedef _Tp __type;
1929  };
1930 
1931  template<typename _Tp>
1932  struct __strip_reference_wrapper<reference_wrapper<_Tp> >
1933  {
1934  typedef _Tp& __type;
1935  };
1936 
1937  template<typename _Tp>
1938  struct __decay_and_strip
1939  {
1940  typedef typename __strip_reference_wrapper<
1941  typename decay<_Tp>::type>::__type __type;
1942  };
1943 
1944 
1945  // Primary template.
1946  /// Define a member typedef @c type only if a boolean constant is true.
1947  template<bool, typename _Tp = void>
1948  struct enable_if
1949  { };
1950 
1951  // Partial specialization for true.
1952  template<typename _Tp>
1953  struct enable_if<true, _Tp>
1954  { typedef _Tp type; };
1955 
1956  template<typename... _Cond>
1957  using _Require = typename enable_if<__and_<_Cond...>::value>::type;
1958 
1959  // Primary template.
1960  /// Define a member typedef @c type to one of two argument types.
1961  template<bool _Cond, typename _Iftrue, typename _Iffalse>
1962  struct conditional
1963  { typedef _Iftrue type; };
1964 
1965  // Partial specialization for false.
1966  template<typename _Iftrue, typename _Iffalse>
1967  struct conditional<false, _Iftrue, _Iffalse>
1968  { typedef _Iffalse type; };
1969 
1970  /// common_type
1971  template<typename... _Tp>
1972  struct common_type;
1973 
1974  // Sfinae-friendly common_type implementation:
1975 
1976  struct __do_common_type_impl
1977  {
1978  template<typename _Tp, typename _Up>
1979  static __success_type<typename decay<decltype
1980  (true ? std::declval<_Tp>()
1981  : std::declval<_Up>())>::type> _S_test(int);
1982 
1983  template<typename, typename>
1984  static __failure_type _S_test(...);
1985  };
1986 
1987  template<typename _Tp, typename _Up>
1988  struct __common_type_impl
1989  : private __do_common_type_impl
1990  {
1991  typedef decltype(_S_test<_Tp, _Up>(0)) type;
1992  };
1993 
1994  struct __do_member_type_wrapper
1995  {
1996  template<typename _Tp>
1997  static __success_type<typename _Tp::type> _S_test(int);
1998 
1999  template<typename>
2000  static __failure_type _S_test(...);
2001  };
2002 
2003  template<typename _Tp>
2004  struct __member_type_wrapper
2005  : private __do_member_type_wrapper
2006  {
2007  typedef decltype(_S_test<_Tp>(0)) type;
2008  };
2009 
2010  template<typename _CTp, typename... _Args>
2011  struct __expanded_common_type_wrapper
2012  {
2013  typedef common_type<typename _CTp::type, _Args...> type;
2014  };
2015 
2016  template<typename... _Args>
2017  struct __expanded_common_type_wrapper<__failure_type, _Args...>
2018  { typedef __failure_type type; };
2019 
2020  template<typename _Tp>
2021  struct common_type<_Tp>
2022  { typedef typename decay<_Tp>::type type; };
2023 
2024  template<typename _Tp, typename _Up>
2025  struct common_type<_Tp, _Up>
2026  : public __common_type_impl<_Tp, _Up>::type
2027  { };
2028 
2029  template<typename _Tp, typename _Up, typename... _Vp>
2030  struct common_type<_Tp, _Up, _Vp...>
2031  : public __expanded_common_type_wrapper<typename __member_type_wrapper<
2032  common_type<_Tp, _Up>>::type, _Vp...>::type
2033  { };
2034 
2035  /// The underlying type of an enum.
2036  template<typename _Tp>
2037  struct underlying_type
2038  {
2039  typedef __underlying_type(_Tp) type;
2040  };
2041 
2042  template<typename _Tp>
2043  struct __declval_protector
2044  {
2045  static const bool __stop = false;
2046  static typename add_rvalue_reference<_Tp>::type __delegate();
2047  };
2048 
2049  template<typename _Tp>
2050  inline typename add_rvalue_reference<_Tp>::type
2051  declval() noexcept
2052  {
2053  static_assert(__declval_protector<_Tp>::__stop,
2054  "declval() must not be used!");
2055  return __declval_protector<_Tp>::__delegate();
2056  }
2057 
2058  /// result_of
2059  template<typename _Signature>
2060  class result_of;
2061 
2062  // Sfinae-friendly result_of implementation:
2063 
2064 #define __cpp_lib_result_of_sfinae 201210
2065 
2066  // [func.require] paragraph 1 bullet 1:
2067  struct __result_of_memfun_ref_impl
2068  {
2069  template<typename _Fp, typename _Tp1, typename... _Args>
2070  static __success_type<decltype(
2071  (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
2072  )> _S_test(int);
2073 
2074  template<typename...>
2075  static __failure_type _S_test(...);
2076  };
2077 
2078  template<typename _MemPtr, typename _Arg, typename... _Args>
2079  struct __result_of_memfun_ref
2080  : private __result_of_memfun_ref_impl
2081  {
2082  typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2083  };
2084 
2085  // [func.require] paragraph 1 bullet 2:
2086  struct __result_of_memfun_deref_impl
2087  {
2088  template<typename _Fp, typename _Tp1, typename... _Args>
2089  static __success_type<decltype(
2090  ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
2091  )> _S_test(int);
2092 
2093  template<typename...>
2094  static __failure_type _S_test(...);
2095  };
2096 
2097  template<typename _MemPtr, typename _Arg, typename... _Args>
2098  struct __result_of_memfun_deref
2099  : private __result_of_memfun_deref_impl
2100  {
2101  typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2102  };
2103 
2104  // [func.require] paragraph 1 bullet 3:
2105  struct __result_of_memobj_ref_impl
2106  {
2107  template<typename _Fp, typename _Tp1>
2108  static __success_type<decltype(
2109  std::declval<_Tp1>().*std::declval<_Fp>()
2110  )> _S_test(int);
2111 
2112  template<typename, typename>
2113  static __failure_type _S_test(...);
2114  };
2115 
2116  template<typename _MemPtr, typename _Arg>
2117  struct __result_of_memobj_ref
2118  : private __result_of_memobj_ref_impl
2119  {
2120  typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2121  };
2122 
2123  // [func.require] paragraph 1 bullet 4:
2124  struct __result_of_memobj_deref_impl
2125  {
2126  template<typename _Fp, typename _Tp1>
2127  static __success_type<decltype(
2128  (*std::declval<_Tp1>()).*std::declval<_Fp>()
2129  )> _S_test(int);
2130 
2131  template<typename, typename>
2132  static __failure_type _S_test(...);
2133  };
2134 
2135  template<typename _MemPtr, typename _Arg>
2136  struct __result_of_memobj_deref
2137  : private __result_of_memobj_deref_impl
2138  {
2139  typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2140  };
2141 
2142  template<typename _MemPtr, typename _Arg>
2143  struct __result_of_memobj;
2144 
2145  template<typename _Res, typename _Class, typename _Arg>
2146  struct __result_of_memobj<_Res _Class::*, _Arg>
2147  {
2148  typedef typename remove_cv<typename remove_reference<
2149  _Arg>::type>::type _Argval;
2150  typedef _Res _Class::* _MemPtr;
2151  typedef typename conditional<__or_<is_same<_Argval, _Class>,
2152  is_base_of<_Class, _Argval>>::value,
2153  __result_of_memobj_ref<_MemPtr, _Arg>,
2154  __result_of_memobj_deref<_MemPtr, _Arg>
2155  >::type::type type;
2156  };
2157 
2158  template<typename _MemPtr, typename _Arg, typename... _Args>
2159  struct __result_of_memfun;
2160 
2161  template<typename _Res, typename _Class, typename _Arg, typename... _Args>
2162  struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
2163  {
2164  typedef typename remove_cv<typename remove_reference<
2165  _Arg>::type>::type _Argval;
2166  typedef _Res _Class::* _MemPtr;
2167  typedef typename conditional<__or_<is_same<_Argval, _Class>,
2168  is_base_of<_Class, _Argval>>::value,
2169  __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
2170  __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
2171  >::type::type type;
2172  };
2173 
2174  template<bool, bool, typename _Functor, typename... _ArgTypes>
2175  struct __result_of_impl
2176  {
2177  typedef __failure_type type;
2178  };
2179 
2180  template<typename _MemPtr, typename _Arg>
2181  struct __result_of_impl<true, false, _MemPtr, _Arg>
2182  : public __result_of_memobj<typename decay<_MemPtr>::type, _Arg>
2183  { };
2184 
2185  template<typename _MemPtr, typename _Arg, typename... _Args>
2186  struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
2187  : public __result_of_memfun<typename decay<_MemPtr>::type, _Arg, _Args...>
2188  { };
2189 
2190  // [func.require] paragraph 1 bullet 5:
2191  struct __result_of_other_impl
2192  {
2193  template<typename _Fn, typename... _Args>
2194  static __success_type<decltype(
2195  std::declval<_Fn>()(std::declval<_Args>()...)
2196  )> _S_test(int);
2197 
2198  template<typename...>
2199  static __failure_type _S_test(...);
2200  };
2201 
2202  template<typename _Functor, typename... _ArgTypes>
2203  struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2204  : private __result_of_other_impl
2205  {
2206  typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
2207  };
2208 
2209  template<typename _Functor, typename... _ArgTypes>
2210  struct result_of<_Functor(_ArgTypes...)>
2211  : public __result_of_impl<
2212  is_member_object_pointer<
2213  typename remove_reference<_Functor>::type
2214  >::value,
2215  is_member_function_pointer<
2216  typename remove_reference<_Functor>::type
2217  >::value,
2218  _Functor, _ArgTypes...
2219  >::type
2220  { };
2221 
2222 #if __cplusplus > 201103L
2223  /// Alias template for aligned_storage
2224  template<size_t _Len, size_t _Align =
2225  __alignof__(typename __aligned_storage_msa<_Len>::__type)>
2226  using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
2227 
2228  /// Alias template for decay
2229  template<typename _Tp>
2230  using decay_t = typename decay<_Tp>::type;
2231 
2232  /// Alias template for enable_if
2233  template<bool _Cond, typename _Tp = void>
2234  using enable_if_t = typename enable_if<_Cond, _Tp>::type;
2235 
2236  /// Alias template for conditional
2237  template<bool _Cond, typename _Iftrue, typename _Iffalse>
2238  using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
2239 
2240  /// Alias template for common_type
2241  template<typename... _Tp>
2242  using common_type_t = typename common_type<_Tp...>::type;
2243 
2244  /// Alias template for underlying_type
2245  template<typename _Tp>
2246  using underlying_type_t = typename underlying_type<_Tp>::type;
2247 
2248  /// Alias template for result_of
2249  template<typename _Tp>
2250  using result_of_t = typename result_of<_Tp>::type;
2251 #endif
2252 
2253  /// @} group metaprogramming
2254 
2255  /**
2256  * Use SFINAE to determine if the type _Tp has a publicly-accessible
2257  * member type _NTYPE.
2258  */
2259 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2260  template<typename _Tp> \
2261  class __has_##_NTYPE##_helper \
2262  { \
2263  template<typename _Up> \
2264  struct _Wrap_type \
2265  { }; \
2266  \
2267  template<typename _Up> \
2268  static true_type __test(_Wrap_type<typename _Up::_NTYPE>*); \
2269  \
2270  template<typename _Up> \
2271  static false_type __test(...); \
2272  \
2273  public: \
2274  typedef decltype(__test<_Tp>(0)) type; \
2275  }; \
2276  \
2277  template<typename _Tp> \
2278  struct __has_##_NTYPE \
2279  : public __has_##_NTYPE##_helper \
2280  <typename remove_cv<_Tp>::type>::type \
2281  { };
2282 
2283 _GLIBCXX_END_NAMESPACE_VERSION
2284 } // namespace std
2285 
2286 #endif // C++11
2287 
2288 #endif // _GLIBCXX_TYPE_TRAITS