libstdc++
type_traits
Go to the documentation of this file.
1 // C++11 <type_traits> -*- C++ -*-
2 
3 // Copyright (C) 2007-2017 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 noexcept { return value; }
75 #if __cplusplus > 201103L
76 
77 #define __cpp_lib_integral_constant_callable 201304
78 
79  constexpr value_type operator()() const noexcept { 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  template<bool __v>
93  using __bool_constant = integral_constant<bool, __v>;
94 
95 #if __cplusplus > 201402L
96 # define __cpp_lib_bool_constant 201505
97  template<bool __v>
98  using bool_constant = integral_constant<bool, __v>;
99 #endif
100 
101  // Meta programming helper types.
102 
103  template<bool, typename, typename>
104  struct conditional;
105 
106  template<typename...>
107  struct __or_;
108 
109  template<>
110  struct __or_<>
111  : public false_type
112  { };
113 
114  template<typename _B1>
115  struct __or_<_B1>
116  : public _B1
117  { };
118 
119  template<typename _B1, typename _B2>
120  struct __or_<_B1, _B2>
121  : public conditional<_B1::value, _B1, _B2>::type
122  { };
123 
124  template<typename _B1, typename _B2, typename _B3, typename... _Bn>
125  struct __or_<_B1, _B2, _B3, _Bn...>
126  : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
127  { };
128 
129  template<typename...>
130  struct __and_;
131 
132  template<>
133  struct __and_<>
134  : public true_type
135  { };
136 
137  template<typename _B1>
138  struct __and_<_B1>
139  : public _B1
140  { };
141 
142  template<typename _B1, typename _B2>
143  struct __and_<_B1, _B2>
144  : public conditional<_B1::value, _B2, _B1>::type
145  { };
146 
147  template<typename _B1, typename _B2, typename _B3, typename... _Bn>
148  struct __and_<_B1, _B2, _B3, _Bn...>
149  : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
150  { };
151 
152  template<typename _Pp>
153  struct __not_
154  : public __bool_constant<!bool(_Pp::value)>
155  { };
156 
157 #if __cplusplus >= 201703L
158 
159 #define __cpp_lib_logical_traits 201510
160 
161  template<typename... _Bn>
162  struct conjunction
163  : __and_<_Bn...>
164  { };
165 
166  template<typename... _Bn>
167  struct disjunction
168  : __or_<_Bn...>
169  { };
170 
171  template<typename _Pp>
172  struct negation
173  : __not_<_Pp>
174  { };
175 
176  template<typename... _Bn>
177  inline constexpr bool conjunction_v = conjunction<_Bn...>::value;
178 
179  template<typename... _Bn>
180  inline constexpr bool disjunction_v = disjunction<_Bn...>::value;
181 
182  template<typename _Pp>
183  inline constexpr bool negation_v = negation<_Pp>::value;
184 
185 #endif // C++17
186 
187  // For several sfinae-friendly trait implementations we transport both the
188  // result information (as the member type) and the failure information (no
189  // member type). This is very similar to std::enable_if, but we cannot use
190  // them, because we need to derive from them as an implementation detail.
191 
192  template<typename _Tp>
193  struct __success_type
194  { typedef _Tp type; };
195 
196  struct __failure_type
197  { };
198 
199  // Primary type categories.
200 
201  template<typename>
202  struct remove_cv;
203 
204  template<typename>
205  struct __is_void_helper
206  : public false_type { };
207 
208  template<>
209  struct __is_void_helper<void>
210  : public true_type { };
211 
212  /// is_void
213  template<typename _Tp>
214  struct is_void
215  : public __is_void_helper<typename remove_cv<_Tp>::type>::type
216  { };
217 
218  template<typename>
219  struct __is_integral_helper
220  : public false_type { };
221 
222  template<>
223  struct __is_integral_helper<bool>
224  : public true_type { };
225 
226  template<>
227  struct __is_integral_helper<char>
228  : public true_type { };
229 
230  template<>
231  struct __is_integral_helper<signed char>
232  : public true_type { };
233 
234  template<>
235  struct __is_integral_helper<unsigned char>
236  : public true_type { };
237 
238 #ifdef _GLIBCXX_USE_WCHAR_T
239  template<>
240  struct __is_integral_helper<wchar_t>
241  : public true_type { };
242 #endif
243 
244  template<>
245  struct __is_integral_helper<char16_t>
246  : public true_type { };
247 
248  template<>
249  struct __is_integral_helper<char32_t>
250  : public true_type { };
251 
252  template<>
253  struct __is_integral_helper<short>
254  : public true_type { };
255 
256  template<>
257  struct __is_integral_helper<unsigned short>
258  : public true_type { };
259 
260  template<>
261  struct __is_integral_helper<int>
262  : public true_type { };
263 
264  template<>
265  struct __is_integral_helper<unsigned int>
266  : public true_type { };
267 
268  template<>
269  struct __is_integral_helper<long>
270  : public true_type { };
271 
272  template<>
273  struct __is_integral_helper<unsigned long>
274  : public true_type { };
275 
276  template<>
277  struct __is_integral_helper<long long>
278  : public true_type { };
279 
280  template<>
281  struct __is_integral_helper<unsigned long long>
282  : public true_type { };
283 
284  // Conditionalizing on __STRICT_ANSI__ here will break any port that
285  // uses one of these types for size_t.
286 #if defined(__GLIBCXX_TYPE_INT_N_0)
287  template<>
288  struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
289  : public true_type { };
290 
291  template<>
292  struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
293  : public true_type { };
294 #endif
295 #if defined(__GLIBCXX_TYPE_INT_N_1)
296  template<>
297  struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
298  : public true_type { };
299 
300  template<>
301  struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
302  : public true_type { };
303 #endif
304 #if defined(__GLIBCXX_TYPE_INT_N_2)
305  template<>
306  struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
307  : public true_type { };
308 
309  template<>
310  struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
311  : public true_type { };
312 #endif
313 #if defined(__GLIBCXX_TYPE_INT_N_3)
314  template<>
315  struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
316  : public true_type { };
317 
318  template<>
319  struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
320  : public true_type { };
321 #endif
322 
323  /// is_integral
324  template<typename _Tp>
325  struct is_integral
326  : public __is_integral_helper<typename remove_cv<_Tp>::type>::type
327  { };
328 
329  template<typename>
330  struct __is_floating_point_helper
331  : public false_type { };
332 
333  template<>
334  struct __is_floating_point_helper<float>
335  : public true_type { };
336 
337  template<>
338  struct __is_floating_point_helper<double>
339  : public true_type { };
340 
341  template<>
342  struct __is_floating_point_helper<long double>
343  : public true_type { };
344 
345 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__)
346  template<>
347  struct __is_floating_point_helper<__float128>
348  : public true_type { };
349 #endif
350 
351  /// is_floating_point
352  template<typename _Tp>
353  struct is_floating_point
354  : public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type
355  { };
356 
357  /// is_array
358  template<typename>
359  struct is_array
360  : public false_type { };
361 
362  template<typename _Tp, std::size_t _Size>
363  struct is_array<_Tp[_Size]>
364  : public true_type { };
365 
366  template<typename _Tp>
367  struct is_array<_Tp[]>
368  : public true_type { };
369 
370  template<typename>
371  struct __is_pointer_helper
372  : public false_type { };
373 
374  template<typename _Tp>
375  struct __is_pointer_helper<_Tp*>
376  : public true_type { };
377 
378  /// is_pointer
379  template<typename _Tp>
380  struct is_pointer
381  : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type
382  { };
383 
384  /// is_lvalue_reference
385  template<typename>
386  struct is_lvalue_reference
387  : public false_type { };
388 
389  template<typename _Tp>
390  struct is_lvalue_reference<_Tp&>
391  : public true_type { };
392 
393  /// is_rvalue_reference
394  template<typename>
395  struct is_rvalue_reference
396  : public false_type { };
397 
398  template<typename _Tp>
399  struct is_rvalue_reference<_Tp&&>
400  : public true_type { };
401 
402  template<typename>
403  struct is_function;
404 
405  template<typename>
406  struct __is_member_object_pointer_helper
407  : public false_type { };
408 
409  template<typename _Tp, typename _Cp>
410  struct __is_member_object_pointer_helper<_Tp _Cp::*>
411  : public integral_constant<bool, !is_function<_Tp>::value> { };
412 
413  /// is_member_object_pointer
414  template<typename _Tp>
415  struct is_member_object_pointer
416  : public __is_member_object_pointer_helper<
417  typename remove_cv<_Tp>::type>::type
418  { };
419 
420  template<typename>
421  struct __is_member_function_pointer_helper
422  : public false_type { };
423 
424  template<typename _Tp, typename _Cp>
425  struct __is_member_function_pointer_helper<_Tp _Cp::*>
426  : public integral_constant<bool, is_function<_Tp>::value> { };
427 
428  /// is_member_function_pointer
429  template<typename _Tp>
430  struct is_member_function_pointer
431  : public __is_member_function_pointer_helper<
432  typename remove_cv<_Tp>::type>::type
433  { };
434 
435  /// is_enum
436  template<typename _Tp>
437  struct is_enum
438  : public integral_constant<bool, __is_enum(_Tp)>
439  { };
440 
441  /// is_union
442  template<typename _Tp>
443  struct is_union
444  : public integral_constant<bool, __is_union(_Tp)>
445  { };
446 
447  /// is_class
448  template<typename _Tp>
449  struct is_class
450  : public integral_constant<bool, __is_class(_Tp)>
451  { };
452 
453  /// is_function
454  template<typename>
455  struct is_function
456  : public false_type { };
457 
458  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
459  struct is_function<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL>
460  : public true_type { };
461 
462  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
463  struct is_function<_Res(_ArgTypes...) & _GLIBCXX_NOEXCEPT_QUAL>
464  : public true_type { };
465 
466  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
467  struct is_function<_Res(_ArgTypes...) && _GLIBCXX_NOEXCEPT_QUAL>
468  : public true_type { };
469 
470  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
471  struct is_function<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL>
472  : public true_type { };
473 
474  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
475  struct is_function<_Res(_ArgTypes......) & _GLIBCXX_NOEXCEPT_QUAL>
476  : public true_type { };
477 
478  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
479  struct is_function<_Res(_ArgTypes......) && _GLIBCXX_NOEXCEPT_QUAL>
480  : public true_type { };
481 
482  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
483  struct is_function<_Res(_ArgTypes...) const _GLIBCXX_NOEXCEPT_QUAL>
484  : public true_type { };
485 
486  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
487  struct is_function<_Res(_ArgTypes...) const & _GLIBCXX_NOEXCEPT_QUAL>
488  : public true_type { };
489 
490  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
491  struct is_function<_Res(_ArgTypes...) const && _GLIBCXX_NOEXCEPT_QUAL>
492  : public true_type { };
493 
494  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
495  struct is_function<_Res(_ArgTypes......) const _GLIBCXX_NOEXCEPT_QUAL>
496  : public true_type { };
497 
498  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
499  struct is_function<_Res(_ArgTypes......) const & _GLIBCXX_NOEXCEPT_QUAL>
500  : public true_type { };
501 
502  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
503  struct is_function<_Res(_ArgTypes......) const && _GLIBCXX_NOEXCEPT_QUAL>
504  : public true_type { };
505 
506  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
507  struct is_function<_Res(_ArgTypes...) volatile _GLIBCXX_NOEXCEPT_QUAL>
508  : public true_type { };
509 
510  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
511  struct is_function<_Res(_ArgTypes...) volatile & _GLIBCXX_NOEXCEPT_QUAL>
512  : public true_type { };
513 
514  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
515  struct is_function<_Res(_ArgTypes...) volatile && _GLIBCXX_NOEXCEPT_QUAL>
516  : public true_type { };
517 
518  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
519  struct is_function<_Res(_ArgTypes......) volatile _GLIBCXX_NOEXCEPT_QUAL>
520  : public true_type { };
521 
522  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
523  struct is_function<_Res(_ArgTypes......) volatile & _GLIBCXX_NOEXCEPT_QUAL>
524  : public true_type { };
525 
526  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
527  struct is_function<_Res(_ArgTypes......) volatile && _GLIBCXX_NOEXCEPT_QUAL>
528  : public true_type { };
529 
530  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
531  struct is_function<_Res(_ArgTypes...) const volatile _GLIBCXX_NOEXCEPT_QUAL>
532  : public true_type { };
533 
534  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
535  struct is_function<_Res(_ArgTypes...) const volatile & _GLIBCXX_NOEXCEPT_QUAL>
536  : public true_type { };
537 
538  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
539  struct is_function<_Res(_ArgTypes...) const volatile && _GLIBCXX_NOEXCEPT_QUAL>
540  : public true_type { };
541 
542  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
543  struct is_function<_Res(_ArgTypes......) const volatile _GLIBCXX_NOEXCEPT_QUAL>
544  : public true_type { };
545 
546  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
547  struct is_function<_Res(_ArgTypes......) const volatile & _GLIBCXX_NOEXCEPT_QUAL>
548  : public true_type { };
549 
550  template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
551  struct is_function<_Res(_ArgTypes......) const volatile && _GLIBCXX_NOEXCEPT_QUAL>
552  : public true_type { };
553 
554 #define __cpp_lib_is_null_pointer 201309
555 
556  template<typename>
557  struct __is_null_pointer_helper
558  : public false_type { };
559 
560  template<>
561  struct __is_null_pointer_helper<std::nullptr_t>
562  : public true_type { };
563 
564  /// is_null_pointer (LWG 2247).
565  template<typename _Tp>
566  struct is_null_pointer
567  : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type
568  { };
569 
570  /// __is_nullptr_t (extension).
571  template<typename _Tp>
572  struct __is_nullptr_t
573  : public is_null_pointer<_Tp>
574  { };
575 
576  // Composite type categories.
577 
578  /// is_reference
579  template<typename _Tp>
580  struct is_reference
581  : public __or_<is_lvalue_reference<_Tp>,
582  is_rvalue_reference<_Tp>>::type
583  { };
584 
585  /// is_arithmetic
586  template<typename _Tp>
587  struct is_arithmetic
588  : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
589  { };
590 
591  /// is_fundamental
592  template<typename _Tp>
593  struct is_fundamental
594  : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
595  is_null_pointer<_Tp>>::type
596  { };
597 
598  /// is_object
599  template<typename _Tp>
600  struct is_object
601  : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
602  is_void<_Tp>>>::type
603  { };
604 
605  template<typename>
606  struct is_member_pointer;
607 
608  /// is_scalar
609  template<typename _Tp>
610  struct is_scalar
611  : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
612  is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
613  { };
614 
615  /// is_compound
616  template<typename _Tp>
617  struct is_compound
618  : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
619 
620  template<typename _Tp>
621  struct __is_member_pointer_helper
622  : public false_type { };
623 
624  template<typename _Tp, typename _Cp>
625  struct __is_member_pointer_helper<_Tp _Cp::*>
626  : public true_type { };
627 
628  /// is_member_pointer
629  template<typename _Tp>
630  struct is_member_pointer
631  : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type
632  { };
633 
634  // Utility to detect referenceable types ([defns.referenceable]).
635 
636  template<typename _Tp>
637  struct __is_referenceable
638  : public __or_<is_object<_Tp>, is_reference<_Tp>>::type
639  { };
640 
641  template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
642  struct __is_referenceable<_Res(_Args...) _GLIBCXX_NOEXCEPT_QUAL>
643  : public true_type
644  { };
645 
646  template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
647  struct __is_referenceable<_Res(_Args......) _GLIBCXX_NOEXCEPT_QUAL>
648  : public true_type
649  { };
650 
651  // Type properties.
652 
653  /// is_const
654  template<typename>
655  struct is_const
656  : public false_type { };
657 
658  template<typename _Tp>
659  struct is_const<_Tp const>
660  : public true_type { };
661 
662  /// is_volatile
663  template<typename>
664  struct is_volatile
665  : public false_type { };
666 
667  template<typename _Tp>
668  struct is_volatile<_Tp volatile>
669  : public true_type { };
670 
671  /// is_trivial
672  template<typename _Tp>
673  struct is_trivial
674  : public integral_constant<bool, __is_trivial(_Tp)>
675  { };
676 
677  // is_trivially_copyable
678  template<typename _Tp>
679  struct is_trivially_copyable
680  : public integral_constant<bool, __is_trivially_copyable(_Tp)>
681  { };
682 
683  /// is_standard_layout
684  template<typename _Tp>
685  struct is_standard_layout
686  : public integral_constant<bool, __is_standard_layout(_Tp)>
687  { };
688 
689  /// is_pod
690  // Could use is_standard_layout && is_trivial instead of the builtin.
691  template<typename _Tp>
692  struct is_pod
693  : public integral_constant<bool, __is_pod(_Tp)>
694  { };
695 
696  /// is_literal_type
697  template<typename _Tp>
698  struct is_literal_type
699  : public integral_constant<bool, __is_literal_type(_Tp)>
700  { };
701 
702  /// is_empty
703  template<typename _Tp>
704  struct is_empty
705  : public integral_constant<bool, __is_empty(_Tp)>
706  { };
707 
708  /// is_polymorphic
709  template<typename _Tp>
710  struct is_polymorphic
711  : public integral_constant<bool, __is_polymorphic(_Tp)>
712  { };
713 
714 #if __cplusplus >= 201402L
715 #define __cpp_lib_is_final 201402L
716  /// is_final
717  template<typename _Tp>
718  struct is_final
719  : public integral_constant<bool, __is_final(_Tp)>
720  { };
721 #endif
722 
723  /// is_abstract
724  template<typename _Tp>
725  struct is_abstract
726  : public integral_constant<bool, __is_abstract(_Tp)>
727  { };
728 
729  template<typename _Tp,
730  bool = is_arithmetic<_Tp>::value>
731  struct __is_signed_helper
732  : public false_type { };
733 
734  template<typename _Tp>
735  struct __is_signed_helper<_Tp, true>
736  : public integral_constant<bool, _Tp(-1) < _Tp(0)>
737  { };
738 
739  /// is_signed
740  template<typename _Tp>
741  struct is_signed
742  : public __is_signed_helper<_Tp>::type
743  { };
744 
745  /// is_unsigned
746  template<typename _Tp>
747  struct is_unsigned
748  : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>
749  { };
750 
751 
752  // Destructible and constructible type properties.
753 
754  template<typename>
755  struct add_rvalue_reference;
756 
757  /**
758  * @brief Utility to simplify expressions used in unevaluated operands
759  * @ingroup utilities
760  */
761  template<typename _Tp>
762  typename add_rvalue_reference<_Tp>::type declval() noexcept;
763 
764  template<typename, unsigned = 0>
765  struct extent;
766 
767  template<typename>
768  struct remove_all_extents;
769 
770  template<typename _Tp>
771  struct __is_array_known_bounds
772  : public integral_constant<bool, (extent<_Tp>::value > 0)>
773  { };
774 
775  template<typename _Tp>
776  struct __is_array_unknown_bounds
777  : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>
778  { };
779 
780  // In N3290 is_destructible does not say anything about function
781  // types and abstract types, see LWG 2049. This implementation
782  // describes function types as non-destructible and all complete
783  // object types as destructible, iff the explicit destructor
784  // call expression is wellformed.
785  struct __do_is_destructible_impl
786  {
787  template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
788  static true_type __test(int);
789 
790  template<typename>
791  static false_type __test(...);
792  };
793 
794  template<typename _Tp>
795  struct __is_destructible_impl
796  : public __do_is_destructible_impl
797  {
798  typedef decltype(__test<_Tp>(0)) type;
799  };
800 
801  template<typename _Tp,
802  bool = __or_<is_void<_Tp>,
803  __is_array_unknown_bounds<_Tp>,
804  is_function<_Tp>>::value,
805  bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
806  struct __is_destructible_safe;
807 
808  template<typename _Tp>
809  struct __is_destructible_safe<_Tp, false, false>
810  : public __is_destructible_impl<typename
811  remove_all_extents<_Tp>::type>::type
812  { };
813 
814  template<typename _Tp>
815  struct __is_destructible_safe<_Tp, true, false>
816  : public false_type { };
817 
818  template<typename _Tp>
819  struct __is_destructible_safe<_Tp, false, true>
820  : public true_type { };
821 
822  /// is_destructible
823  template<typename _Tp>
824  struct is_destructible
825  : public __is_destructible_safe<_Tp>::type
826  { };
827 
828  // is_nothrow_destructible requires that is_destructible is
829  // satisfied as well. We realize that by mimicing the
830  // implementation of is_destructible but refer to noexcept(expr)
831  // instead of decltype(expr).
832  struct __do_is_nt_destructible_impl
833  {
834  template<typename _Tp>
835  static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
836  __test(int);
837 
838  template<typename>
839  static false_type __test(...);
840  };
841 
842  template<typename _Tp>
843  struct __is_nt_destructible_impl
844  : public __do_is_nt_destructible_impl
845  {
846  typedef decltype(__test<_Tp>(0)) type;
847  };
848 
849  template<typename _Tp,
850  bool = __or_<is_void<_Tp>,
851  __is_array_unknown_bounds<_Tp>,
852  is_function<_Tp>>::value,
853  bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
854  struct __is_nt_destructible_safe;
855 
856  template<typename _Tp>
857  struct __is_nt_destructible_safe<_Tp, false, false>
858  : public __is_nt_destructible_impl<typename
859  remove_all_extents<_Tp>::type>::type
860  { };
861 
862  template<typename _Tp>
863  struct __is_nt_destructible_safe<_Tp, true, false>
864  : public false_type { };
865 
866  template<typename _Tp>
867  struct __is_nt_destructible_safe<_Tp, false, true>
868  : public true_type { };
869 
870  /// is_nothrow_destructible
871  template<typename _Tp>
872  struct is_nothrow_destructible
873  : public __is_nt_destructible_safe<_Tp>::type
874  { };
875 
876  struct __do_is_default_constructible_impl
877  {
878  template<typename _Tp, typename = decltype(_Tp())>
879  static true_type __test(int);
880 
881  template<typename>
882  static false_type __test(...);
883  };
884 
885  template<typename _Tp>
886  struct __is_default_constructible_impl
887  : public __do_is_default_constructible_impl
888  {
889  typedef decltype(__test<_Tp>(0)) type;
890  };
891 
892  template<typename _Tp>
893  struct __is_default_constructible_atom
894  : public __and_<__not_<is_void<_Tp>>,
895  __is_default_constructible_impl<_Tp>>
896  { };
897 
898  template<typename _Tp, bool = is_array<_Tp>::value>
899  struct __is_default_constructible_safe;
900 
901  // The following technique is a workaround for a current core language
902  // restriction, which does not allow for array types to occur in
903  // functional casts of the form T(). Complete arrays can be default-
904  // constructed, if the element type is default-constructible, but
905  // arrays with unknown bounds are not.
906  template<typename _Tp>
907  struct __is_default_constructible_safe<_Tp, true>
908  : public __and_<__is_array_known_bounds<_Tp>,
909  __is_default_constructible_atom<typename
910  remove_all_extents<_Tp>::type>>
911  { };
912 
913  template<typename _Tp>
914  struct __is_default_constructible_safe<_Tp, false>
915  : public __is_default_constructible_atom<_Tp>::type
916  { };
917 
918  /// is_default_constructible
919  template<typename _Tp>
920  struct is_default_constructible
921  : public __is_default_constructible_safe<_Tp>::type
922  { };
923 
924 
925  // Implementation of is_constructible.
926 
927  // The hardest part of this trait is the binary direct-initialization
928  // case, because we hit into a functional cast of the form T(arg).
929  // This implementation uses different strategies depending on the
930  // target type to reduce the test overhead as much as possible:
931  //
932  // a) For a reference target type, we use a static_cast expression
933  // modulo its extra cases.
934  //
935  // b) For a non-reference target type we use a ::new expression.
936  struct __do_is_static_castable_impl
937  {
938  template<typename _From, typename _To, typename
939  = decltype(static_cast<_To>(declval<_From>()))>
940  static true_type __test(int);
941 
942  template<typename, typename>
943  static false_type __test(...);
944  };
945 
946  template<typename _From, typename _To>
947  struct __is_static_castable_impl
948  : public __do_is_static_castable_impl
949  {
950  typedef decltype(__test<_From, _To>(0)) type;
951  };
952 
953  template<typename _From, typename _To>
954  struct __is_static_castable_safe
955  : public __is_static_castable_impl<_From, _To>::type
956  { };
957 
958  // __is_static_castable
959  template<typename _From, typename _To>
960  struct __is_static_castable
961  : public integral_constant<bool, (__is_static_castable_safe<
962  _From, _To>::value)>
963  { };
964 
965  // Implementation for non-reference types. To meet the proper
966  // variable definition semantics, we also need to test for
967  // is_destructible in this case.
968  // This form should be simplified by a single expression:
969  // ::delete ::new _Tp(declval<_Arg>()), see c++/51222.
970  struct __do_is_direct_constructible_impl
971  {
972  template<typename _Tp, typename _Arg, typename
973  = decltype(::new _Tp(declval<_Arg>()))>
974  static true_type __test(int);
975 
976  template<typename, typename>
977  static false_type __test(...);
978  };
979 
980  template<typename _Tp, typename _Arg>
981  struct __is_direct_constructible_impl
982  : public __do_is_direct_constructible_impl
983  {
984  typedef decltype(__test<_Tp, _Arg>(0)) type;
985  };
986 
987  template<typename _Tp, typename _Arg>
988  struct __is_direct_constructible_new_safe
989  : public __and_<is_destructible<_Tp>,
990  __is_direct_constructible_impl<_Tp, _Arg>>
991  { };
992 
993  template<typename, typename>
994  struct is_same;
995 
996  template<typename, typename>
997  struct is_base_of;
998 
999  template<typename>
1000  struct remove_reference;
1001 
1002  template<typename _From, typename _To, bool
1003  = __not_<__or_<is_void<_From>,
1004  is_function<_From>>>::value>
1005  struct __is_base_to_derived_ref;
1006 
1007  template<typename _Tp, typename... _Args>
1008  struct is_constructible;
1009 
1010  // Detect whether we have a downcast situation during
1011  // reference binding.
1012  template<typename _From, typename _To>
1013  struct __is_base_to_derived_ref<_From, _To, true>
1014  {
1015  typedef typename remove_cv<typename remove_reference<_From
1016  >::type>::type __src_t;
1017  typedef typename remove_cv<typename remove_reference<_To
1018  >::type>::type __dst_t;
1019  typedef __and_<__not_<is_same<__src_t, __dst_t>>,
1020  is_base_of<__src_t, __dst_t>,
1021  __not_<is_constructible<__dst_t, _From>>> type;
1022  static constexpr bool value = type::value;
1023  };
1024 
1025  template<typename _From, typename _To>
1026  struct __is_base_to_derived_ref<_From, _To, false>
1027  : public false_type
1028  { };
1029 
1030  template<typename _From, typename _To, bool
1031  = __and_<is_lvalue_reference<_From>,
1032  is_rvalue_reference<_To>>::value>
1033  struct __is_lvalue_to_rvalue_ref;
1034 
1035  // Detect whether we have an lvalue of non-function type
1036  // bound to a reference-compatible rvalue-reference.
1037  template<typename _From, typename _To>
1038  struct __is_lvalue_to_rvalue_ref<_From, _To, true>
1039  {
1040  typedef typename remove_cv<typename remove_reference<
1041  _From>::type>::type __src_t;
1042  typedef typename remove_cv<typename remove_reference<
1043  _To>::type>::type __dst_t;
1044  typedef __and_<__not_<is_function<__src_t>>,
1045  __or_<is_same<__src_t, __dst_t>,
1046  is_base_of<__dst_t, __src_t>>> type;
1047  static constexpr bool value = type::value;
1048  };
1049 
1050  template<typename _From, typename _To>
1051  struct __is_lvalue_to_rvalue_ref<_From, _To, false>
1052  : public false_type
1053  { };
1054 
1055  // Here we handle direct-initialization to a reference type as
1056  // equivalent to a static_cast modulo overshooting conversions.
1057  // These are restricted to the following conversions:
1058  // a) A base class value to a derived class reference
1059  // b) An lvalue to an rvalue-reference of reference-compatible
1060  // types that are not functions
1061  template<typename _Tp, typename _Arg>
1062  struct __is_direct_constructible_ref_cast
1063  : public __and_<__is_static_castable<_Arg, _Tp>,
1064  __not_<__or_<__is_base_to_derived_ref<_Arg, _Tp>,
1065  __is_lvalue_to_rvalue_ref<_Arg, _Tp>
1066  >>>
1067  { };
1068 
1069  template<typename _Tp, typename _Arg>
1070  struct __is_direct_constructible_new
1071  : public conditional<is_reference<_Tp>::value,
1072  __is_direct_constructible_ref_cast<_Tp, _Arg>,
1073  __is_direct_constructible_new_safe<_Tp, _Arg>
1074  >::type
1075  { };
1076 
1077  template<typename _Tp, typename _Arg>
1078  struct __is_direct_constructible
1079  : public __is_direct_constructible_new<_Tp, _Arg>::type
1080  { };
1081 
1082  // Since default-construction and binary direct-initialization have
1083  // been handled separately, the implementation of the remaining
1084  // n-ary construction cases is rather straightforward. We can use
1085  // here a functional cast, because array types are excluded anyway
1086  // and this form is never interpreted as a C cast.
1087  struct __do_is_nary_constructible_impl
1088  {
1089  template<typename _Tp, typename... _Args, typename
1090  = decltype(_Tp(declval<_Args>()...))>
1091  static true_type __test(int);
1092 
1093  template<typename, typename...>
1094  static false_type __test(...);
1095  };
1096 
1097  template<typename _Tp, typename... _Args>
1098  struct __is_nary_constructible_impl
1099  : public __do_is_nary_constructible_impl
1100  {
1101  typedef decltype(__test<_Tp, _Args...>(0)) type;
1102  };
1103 
1104  template<typename _Tp, typename... _Args>
1105  struct __is_nary_constructible
1106  : public __is_nary_constructible_impl<_Tp, _Args...>::type
1107  {
1108  static_assert(sizeof...(_Args) > 1,
1109  "Only useful for > 1 arguments");
1110  };
1111 
1112  template<typename _Tp, typename... _Args>
1113  struct __is_constructible_impl
1114  : public __is_nary_constructible<_Tp, _Args...>
1115  { };
1116 
1117  template<typename _Tp, typename _Arg>
1118  struct __is_constructible_impl<_Tp, _Arg>
1119  : public __is_direct_constructible<_Tp, _Arg>
1120  { };
1121 
1122  template<typename _Tp>
1123  struct __is_constructible_impl<_Tp>
1124  : public is_default_constructible<_Tp>
1125  { };
1126 
1127  /// is_constructible
1128  template<typename _Tp, typename... _Args>
1129  struct is_constructible
1130  : public __is_constructible_impl<_Tp, _Args...>::type
1131  { };
1132 
1133  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1134  struct __is_copy_constructible_impl;
1135 
1136  template<typename _Tp>
1137  struct __is_copy_constructible_impl<_Tp, false>
1138  : public false_type { };
1139 
1140  template<typename _Tp>
1141  struct __is_copy_constructible_impl<_Tp, true>
1142  : public is_constructible<_Tp, const _Tp&>
1143  { };
1144 
1145  /// is_copy_constructible
1146  template<typename _Tp>
1147  struct is_copy_constructible
1148  : public __is_copy_constructible_impl<_Tp>
1149  { };
1150 
1151  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1152  struct __is_move_constructible_impl;
1153 
1154  template<typename _Tp>
1155  struct __is_move_constructible_impl<_Tp, false>
1156  : public false_type { };
1157 
1158  template<typename _Tp>
1159  struct __is_move_constructible_impl<_Tp, true>
1160  : public is_constructible<_Tp, _Tp&&>
1161  { };
1162 
1163  /// is_move_constructible
1164  template<typename _Tp>
1165  struct is_move_constructible
1166  : public __is_move_constructible_impl<_Tp>
1167  { };
1168 
1169  template<typename _Tp>
1170  struct __is_nt_default_constructible_atom
1171  : public integral_constant<bool, noexcept(_Tp())>
1172  { };
1173 
1174  template<typename _Tp, bool = is_array<_Tp>::value>
1175  struct __is_nt_default_constructible_impl;
1176 
1177  template<typename _Tp>
1178  struct __is_nt_default_constructible_impl<_Tp, true>
1179  : public __and_<__is_array_known_bounds<_Tp>,
1180  __is_nt_default_constructible_atom<typename
1181  remove_all_extents<_Tp>::type>>
1182  { };
1183 
1184  template<typename _Tp>
1185  struct __is_nt_default_constructible_impl<_Tp, false>
1186  : public __is_nt_default_constructible_atom<_Tp>
1187  { };
1188 
1189  /// is_nothrow_default_constructible
1190  template<typename _Tp>
1191  struct is_nothrow_default_constructible
1192  : public __and_<is_default_constructible<_Tp>,
1193  __is_nt_default_constructible_impl<_Tp>>
1194  { };
1195 
1196  template<typename _Tp, typename... _Args>
1197  struct __is_nt_constructible_impl
1198  : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
1199  { };
1200 
1201  template<typename _Tp, typename _Arg>
1202  struct __is_nt_constructible_impl<_Tp, _Arg>
1203  : public integral_constant<bool,
1204  noexcept(static_cast<_Tp>(declval<_Arg>()))>
1205  { };
1206 
1207  template<typename _Tp>
1208  struct __is_nt_constructible_impl<_Tp>
1209  : public is_nothrow_default_constructible<_Tp>
1210  { };
1211 
1212  /// is_nothrow_constructible
1213  template<typename _Tp, typename... _Args>
1214  struct is_nothrow_constructible
1215  : public __and_<is_constructible<_Tp, _Args...>,
1216  __is_nt_constructible_impl<_Tp, _Args...>>
1217  { };
1218 
1219  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1220  struct __is_nothrow_copy_constructible_impl;
1221 
1222  template<typename _Tp>
1223  struct __is_nothrow_copy_constructible_impl<_Tp, false>
1224  : public false_type { };
1225 
1226  template<typename _Tp>
1227  struct __is_nothrow_copy_constructible_impl<_Tp, true>
1228  : public is_nothrow_constructible<_Tp, const _Tp&>
1229  { };
1230 
1231  /// is_nothrow_copy_constructible
1232  template<typename _Tp>
1233  struct is_nothrow_copy_constructible
1234  : public __is_nothrow_copy_constructible_impl<_Tp>
1235  { };
1236 
1237  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1238  struct __is_nothrow_move_constructible_impl;
1239 
1240  template<typename _Tp>
1241  struct __is_nothrow_move_constructible_impl<_Tp, false>
1242  : public false_type { };
1243 
1244  template<typename _Tp>
1245  struct __is_nothrow_move_constructible_impl<_Tp, true>
1246  : public is_nothrow_constructible<_Tp, _Tp&&>
1247  { };
1248 
1249  /// is_nothrow_move_constructible
1250  template<typename _Tp>
1251  struct is_nothrow_move_constructible
1252  : public __is_nothrow_move_constructible_impl<_Tp>
1253  { };
1254 
1255  template<typename _Tp, typename _Up>
1256  class __is_assignable_helper
1257  {
1258  template<typename _Tp1, typename _Up1,
1259  typename = decltype(declval<_Tp1>() = declval<_Up1>())>
1260  static true_type
1261  __test(int);
1262 
1263  template<typename, typename>
1264  static false_type
1265  __test(...);
1266 
1267  public:
1268  typedef decltype(__test<_Tp, _Up>(0)) type;
1269  };
1270 
1271  /// is_assignable
1272  template<typename _Tp, typename _Up>
1273  struct is_assignable
1274  : public __is_assignable_helper<_Tp, _Up>::type
1275  { };
1276 
1277  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1278  struct __is_copy_assignable_impl;
1279 
1280  template<typename _Tp>
1281  struct __is_copy_assignable_impl<_Tp, false>
1282  : public false_type { };
1283 
1284  template<typename _Tp>
1285  struct __is_copy_assignable_impl<_Tp, true>
1286  : public is_assignable<_Tp&, const _Tp&>
1287  { };
1288 
1289  /// is_copy_assignable
1290  template<typename _Tp>
1291  struct is_copy_assignable
1292  : public __is_copy_assignable_impl<_Tp>
1293  { };
1294 
1295  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1296  struct __is_move_assignable_impl;
1297 
1298  template<typename _Tp>
1299  struct __is_move_assignable_impl<_Tp, false>
1300  : public false_type { };
1301 
1302  template<typename _Tp>
1303  struct __is_move_assignable_impl<_Tp, true>
1304  : public is_assignable<_Tp&, _Tp&&>
1305  { };
1306 
1307  /// is_move_assignable
1308  template<typename _Tp>
1309  struct is_move_assignable
1310  : public __is_move_assignable_impl<_Tp>
1311  { };
1312 
1313  template<typename _Tp, typename _Up>
1314  struct __is_nt_assignable_impl
1315  : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
1316  { };
1317 
1318  /// is_nothrow_assignable
1319  template<typename _Tp, typename _Up>
1320  struct is_nothrow_assignable
1321  : public __and_<is_assignable<_Tp, _Up>,
1322  __is_nt_assignable_impl<_Tp, _Up>>
1323  { };
1324 
1325  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1326  struct __is_nt_copy_assignable_impl;
1327 
1328  template<typename _Tp>
1329  struct __is_nt_copy_assignable_impl<_Tp, false>
1330  : public false_type { };
1331 
1332  template<typename _Tp>
1333  struct __is_nt_copy_assignable_impl<_Tp, true>
1334  : public is_nothrow_assignable<_Tp&, const _Tp&>
1335  { };
1336 
1337  /// is_nothrow_copy_assignable
1338  template<typename _Tp>
1339  struct is_nothrow_copy_assignable
1340  : public __is_nt_copy_assignable_impl<_Tp>
1341  { };
1342 
1343  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1344  struct __is_nt_move_assignable_impl;
1345 
1346  template<typename _Tp>
1347  struct __is_nt_move_assignable_impl<_Tp, false>
1348  : public false_type { };
1349 
1350  template<typename _Tp>
1351  struct __is_nt_move_assignable_impl<_Tp, true>
1352  : public is_nothrow_assignable<_Tp&, _Tp&&>
1353  { };
1354 
1355  /// is_nothrow_move_assignable
1356  template<typename _Tp>
1357  struct is_nothrow_move_assignable
1358  : public __is_nt_move_assignable_impl<_Tp>
1359  { };
1360 
1361  /// is_trivially_constructible
1362  template<typename _Tp, typename... _Args>
1363  struct is_trivially_constructible
1364  : public __and_<is_constructible<_Tp, _Args...>, integral_constant<bool,
1365  __is_trivially_constructible(_Tp, _Args...)>>
1366  { };
1367 
1368  /// is_trivially_default_constructible
1369  template<typename _Tp>
1370  struct is_trivially_default_constructible
1371  : public is_trivially_constructible<_Tp>::type
1372  { };
1373 
1374  struct __do_is_implicitly_default_constructible_impl
1375  {
1376  template <typename _Tp>
1377  static void __helper(const _Tp&);
1378 
1379  template <typename _Tp>
1380  static true_type __test(const _Tp&,
1381  decltype(__helper<const _Tp&>({}))* = 0);
1382 
1383  static false_type __test(...);
1384  };
1385 
1386  template<typename _Tp>
1387  struct __is_implicitly_default_constructible_impl
1388  : public __do_is_implicitly_default_constructible_impl
1389  {
1390  typedef decltype(__test(declval<_Tp>())) type;
1391  };
1392 
1393  template<typename _Tp>
1394  struct __is_implicitly_default_constructible_safe
1395  : public __is_implicitly_default_constructible_impl<_Tp>::type
1396  { };
1397 
1398  template <typename _Tp>
1399  struct __is_implicitly_default_constructible
1400  : public __and_<is_default_constructible<_Tp>,
1401  __is_implicitly_default_constructible_safe<_Tp>>
1402  { };
1403 
1404  /// is_trivially_copy_constructible
1405  template<typename _Tp>
1406  struct is_trivially_copy_constructible
1407  : public __and_<is_copy_constructible<_Tp>,
1408  integral_constant<bool,
1409  __is_trivially_constructible(_Tp, const _Tp&)>>
1410  { };
1411 
1412  /// is_trivially_move_constructible
1413  template<typename _Tp>
1414  struct is_trivially_move_constructible
1415  : public __and_<is_move_constructible<_Tp>,
1416  integral_constant<bool,
1417  __is_trivially_constructible(_Tp, _Tp&&)>>
1418  { };
1419 
1420  /// is_trivially_assignable
1421  template<typename _Tp, typename _Up>
1422  struct is_trivially_assignable
1423  : public __and_<is_assignable<_Tp, _Up>,
1424  integral_constant<bool,
1425  __is_trivially_assignable(_Tp, _Up)>>
1426  { };
1427 
1428  /// is_trivially_copy_assignable
1429  template<typename _Tp>
1430  struct is_trivially_copy_assignable
1431  : public __and_<is_copy_assignable<_Tp>,
1432  integral_constant<bool,
1433  __is_trivially_assignable(_Tp&, const _Tp&)>>
1434  { };
1435 
1436  /// is_trivially_move_assignable
1437  template<typename _Tp>
1438  struct is_trivially_move_assignable
1439  : public __and_<is_move_assignable<_Tp>,
1440  integral_constant<bool,
1441  __is_trivially_assignable(_Tp&, _Tp&&)>>
1442  { };
1443 
1444  /// is_trivially_destructible
1445  template<typename _Tp>
1446  struct is_trivially_destructible
1447  : public __and_<is_destructible<_Tp>, integral_constant<bool,
1448  __has_trivial_destructor(_Tp)>>
1449  { };
1450 
1451 
1452  /// has_virtual_destructor
1453  template<typename _Tp>
1454  struct has_virtual_destructor
1455  : public integral_constant<bool, __has_virtual_destructor(_Tp)>
1456  { };
1457 
1458 
1459  // type property queries.
1460 
1461  /// alignment_of
1462  template<typename _Tp>
1463  struct alignment_of
1464  : public integral_constant<std::size_t, __alignof__(_Tp)> { };
1465 
1466  /// rank
1467  template<typename>
1468  struct rank
1469  : public integral_constant<std::size_t, 0> { };
1470 
1471  template<typename _Tp, std::size_t _Size>
1472  struct rank<_Tp[_Size]>
1473  : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1474 
1475  template<typename _Tp>
1476  struct rank<_Tp[]>
1477  : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1478 
1479  /// extent
1480  template<typename, unsigned _Uint>
1481  struct extent
1482  : public integral_constant<std::size_t, 0> { };
1483 
1484  template<typename _Tp, unsigned _Uint, std::size_t _Size>
1485  struct extent<_Tp[_Size], _Uint>
1486  : public integral_constant<std::size_t,
1487  _Uint == 0 ? _Size : extent<_Tp,
1488  _Uint - 1>::value>
1489  { };
1490 
1491  template<typename _Tp, unsigned _Uint>
1492  struct extent<_Tp[], _Uint>
1493  : public integral_constant<std::size_t,
1494  _Uint == 0 ? 0 : extent<_Tp,
1495  _Uint - 1>::value>
1496  { };
1497 
1498 
1499  // Type relations.
1500 
1501  /// is_same
1502  template<typename, typename>
1503  struct is_same
1504  : public false_type { };
1505 
1506  template<typename _Tp>
1507  struct is_same<_Tp, _Tp>
1508  : public true_type { };
1509 
1510  /// is_base_of
1511  template<typename _Base, typename _Derived>
1512  struct is_base_of
1513  : public integral_constant<bool, __is_base_of(_Base, _Derived)>
1514  { };
1515 
1516  template<typename _From, typename _To,
1517  bool = __or_<is_void<_From>, is_function<_To>,
1518  is_array<_To>>::value>
1519  struct __is_convertible_helper
1520  { typedef typename is_void<_To>::type type; };
1521 
1522  template<typename _From, typename _To>
1523  class __is_convertible_helper<_From, _To, false>
1524  {
1525  template<typename _To1>
1526  static void __test_aux(_To1);
1527 
1528  template<typename _From1, typename _To1,
1529  typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
1530  static true_type
1531  __test(int);
1532 
1533  template<typename, typename>
1534  static false_type
1535  __test(...);
1536 
1537  public:
1538  typedef decltype(__test<_From, _To>(0)) type;
1539  };
1540 
1541 
1542  /// is_convertible
1543  template<typename _From, typename _To>
1544  struct is_convertible
1545  : public __is_convertible_helper<_From, _To>::type
1546  { };
1547 
1548 
1549  // Const-volatile modifications.
1550 
1551  /// remove_const
1552  template<typename _Tp>
1553  struct remove_const
1554  { typedef _Tp type; };
1555 
1556  template<typename _Tp>
1557  struct remove_const<_Tp const>
1558  { typedef _Tp type; };
1559 
1560  /// remove_volatile
1561  template<typename _Tp>
1562  struct remove_volatile
1563  { typedef _Tp type; };
1564 
1565  template<typename _Tp>
1566  struct remove_volatile<_Tp volatile>
1567  { typedef _Tp type; };
1568 
1569  /// remove_cv
1570  template<typename _Tp>
1571  struct remove_cv
1572  {
1573  typedef typename
1574  remove_const<typename remove_volatile<_Tp>::type>::type type;
1575  };
1576 
1577  /// add_const
1578  template<typename _Tp>
1579  struct add_const
1580  { typedef _Tp const type; };
1581 
1582  /// add_volatile
1583  template<typename _Tp>
1584  struct add_volatile
1585  { typedef _Tp volatile type; };
1586 
1587  /// add_cv
1588  template<typename _Tp>
1589  struct add_cv
1590  {
1591  typedef typename
1592  add_const<typename add_volatile<_Tp>::type>::type type;
1593  };
1594 
1595 #if __cplusplus > 201103L
1596 
1597 #define __cpp_lib_transformation_trait_aliases 201304
1598 
1599  /// Alias template for remove_const
1600  template<typename _Tp>
1601  using remove_const_t = typename remove_const<_Tp>::type;
1602 
1603  /// Alias template for remove_volatile
1604  template<typename _Tp>
1605  using remove_volatile_t = typename remove_volatile<_Tp>::type;
1606 
1607  /// Alias template for remove_cv
1608  template<typename _Tp>
1609  using remove_cv_t = typename remove_cv<_Tp>::type;
1610 
1611  /// Alias template for add_const
1612  template<typename _Tp>
1613  using add_const_t = typename add_const<_Tp>::type;
1614 
1615  /// Alias template for add_volatile
1616  template<typename _Tp>
1617  using add_volatile_t = typename add_volatile<_Tp>::type;
1618 
1619  /// Alias template for add_cv
1620  template<typename _Tp>
1621  using add_cv_t = typename add_cv<_Tp>::type;
1622 #endif
1623 
1624  // Reference transformations.
1625 
1626  /// remove_reference
1627  template<typename _Tp>
1628  struct remove_reference
1629  { typedef _Tp type; };
1630 
1631  template<typename _Tp>
1632  struct remove_reference<_Tp&>
1633  { typedef _Tp type; };
1634 
1635  template<typename _Tp>
1636  struct remove_reference<_Tp&&>
1637  { typedef _Tp type; };
1638 
1639  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1640  struct __add_lvalue_reference_helper
1641  { typedef _Tp type; };
1642 
1643  template<typename _Tp>
1644  struct __add_lvalue_reference_helper<_Tp, true>
1645  { typedef _Tp& type; };
1646 
1647  /// add_lvalue_reference
1648  template<typename _Tp>
1649  struct add_lvalue_reference
1650  : public __add_lvalue_reference_helper<_Tp>
1651  { };
1652 
1653  template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1654  struct __add_rvalue_reference_helper
1655  { typedef _Tp type; };
1656 
1657  template<typename _Tp>
1658  struct __add_rvalue_reference_helper<_Tp, true>
1659  { typedef _Tp&& type; };
1660 
1661  /// add_rvalue_reference
1662  template<typename _Tp>
1663  struct add_rvalue_reference
1664  : public __add_rvalue_reference_helper<_Tp>
1665  { };
1666 
1667 #if __cplusplus > 201103L
1668  /// Alias template for remove_reference
1669  template<typename _Tp>
1670  using remove_reference_t = typename remove_reference<_Tp>::type;
1671 
1672  /// Alias template for add_lvalue_reference
1673  template<typename _Tp>
1674  using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1675 
1676  /// Alias template for add_rvalue_reference
1677  template<typename _Tp>
1678  using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1679 #endif
1680 
1681  // Sign modifications.
1682 
1683  // Utility for constructing identically cv-qualified types.
1684  template<typename _Unqualified, bool _IsConst, bool _IsVol>
1685  struct __cv_selector;
1686 
1687  template<typename _Unqualified>
1688  struct __cv_selector<_Unqualified, false, false>
1689  { typedef _Unqualified __type; };
1690 
1691  template<typename _Unqualified>
1692  struct __cv_selector<_Unqualified, false, true>
1693  { typedef volatile _Unqualified __type; };
1694 
1695  template<typename _Unqualified>
1696  struct __cv_selector<_Unqualified, true, false>
1697  { typedef const _Unqualified __type; };
1698 
1699  template<typename _Unqualified>
1700  struct __cv_selector<_Unqualified, true, true>
1701  { typedef const volatile _Unqualified __type; };
1702 
1703  template<typename _Qualified, typename _Unqualified,
1704  bool _IsConst = is_const<_Qualified>::value,
1705  bool _IsVol = is_volatile<_Qualified>::value>
1706  class __match_cv_qualifiers
1707  {
1708  typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1709 
1710  public:
1711  typedef typename __match::__type __type;
1712  };
1713 
1714  // Utility for finding the unsigned versions of signed integral types.
1715  template<typename _Tp>
1716  struct __make_unsigned
1717  { typedef _Tp __type; };
1718 
1719  template<>
1720  struct __make_unsigned<char>
1721  { typedef unsigned char __type; };
1722 
1723  template<>
1724  struct __make_unsigned<signed char>
1725  { typedef unsigned char __type; };
1726 
1727  template<>
1728  struct __make_unsigned<short>
1729  { typedef unsigned short __type; };
1730 
1731  template<>
1732  struct __make_unsigned<int>
1733  { typedef unsigned int __type; };
1734 
1735  template<>
1736  struct __make_unsigned<long>
1737  { typedef unsigned long __type; };
1738 
1739  template<>
1740  struct __make_unsigned<long long>
1741  { typedef unsigned long long __type; };
1742 
1743 #if defined(_GLIBCXX_USE_WCHAR_T) && !defined(__WCHAR_UNSIGNED__)
1744  template<>
1745  struct __make_unsigned<wchar_t> : __make_unsigned<__WCHAR_TYPE__>
1746  { };
1747 #endif
1748 
1749 #if defined(__GLIBCXX_TYPE_INT_N_0)
1750  template<>
1751  struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
1752  { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; };
1753 #endif
1754 #if defined(__GLIBCXX_TYPE_INT_N_1)
1755  template<>
1756  struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
1757  { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; };
1758 #endif
1759 #if defined(__GLIBCXX_TYPE_INT_N_2)
1760  template<>
1761  struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
1762  { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; };
1763 #endif
1764 #if defined(__GLIBCXX_TYPE_INT_N_3)
1765  template<>
1766  struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
1767  { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; };
1768 #endif
1769 
1770  // Select between integral and enum: not possible to be both.
1771  template<typename _Tp,
1772  bool _IsInt = is_integral<_Tp>::value,
1773  bool _IsEnum = is_enum<_Tp>::value>
1774  class __make_unsigned_selector;
1775 
1776  template<typename _Tp>
1777  class __make_unsigned_selector<_Tp, true, false>
1778  {
1779  typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt;
1780  typedef typename __unsignedt::__type __unsigned_type;
1781  typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1782 
1783  public:
1784  typedef typename __cv_unsigned::__type __type;
1785  };
1786 
1787  template<typename _Tp>
1788  class __make_unsigned_selector<_Tp, false, true>
1789  {
1790  // With -fshort-enums, an enum may be as small as a char.
1791  typedef unsigned char __smallest;
1792  static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1793  static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short);
1794  static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int);
1795  static const bool __b3 = sizeof(_Tp) <= sizeof(unsigned long);
1796  typedef conditional<__b3, unsigned long, unsigned long long> __cond3;
1797  typedef typename __cond3::type __cond3_type;
1798  typedef conditional<__b2, unsigned int, __cond3_type> __cond2;
1799  typedef typename __cond2::type __cond2_type;
1800  typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
1801  typedef typename __cond1::type __cond1_type;
1802 
1803  typedef typename conditional<__b0, __smallest, __cond1_type>::type
1804  __unsigned_type;
1805  typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1806 
1807  public:
1808  typedef typename __cv_unsigned::__type __type;
1809  };
1810 
1811  // Given an integral/enum type, return the corresponding unsigned
1812  // integer type.
1813  // Primary template.
1814  /// make_unsigned
1815  template<typename _Tp>
1816  struct make_unsigned
1817  { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1818 
1819  // Integral, but don't define.
1820  template<>
1821  struct make_unsigned<bool>;
1822 
1823 
1824  // Utility for finding the signed versions of unsigned integral types.
1825  template<typename _Tp>
1826  struct __make_signed
1827  { typedef _Tp __type; };
1828 
1829  template<>
1830  struct __make_signed<char>
1831  { typedef signed char __type; };
1832 
1833  template<>
1834  struct __make_signed<unsigned char>
1835  { typedef signed char __type; };
1836 
1837  template<>
1838  struct __make_signed<unsigned short>
1839  { typedef signed short __type; };
1840 
1841  template<>
1842  struct __make_signed<unsigned int>
1843  { typedef signed int __type; };
1844 
1845  template<>
1846  struct __make_signed<unsigned long>
1847  { typedef signed long __type; };
1848 
1849  template<>
1850  struct __make_signed<unsigned long long>
1851  { typedef signed long long __type; };
1852 
1853 #if defined(_GLIBCXX_USE_WCHAR_T) && defined(__WCHAR_UNSIGNED__)
1854  template<>
1855  struct __make_signed<wchar_t> : __make_signed<__WCHAR_TYPE__>
1856  { };
1857 #endif
1858 
1859 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
1860  template<>
1861  struct __make_signed<char16_t> : __make_signed<uint_least16_t>
1862  { };
1863  template<>
1864  struct __make_signed<char32_t> : __make_signed<uint_least32_t>
1865  { };
1866 #endif
1867 
1868 #if defined(__GLIBCXX_TYPE_INT_N_0)
1869  template<>
1870  struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
1871  { typedef __GLIBCXX_TYPE_INT_N_0 __type; };
1872 #endif
1873 #if defined(__GLIBCXX_TYPE_INT_N_1)
1874  template<>
1875  struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
1876  { typedef __GLIBCXX_TYPE_INT_N_1 __type; };
1877 #endif
1878 #if defined(__GLIBCXX_TYPE_INT_N_2)
1879  template<>
1880  struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
1881  { typedef __GLIBCXX_TYPE_INT_N_2 __type; };
1882 #endif
1883 #if defined(__GLIBCXX_TYPE_INT_N_3)
1884  template<>
1885  struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
1886  { typedef __GLIBCXX_TYPE_INT_N_3 __type; };
1887 #endif
1888 
1889  // Select between integral and enum: not possible to be both.
1890  template<typename _Tp,
1891  bool _IsInt = is_integral<_Tp>::value,
1892  bool _IsEnum = is_enum<_Tp>::value>
1893  class __make_signed_selector;
1894 
1895  template<typename _Tp>
1896  class __make_signed_selector<_Tp, true, false>
1897  {
1898  typedef __make_signed<typename remove_cv<_Tp>::type> __signedt;
1899  typedef typename __signedt::__type __signed_type;
1900  typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed;
1901 
1902  public:
1903  typedef typename __cv_signed::__type __type;
1904  };
1905 
1906  template<typename _Tp>
1907  class __make_signed_selector<_Tp, false, true>
1908  {
1909  typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type;
1910 
1911  public:
1912  typedef typename __make_signed_selector<__unsigned_type>::__type __type;
1913  };
1914 
1915  // Given an integral/enum type, return the corresponding signed
1916  // integer type.
1917  // Primary template.
1918  /// make_signed
1919  template<typename _Tp>
1920  struct make_signed
1921  { typedef typename __make_signed_selector<_Tp>::__type type; };
1922 
1923  // Integral, but don't define.
1924  template<>
1925  struct make_signed<bool>;
1926 
1927 #if __cplusplus > 201103L
1928  /// Alias template for make_signed
1929  template<typename _Tp>
1930  using make_signed_t = typename make_signed<_Tp>::type;
1931 
1932  /// Alias template for make_unsigned
1933  template<typename _Tp>
1934  using make_unsigned_t = typename make_unsigned<_Tp>::type;
1935 #endif
1936 
1937  // Array modifications.
1938 
1939  /// remove_extent
1940  template<typename _Tp>
1941  struct remove_extent
1942  { typedef _Tp type; };
1943 
1944  template<typename _Tp, std::size_t _Size>
1945  struct remove_extent<_Tp[_Size]>
1946  { typedef _Tp type; };
1947 
1948  template<typename _Tp>
1949  struct remove_extent<_Tp[]>
1950  { typedef _Tp type; };
1951 
1952  /// remove_all_extents
1953  template<typename _Tp>
1954  struct remove_all_extents
1955  { typedef _Tp type; };
1956 
1957  template<typename _Tp, std::size_t _Size>
1958  struct remove_all_extents<_Tp[_Size]>
1959  { typedef typename remove_all_extents<_Tp>::type type; };
1960 
1961  template<typename _Tp>
1962  struct remove_all_extents<_Tp[]>
1963  { typedef typename remove_all_extents<_Tp>::type type; };
1964 
1965 #if __cplusplus > 201103L
1966  /// Alias template for remove_extent
1967  template<typename _Tp>
1968  using remove_extent_t = typename remove_extent<_Tp>::type;
1969 
1970  /// Alias template for remove_all_extents
1971  template<typename _Tp>
1972  using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1973 #endif
1974 
1975  // Pointer modifications.
1976 
1977  template<typename _Tp, typename>
1978  struct __remove_pointer_helper
1979  { typedef _Tp type; };
1980 
1981  template<typename _Tp, typename _Up>
1982  struct __remove_pointer_helper<_Tp, _Up*>
1983  { typedef _Up type; };
1984 
1985  /// remove_pointer
1986  template<typename _Tp>
1987  struct remove_pointer
1988  : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1989  { };
1990 
1991  /// add_pointer
1992  template<typename _Tp, bool = __or_<__is_referenceable<_Tp>,
1993  is_void<_Tp>>::value>
1994  struct __add_pointer_helper
1995  { typedef _Tp type; };
1996 
1997  template<typename _Tp>
1998  struct __add_pointer_helper<_Tp, true>
1999  { typedef typename remove_reference<_Tp>::type* type; };
2000 
2001  template<typename _Tp>
2002  struct add_pointer
2003  : public __add_pointer_helper<_Tp>
2004  { };
2005 
2006 #if __cplusplus > 201103L
2007  /// Alias template for remove_pointer
2008  template<typename _Tp>
2009  using remove_pointer_t = typename remove_pointer<_Tp>::type;
2010 
2011  /// Alias template for add_pointer
2012  template<typename _Tp>
2013  using add_pointer_t = typename add_pointer<_Tp>::type;
2014 #endif
2015 
2016  template<std::size_t _Len>
2017  struct __aligned_storage_msa
2018  {
2019  union __type
2020  {
2021  unsigned char __data[_Len];
2022  struct __attribute__((__aligned__)) { } __align;
2023  };
2024  };
2025 
2026  /**
2027  * @brief Alignment type.
2028  *
2029  * The value of _Align is a default-alignment which shall be the
2030  * most stringent alignment requirement for any C++ object type
2031  * whose size is no greater than _Len (3.9). The member typedef
2032  * type shall be a POD type suitable for use as uninitialized
2033  * storage for any object whose size is at most _Len and whose
2034  * alignment is a divisor of _Align.
2035  */
2036  template<std::size_t _Len, std::size_t _Align =
2037  __alignof__(typename __aligned_storage_msa<_Len>::__type)>
2038  struct aligned_storage
2039  {
2040  union type
2041  {
2042  unsigned char __data[_Len];
2043  struct __attribute__((__aligned__((_Align)))) { } __align;
2044  };
2045  };
2046 
2047  template <typename... _Types>
2048  struct __strictest_alignment
2049  {
2050  static const size_t _S_alignment = 0;
2051  static const size_t _S_size = 0;
2052  };
2053 
2054  template <typename _Tp, typename... _Types>
2055  struct __strictest_alignment<_Tp, _Types...>
2056  {
2057  static const size_t _S_alignment =
2058  alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment
2059  ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment;
2060  static const size_t _S_size =
2061  sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size
2062  ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size;
2063  };
2064 
2065  /**
2066  * @brief Provide aligned storage for types.
2067  *
2068  * [meta.trans.other]
2069  *
2070  * Provides aligned storage for any of the provided types of at
2071  * least size _Len.
2072  *
2073  * @see aligned_storage
2074  */
2075  template <size_t _Len, typename... _Types>
2076  struct aligned_union
2077  {
2078  private:
2079  static_assert(sizeof...(_Types) != 0, "At least one type is required");
2080 
2081  using __strictest = __strictest_alignment<_Types...>;
2082  static const size_t _S_len = _Len > __strictest::_S_size
2083  ? _Len : __strictest::_S_size;
2084  public:
2085  /// The value of the strictest alignment of _Types.
2086  static const size_t alignment_value = __strictest::_S_alignment;
2087  /// The storage.
2088  typedef typename aligned_storage<_S_len, alignment_value>::type type;
2089  };
2090 
2091  template <size_t _Len, typename... _Types>
2092  const size_t aligned_union<_Len, _Types...>::alignment_value;
2093 
2094  // Decay trait for arrays and functions, used for perfect forwarding
2095  // in make_pair, make_tuple, etc.
2096  template<typename _Up,
2097  bool _IsArray = is_array<_Up>::value,
2098  bool _IsFunction = is_function<_Up>::value>
2099  struct __decay_selector;
2100 
2101  // NB: DR 705.
2102  template<typename _Up>
2103  struct __decay_selector<_Up, false, false>
2104  { typedef typename remove_cv<_Up>::type __type; };
2105 
2106  template<typename _Up>
2107  struct __decay_selector<_Up, true, false>
2108  { typedef typename remove_extent<_Up>::type* __type; };
2109 
2110  template<typename _Up>
2111  struct __decay_selector<_Up, false, true>
2112  { typedef typename add_pointer<_Up>::type __type; };
2113 
2114  /// decay
2115  template<typename _Tp>
2116  class decay
2117  {
2118  typedef typename remove_reference<_Tp>::type __remove_type;
2119 
2120  public:
2121  typedef typename __decay_selector<__remove_type>::__type type;
2122  };
2123 
2124  template<typename _Tp>
2125  class reference_wrapper;
2126 
2127  // Helper which adds a reference to a type when given a reference_wrapper
2128  template<typename _Tp>
2129  struct __strip_reference_wrapper
2130  {
2131  typedef _Tp __type;
2132  };
2133 
2134  template<typename _Tp>
2135  struct __strip_reference_wrapper<reference_wrapper<_Tp> >
2136  {
2137  typedef _Tp& __type;
2138  };
2139 
2140  template<typename _Tp>
2141  struct __decay_and_strip
2142  {
2143  typedef typename __strip_reference_wrapper<
2144  typename decay<_Tp>::type>::__type __type;
2145  };
2146 
2147 
2148  // Primary template.
2149  /// Define a member typedef @c type only if a boolean constant is true.
2150  template<bool, typename _Tp = void>
2151  struct enable_if
2152  { };
2153 
2154  // Partial specialization for true.
2155  template<typename _Tp>
2156  struct enable_if<true, _Tp>
2157  { typedef _Tp type; };
2158 
2159  template<typename... _Cond>
2160  using _Require = typename enable_if<__and_<_Cond...>::value>::type;
2161 
2162  // Primary template.
2163  /// Define a member typedef @c type to one of two argument types.
2164  template<bool _Cond, typename _Iftrue, typename _Iffalse>
2165  struct conditional
2166  { typedef _Iftrue type; };
2167 
2168  // Partial specialization for false.
2169  template<typename _Iftrue, typename _Iffalse>
2170  struct conditional<false, _Iftrue, _Iffalse>
2171  { typedef _Iffalse type; };
2172 
2173  /// common_type
2174  template<typename... _Tp>
2175  struct common_type;
2176 
2177  // Sfinae-friendly common_type implementation:
2178 
2179  struct __do_common_type_impl
2180  {
2181  template<typename _Tp, typename _Up>
2182  static __success_type<typename decay<decltype
2183  (true ? std::declval<_Tp>()
2184  : std::declval<_Up>())>::type> _S_test(int);
2185 
2186  template<typename, typename>
2187  static __failure_type _S_test(...);
2188  };
2189 
2190  template<typename _Tp, typename _Up>
2191  struct __common_type_impl
2192  : private __do_common_type_impl
2193  {
2194  typedef decltype(_S_test<_Tp, _Up>(0)) type;
2195  };
2196 
2197  struct __do_member_type_wrapper
2198  {
2199  template<typename _Tp>
2200  static __success_type<typename _Tp::type> _S_test(int);
2201 
2202  template<typename>
2203  static __failure_type _S_test(...);
2204  };
2205 
2206  template<typename _Tp>
2207  struct __member_type_wrapper
2208  : private __do_member_type_wrapper
2209  {
2210  typedef decltype(_S_test<_Tp>(0)) type;
2211  };
2212 
2213  template<typename _CTp, typename... _Args>
2214  struct __expanded_common_type_wrapper
2215  {
2216  typedef common_type<typename _CTp::type, _Args...> type;
2217  };
2218 
2219  template<typename... _Args>
2220  struct __expanded_common_type_wrapper<__failure_type, _Args...>
2221  { typedef __failure_type type; };
2222 
2223  template<typename _Tp>
2224  struct common_type<_Tp>
2225  { typedef typename decay<_Tp>::type type; };
2226 
2227  template<typename _Tp, typename _Up>
2228  struct common_type<_Tp, _Up>
2229  : public __common_type_impl<_Tp, _Up>::type
2230  { };
2231 
2232  template<typename _Tp, typename _Up, typename... _Vp>
2233  struct common_type<_Tp, _Up, _Vp...>
2234  : public __expanded_common_type_wrapper<typename __member_type_wrapper<
2235  common_type<_Tp, _Up>>::type, _Vp...>::type
2236  { };
2237 
2238  /// The underlying type of an enum.
2239  template<typename _Tp>
2240  struct underlying_type
2241  {
2242  typedef __underlying_type(_Tp) type;
2243  };
2244 
2245  template<typename _Tp>
2246  struct __declval_protector
2247  {
2248  static const bool __stop = false;
2249  static typename add_rvalue_reference<_Tp>::type __delegate();
2250  };
2251 
2252  template<typename _Tp>
2253  inline typename add_rvalue_reference<_Tp>::type
2254  declval() noexcept
2255  {
2256  static_assert(__declval_protector<_Tp>::__stop,
2257  "declval() must not be used!");
2258  return __declval_protector<_Tp>::__delegate();
2259  }
2260 
2261  /// result_of
2262  template<typename _Signature>
2263  class result_of;
2264 
2265  // Sfinae-friendly result_of implementation:
2266 
2267 #define __cpp_lib_result_of_sfinae 201210
2268 
2269  struct __invoke_memfun_ref { };
2270  struct __invoke_memfun_deref { };
2271  struct __invoke_memobj_ref { };
2272  struct __invoke_memobj_deref { };
2273  struct __invoke_other { };
2274 
2275  // Associate a tag type with a specialization of __success_type.
2276  template<typename _Tp, typename _Tag>
2277  struct __result_of_success : __success_type<_Tp>
2278  { using __invoke_type = _Tag; };
2279 
2280  // [func.require] paragraph 1 bullet 1:
2281  struct __result_of_memfun_ref_impl
2282  {
2283  template<typename _Fp, typename _Tp1, typename... _Args>
2284  static __result_of_success<decltype(
2285  (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
2286  ), __invoke_memfun_ref> _S_test(int);
2287 
2288  template<typename...>
2289  static __failure_type _S_test(...);
2290  };
2291 
2292  template<typename _MemPtr, typename _Arg, typename... _Args>
2293  struct __result_of_memfun_ref
2294  : private __result_of_memfun_ref_impl
2295  {
2296  typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2297  };
2298 
2299  // [func.require] paragraph 1 bullet 2:
2300  struct __result_of_memfun_deref_impl
2301  {
2302  template<typename _Fp, typename _Tp1, typename... _Args>
2303  static __result_of_success<decltype(
2304  ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
2305  ), __invoke_memfun_deref> _S_test(int);
2306 
2307  template<typename...>
2308  static __failure_type _S_test(...);
2309  };
2310 
2311  template<typename _MemPtr, typename _Arg, typename... _Args>
2312  struct __result_of_memfun_deref
2313  : private __result_of_memfun_deref_impl
2314  {
2315  typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2316  };
2317 
2318  // [func.require] paragraph 1 bullet 3:
2319  struct __result_of_memobj_ref_impl
2320  {
2321  template<typename _Fp, typename _Tp1>
2322  static __result_of_success<decltype(
2323  std::declval<_Tp1>().*std::declval<_Fp>()
2324  ), __invoke_memobj_ref> _S_test(int);
2325 
2326  template<typename, typename>
2327  static __failure_type _S_test(...);
2328  };
2329 
2330  template<typename _MemPtr, typename _Arg>
2331  struct __result_of_memobj_ref
2332  : private __result_of_memobj_ref_impl
2333  {
2334  typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2335  };
2336 
2337  // [func.require] paragraph 1 bullet 4:
2338  struct __result_of_memobj_deref_impl
2339  {
2340  template<typename _Fp, typename _Tp1>
2341  static __result_of_success<decltype(
2342  (*std::declval<_Tp1>()).*std::declval<_Fp>()
2343  ), __invoke_memobj_deref> _S_test(int);
2344 
2345  template<typename, typename>
2346  static __failure_type _S_test(...);
2347  };
2348 
2349  template<typename _MemPtr, typename _Arg>
2350  struct __result_of_memobj_deref
2351  : private __result_of_memobj_deref_impl
2352  {
2353  typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2354  };
2355 
2356  template<typename _MemPtr, typename _Arg>
2357  struct __result_of_memobj;
2358 
2359  template<typename _Res, typename _Class, typename _Arg>
2360  struct __result_of_memobj<_Res _Class::*, _Arg>
2361  {
2362  typedef typename remove_cv<typename remove_reference<
2363  _Arg>::type>::type _Argval;
2364  typedef _Res _Class::* _MemPtr;
2365  typedef typename conditional<__or_<is_same<_Argval, _Class>,
2366  is_base_of<_Class, _Argval>>::value,
2367  __result_of_memobj_ref<_MemPtr, _Arg>,
2368  __result_of_memobj_deref<_MemPtr, _Arg>
2369  >::type::type type;
2370  };
2371 
2372  template<typename _MemPtr, typename _Arg, typename... _Args>
2373  struct __result_of_memfun;
2374 
2375  template<typename _Res, typename _Class, typename _Arg, typename... _Args>
2376  struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
2377  {
2378  typedef typename remove_cv<typename remove_reference<
2379  _Arg>::type>::type _Argval;
2380  typedef _Res _Class::* _MemPtr;
2381  typedef typename conditional<__or_<is_same<_Argval, _Class>,
2382  is_base_of<_Class, _Argval>>::value,
2383  __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
2384  __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
2385  >::type::type type;
2386  };
2387 
2388  // _GLIBCXX_RESOLVE_LIB_DEFECTS
2389  // 2219. INVOKE-ing a pointer to member with a reference_wrapper
2390  // as the object expression
2391 
2392  // Used by result_of, invoke etc. to unwrap a reference_wrapper.
2393  template<typename _Tp, typename _Up = typename decay<_Tp>::type>
2394  struct __inv_unwrap
2395  {
2396  using type = _Tp;
2397  };
2398 
2399  template<typename _Tp, typename _Up>
2400  struct __inv_unwrap<_Tp, reference_wrapper<_Up>>
2401  {
2402  using type = _Up&;
2403  };
2404 
2405  template<bool, bool, typename _Functor, typename... _ArgTypes>
2406  struct __result_of_impl
2407  {
2408  typedef __failure_type type;
2409  };
2410 
2411  template<typename _MemPtr, typename _Arg>
2412  struct __result_of_impl<true, false, _MemPtr, _Arg>
2413  : public __result_of_memobj<typename decay<_MemPtr>::type,
2414  typename __inv_unwrap<_Arg>::type>
2415  { };
2416 
2417  template<typename _MemPtr, typename _Arg, typename... _Args>
2418  struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
2419  : public __result_of_memfun<typename decay<_MemPtr>::type,
2420  typename __inv_unwrap<_Arg>::type, _Args...>
2421  { };
2422 
2423  // [func.require] paragraph 1 bullet 5:
2424  struct __result_of_other_impl
2425  {
2426  template<typename _Fn, typename... _Args>
2427  static __result_of_success<decltype(
2428  std::declval<_Fn>()(std::declval<_Args>()...)
2429  ), __invoke_other> _S_test(int);
2430 
2431  template<typename...>
2432  static __failure_type _S_test(...);
2433  };
2434 
2435  template<typename _Functor, typename... _ArgTypes>
2436  struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2437  : private __result_of_other_impl
2438  {
2439  typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
2440  };
2441 
2442  // __invoke_result (std::invoke_result for C++11)
2443  template<typename _Functor, typename... _ArgTypes>
2444  struct __invoke_result
2445  : public __result_of_impl<
2446  is_member_object_pointer<
2447  typename remove_reference<_Functor>::type
2448  >::value,
2449  is_member_function_pointer<
2450  typename remove_reference<_Functor>::type
2451  >::value,
2452  _Functor, _ArgTypes...
2453  >::type
2454  { };
2455 
2456  template<typename _Functor, typename... _ArgTypes>
2457  struct result_of<_Functor(_ArgTypes...)>
2458  : public __invoke_result<_Functor, _ArgTypes...>
2459  { };
2460 
2461 #if __cplusplus >= 201402L
2462  /// Alias template for aligned_storage
2463  template<size_t _Len, size_t _Align =
2464  __alignof__(typename __aligned_storage_msa<_Len>::__type)>
2465  using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
2466 
2467  template <size_t _Len, typename... _Types>
2468  using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
2469 
2470  /// Alias template for decay
2471  template<typename _Tp>
2472  using decay_t = typename decay<_Tp>::type;
2473 
2474  /// Alias template for enable_if
2475  template<bool _Cond, typename _Tp = void>
2476  using enable_if_t = typename enable_if<_Cond, _Tp>::type;
2477 
2478  /// Alias template for conditional
2479  template<bool _Cond, typename _Iftrue, typename _Iffalse>
2480  using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
2481 
2482  /// Alias template for common_type
2483  template<typename... _Tp>
2484  using common_type_t = typename common_type<_Tp...>::type;
2485 
2486  /// Alias template for underlying_type
2487  template<typename _Tp>
2488  using underlying_type_t = typename underlying_type<_Tp>::type;
2489 
2490  /// Alias template for result_of
2491  template<typename _Tp>
2492  using result_of_t = typename result_of<_Tp>::type;
2493 #endif // C++14
2494 
2495  // __enable_if_t (std::enable_if_t for C++11)
2496  template<bool _Cond, typename _Tp = void>
2497  using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
2498 
2499  // __void_t (std::void_t for C++11)
2500  template<typename...> using __void_t = void;
2501 
2502 #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11
2503 #define __cpp_lib_void_t 201411
2504  /// A metafunction that always yields void, used for detecting valid types.
2505  template<typename...> using void_t = void;
2506 #endif
2507 
2508  /// Implementation of the detection idiom (negative case).
2509  template<typename _Default, typename _AlwaysVoid,
2510  template<typename...> class _Op, typename... _Args>
2511  struct __detector
2512  {
2513  using value_t = false_type;
2514  using type = _Default;
2515  };
2516 
2517  /// Implementation of the detection idiom (positive case).
2518  template<typename _Default, template<typename...> class _Op,
2519  typename... _Args>
2520  struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
2521  {
2522  using value_t = true_type;
2523  using type = _Op<_Args...>;
2524  };
2525 
2526  // Detect whether _Op<_Args...> is a valid type, use _Default if not.
2527  template<typename _Default, template<typename...> class _Op,
2528  typename... _Args>
2529  using __detected_or = __detector<_Default, void, _Op, _Args...>;
2530 
2531  // _Op<_Args...> if that is a valid type, otherwise _Default.
2532  template<typename _Default, template<typename...> class _Op,
2533  typename... _Args>
2534  using __detected_or_t
2535  = typename __detected_or<_Default, _Op, _Args...>::type;
2536 
2537  /// @} group metaprogramming
2538 
2539  /**
2540  * Use SFINAE to determine if the type _Tp has a publicly-accessible
2541  * member type _NTYPE.
2542  */
2543 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2544  template<typename _Tp, typename = __void_t<>> \
2545  struct __has_##_NTYPE \
2546  : false_type \
2547  { }; \
2548  template<typename _Tp> \
2549  struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \
2550  : true_type \
2551  { };
2552 
2553  template <typename _Tp>
2554  struct __is_swappable;
2555 
2556  template <typename _Tp>
2557  struct __is_nothrow_swappable;
2558 
2559  template<typename... _Elements>
2560  class tuple;
2561 
2562  template<typename>
2563  struct __is_tuple_like_impl : false_type
2564  { };
2565 
2566  template<typename... _Tps>
2567  struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
2568  { };
2569 
2570  // Internal type trait that allows us to sfinae-protect tuple_cat.
2571  template<typename _Tp>
2572  struct __is_tuple_like
2573  : public __is_tuple_like_impl<typename remove_cv<
2574  typename remove_reference<_Tp>::type>::type>::type
2575  { };
2576 
2577  template<typename _Tp>
2578  inline
2579  typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
2580  is_move_constructible<_Tp>,
2581  is_move_assignable<_Tp>>::value>::type
2582  swap(_Tp&, _Tp&)
2583  noexcept(__and_<is_nothrow_move_constructible<_Tp>,
2584  is_nothrow_move_assignable<_Tp>>::value);
2585 
2586  template<typename _Tp, size_t _Nm>
2587  inline
2588  typename enable_if<__is_swappable<_Tp>::value>::type
2589  swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
2590  noexcept(__is_nothrow_swappable<_Tp>::value);
2591 
2592  namespace __swappable_details {
2593  using std::swap;
2594 
2595  struct __do_is_swappable_impl
2596  {
2597  template<typename _Tp, typename
2598  = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))>
2599  static true_type __test(int);
2600 
2601  template<typename>
2602  static false_type __test(...);
2603  };
2604 
2605  struct __do_is_nothrow_swappable_impl
2606  {
2607  template<typename _Tp>
2608  static __bool_constant<
2609  noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))
2610  > __test(int);
2611 
2612  template<typename>
2613  static false_type __test(...);
2614  };
2615 
2616  } // namespace __swappable_details
2617 
2618  template<typename _Tp>
2619  struct __is_swappable_impl
2620  : public __swappable_details::__do_is_swappable_impl
2621  {
2622  typedef decltype(__test<_Tp>(0)) type;
2623  };
2624 
2625  template<typename _Tp>
2626  struct __is_nothrow_swappable_impl
2627  : public __swappable_details::__do_is_nothrow_swappable_impl
2628  {
2629  typedef decltype(__test<_Tp>(0)) type;
2630  };
2631 
2632  template<typename _Tp>
2633  struct __is_swappable
2634  : public __is_swappable_impl<_Tp>::type
2635  { };
2636 
2637  template<typename _Tp>
2638  struct __is_nothrow_swappable
2639  : public __is_nothrow_swappable_impl<_Tp>::type
2640  { };
2641 
2642 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
2643 #define __cpp_lib_is_swappable 201603
2644  /// Metafunctions used for detecting swappable types: p0185r1
2645 
2646  /// is_swappable
2647  template<typename _Tp>
2648  struct is_swappable
2649  : public __is_swappable_impl<_Tp>::type
2650  { };
2651 
2652  /// is_nothrow_swappable
2653  template<typename _Tp>
2654  struct is_nothrow_swappable
2655  : public __is_nothrow_swappable_impl<_Tp>::type
2656  { };
2657 
2658 #if __cplusplus >= 201402L
2659  /// is_swappable_v
2660  template<typename _Tp>
2661  _GLIBCXX17_INLINE constexpr bool is_swappable_v =
2662  is_swappable<_Tp>::value;
2663 
2664  /// is_nothrow_swappable_v
2665  template<typename _Tp>
2666  _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v =
2667  is_nothrow_swappable<_Tp>::value;
2668 #endif // __cplusplus >= 201402L
2669 
2670  namespace __swappable_with_details {
2671  using std::swap;
2672 
2673  struct __do_is_swappable_with_impl
2674  {
2675  template<typename _Tp, typename _Up, typename
2676  = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
2677  typename
2678  = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))>
2679  static true_type __test(int);
2680 
2681  template<typename, typename>
2682  static false_type __test(...);
2683  };
2684 
2685  struct __do_is_nothrow_swappable_with_impl
2686  {
2687  template<typename _Tp, typename _Up>
2688  static __bool_constant<
2689  noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
2690  &&
2691  noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()))
2692  > __test(int);
2693 
2694  template<typename, typename>
2695  static false_type __test(...);
2696  };
2697 
2698  } // namespace __swappable_with_details
2699 
2700  template<typename _Tp, typename _Up>
2701  struct __is_swappable_with_impl
2702  : public __swappable_with_details::__do_is_swappable_with_impl
2703  {
2704  typedef decltype(__test<_Tp, _Up>(0)) type;
2705  };
2706 
2707  // Optimization for the homogenous lvalue case, not required:
2708  template<typename _Tp>
2709  struct __is_swappable_with_impl<_Tp&, _Tp&>
2710  : public __swappable_details::__do_is_swappable_impl
2711  {
2712  typedef decltype(__test<_Tp&>(0)) type;
2713  };
2714 
2715  template<typename _Tp, typename _Up>
2716  struct __is_nothrow_swappable_with_impl
2717  : public __swappable_with_details::__do_is_nothrow_swappable_with_impl
2718  {
2719  typedef decltype(__test<_Tp, _Up>(0)) type;
2720  };
2721 
2722  // Optimization for the homogenous lvalue case, not required:
2723  template<typename _Tp>
2724  struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&>
2725  : public __swappable_details::__do_is_nothrow_swappable_impl
2726  {
2727  typedef decltype(__test<_Tp&>(0)) type;
2728  };
2729 
2730  /// is_swappable_with
2731  template<typename _Tp, typename _Up>
2732  struct is_swappable_with
2733  : public __is_swappable_with_impl<_Tp, _Up>::type
2734  { };
2735 
2736  /// is_nothrow_swappable_with
2737  template<typename _Tp, typename _Up>
2738  struct is_nothrow_swappable_with
2739  : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type
2740  { };
2741 
2742 #if __cplusplus >= 201402L
2743  /// is_swappable_with_v
2744  template<typename _Tp, typename _Up>
2745  _GLIBCXX17_INLINE constexpr bool is_swappable_with_v =
2746  is_swappable_with<_Tp, _Up>::value;
2747 
2748  /// is_nothrow_swappable_with_v
2749  template<typename _Tp, typename _Up>
2750  _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v =
2751  is_nothrow_swappable_with<_Tp, _Up>::value;
2752 #endif // __cplusplus >= 201402L
2753 
2754 #endif// c++1z or gnu++11
2755 
2756  // __is_invocable (std::is_invocable for C++11)
2757 
2758  template<typename _Result, typename _Ret, typename = void>
2759  struct __is_invocable_impl : false_type { };
2760 
2761  template<typename _Result, typename _Ret>
2762  struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>>
2763  : __or_<is_void<_Ret>, is_convertible<typename _Result::type, _Ret>>::type
2764  { };
2765 
2766  template<typename _Fn, typename... _ArgTypes>
2767  struct __is_invocable
2768  : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2769  { };
2770 
2771  template<typename _Fn, typename _Tp, typename... _Args>
2772  constexpr bool __call_is_nt(__invoke_memfun_ref)
2773  {
2774  using _Up = typename __inv_unwrap<_Tp>::type;
2775  return noexcept((std::declval<_Up>().*std::declval<_Fn>())(
2776  std::declval<_Args>()...));
2777  }
2778 
2779  template<typename _Fn, typename _Tp, typename... _Args>
2780  constexpr bool __call_is_nt(__invoke_memfun_deref)
2781  {
2782  return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())(
2783  std::declval<_Args>()...));
2784  }
2785 
2786  template<typename _Fn, typename _Tp>
2787  constexpr bool __call_is_nt(__invoke_memobj_ref)
2788  {
2789  using _Up = typename __inv_unwrap<_Tp>::type;
2790  return noexcept(std::declval<_Up>().*std::declval<_Fn>());
2791  }
2792 
2793  template<typename _Fn, typename _Tp>
2794  constexpr bool __call_is_nt(__invoke_memobj_deref)
2795  {
2796  return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>());
2797  }
2798 
2799  template<typename _Fn, typename... _Args>
2800  constexpr bool __call_is_nt(__invoke_other)
2801  {
2802  return noexcept(std::declval<_Fn>()(std::declval<_Args>()...));
2803  }
2804 
2805  template<typename _Result, typename _Fn, typename... _Args>
2806  struct __call_is_nothrow
2807  : __bool_constant<
2808  std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{})
2809  >
2810  { };
2811 
2812  template<typename _Fn, typename... _Args>
2813  using __call_is_nothrow_
2814  = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>;
2815 
2816  // __is_nothrow_invocable (std::is_nothrow_invocable for C++11)
2817  template<typename _Fn, typename... _Args>
2818  struct __is_nothrow_invocable
2819  : __and_<__is_invocable<_Fn, _Args...>,
2820  __call_is_nothrow_<_Fn, _Args...>>::type
2821  { };
2822 
2823  struct __nonesuch {
2824  __nonesuch() = delete;
2825  ~__nonesuch() = delete;
2826  __nonesuch(__nonesuch const&) = delete;
2827  void operator=(__nonesuch const&) = delete;
2828  };
2829 
2830 #if __cplusplus > 201402L
2831 # define __cpp_lib_is_invocable 201703
2832 
2833  /// std::invoke_result
2834  template<typename _Functor, typename... _ArgTypes>
2835  struct invoke_result
2836  : public __invoke_result<_Functor, _ArgTypes...>
2837  { };
2838 
2839  /// std::invoke_result_t
2840  template<typename _Fn, typename... _Args>
2841  using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
2842 
2843  /// std::is_invocable
2844  template<typename _Fn, typename... _ArgTypes>
2845  struct is_invocable
2846  : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2847  { };
2848 
2849  /// std::is_invocable_r
2850  template<typename _Ret, typename _Fn, typename... _ArgTypes>
2851  struct is_invocable_r
2852  : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type
2853  { };
2854 
2855  /// std::is_nothrow_invocable
2856  template<typename _Fn, typename... _ArgTypes>
2857  struct is_nothrow_invocable
2858  : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>,
2859  __call_is_nothrow_<_Fn, _ArgTypes...>>::type
2860  { };
2861 
2862  template<typename _Result, typename _Ret, typename = void>
2863  struct __is_nt_invocable_impl : false_type { };
2864 
2865  template<typename _Result, typename _Ret>
2866  struct __is_nt_invocable_impl<_Result, _Ret,
2867  __void_t<typename _Result::type>>
2868  : __or_<is_void<_Ret>,
2869  __and_<is_convertible<typename _Result::type, _Ret>,
2870  is_nothrow_constructible<_Ret, typename _Result::type>>>
2871  { };
2872 
2873  /// std::is_nothrow_invocable_r
2874  template<typename _Ret, typename _Fn, typename... _ArgTypes>
2875  struct is_nothrow_invocable_r
2876  : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>,
2877  __call_is_nothrow_<_Fn, _ArgTypes...>>::type
2878  { };
2879 
2880  /// std::is_invocable_v
2881  template<typename _Fn, typename... _Args>
2882  inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
2883 
2884  /// std::is_nothrow_invocable_v
2885  template<typename _Fn, typename... _Args>
2886  inline constexpr bool is_nothrow_invocable_v
2887  = is_nothrow_invocable<_Fn, _Args...>::value;
2888 
2889  /// std::is_invocable_r_v
2890  template<typename _Fn, typename... _Args>
2891  inline constexpr bool is_invocable_r_v
2892  = is_invocable_r<_Fn, _Args...>::value;
2893 
2894  /// std::is_nothrow_invocable_r_v
2895  template<typename _Fn, typename... _Args>
2896  inline constexpr bool is_nothrow_invocable_r_v
2897  = is_nothrow_invocable_r<_Fn, _Args...>::value;
2898 #endif // C++17
2899 
2900 #if __cplusplus > 201402L
2901 # define __cpp_lib_type_trait_variable_templates 201510L
2902 template <typename _Tp>
2903  inline constexpr bool is_void_v = is_void<_Tp>::value;
2904 template <typename _Tp>
2905  inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
2906 template <typename _Tp>
2907  inline constexpr bool is_integral_v = is_integral<_Tp>::value;
2908 template <typename _Tp>
2909  inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
2910 template <typename _Tp>
2911  inline constexpr bool is_array_v = is_array<_Tp>::value;
2912 template <typename _Tp>
2913  inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
2914 template <typename _Tp>
2915  inline constexpr bool is_lvalue_reference_v =
2916  is_lvalue_reference<_Tp>::value;
2917 template <typename _Tp>
2918  inline constexpr bool is_rvalue_reference_v =
2919  is_rvalue_reference<_Tp>::value;
2920 template <typename _Tp>
2921  inline constexpr bool is_member_object_pointer_v =
2922  is_member_object_pointer<_Tp>::value;
2923 template <typename _Tp>
2924  inline constexpr bool is_member_function_pointer_v =
2925  is_member_function_pointer<_Tp>::value;
2926 template <typename _Tp>
2927  inline constexpr bool is_enum_v = is_enum<_Tp>::value;
2928 template <typename _Tp>
2929  inline constexpr bool is_union_v = is_union<_Tp>::value;
2930 template <typename _Tp>
2931  inline constexpr bool is_class_v = is_class<_Tp>::value;
2932 template <typename _Tp>
2933  inline constexpr bool is_function_v = is_function<_Tp>::value;
2934 template <typename _Tp>
2935  inline constexpr bool is_reference_v = is_reference<_Tp>::value;
2936 template <typename _Tp>
2937  inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
2938 template <typename _Tp>
2939  inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
2940 template <typename _Tp>
2941  inline constexpr bool is_object_v = is_object<_Tp>::value;
2942 template <typename _Tp>
2943  inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
2944 template <typename _Tp>
2945  inline constexpr bool is_compound_v = is_compound<_Tp>::value;
2946 template <typename _Tp>
2947  inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
2948 template <typename _Tp>
2949  inline constexpr bool is_const_v = is_const<_Tp>::value;
2950 template <typename _Tp>
2951  inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
2952 template <typename _Tp>
2953  inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
2954 template <typename _Tp>
2955  inline constexpr bool is_trivially_copyable_v =
2956  is_trivially_copyable<_Tp>::value;
2957 template <typename _Tp>
2958  inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
2959 template <typename _Tp>
2960  inline constexpr bool is_pod_v = is_pod<_Tp>::value;
2961 template <typename _Tp>
2962  inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
2963 template <typename _Tp>
2964  inline constexpr bool is_empty_v = is_empty<_Tp>::value;
2965 template <typename _Tp>
2966  inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
2967 template <typename _Tp>
2968  inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
2969 template <typename _Tp>
2970  inline constexpr bool is_final_v = is_final<_Tp>::value;
2971 template <typename _Tp>
2972  inline constexpr bool is_signed_v = is_signed<_Tp>::value;
2973 template <typename _Tp>
2974  inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
2975 template <typename _Tp, typename... _Args>
2976  inline constexpr bool is_constructible_v =
2977  is_constructible<_Tp, _Args...>::value;
2978 template <typename _Tp>
2979  inline constexpr bool is_default_constructible_v =
2980  is_default_constructible<_Tp>::value;
2981 template <typename _Tp>
2982  inline constexpr bool is_copy_constructible_v =
2983  is_copy_constructible<_Tp>::value;
2984 template <typename _Tp>
2985  inline constexpr bool is_move_constructible_v =
2986  is_move_constructible<_Tp>::value;
2987 template <typename _Tp, typename _Up>
2988  inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
2989 template <typename _Tp>
2990  inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
2991 template <typename _Tp>
2992  inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
2993 template <typename _Tp>
2994  inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
2995 template <typename _Tp, typename... _Args>
2996  inline constexpr bool is_trivially_constructible_v =
2997  is_trivially_constructible<_Tp, _Args...>::value;
2998 template <typename _Tp>
2999  inline constexpr bool is_trivially_default_constructible_v =
3000  is_trivially_default_constructible<_Tp>::value;
3001 template <typename _Tp>
3002  inline constexpr bool is_trivially_copy_constructible_v =
3003  is_trivially_copy_constructible<_Tp>::value;
3004 template <typename _Tp>
3005  inline constexpr bool is_trivially_move_constructible_v =
3006  is_trivially_move_constructible<_Tp>::value;
3007 template <typename _Tp, typename _Up>
3008  inline constexpr bool is_trivially_assignable_v =
3009  is_trivially_assignable<_Tp, _Up>::value;
3010 template <typename _Tp>
3011  inline constexpr bool is_trivially_copy_assignable_v =
3012  is_trivially_copy_assignable<_Tp>::value;
3013 template <typename _Tp>
3014  inline constexpr bool is_trivially_move_assignable_v =
3015  is_trivially_move_assignable<_Tp>::value;
3016 template <typename _Tp>
3017  inline constexpr bool is_trivially_destructible_v =
3018  is_trivially_destructible<_Tp>::value;
3019 template <typename _Tp, typename... _Args>
3020  inline constexpr bool is_nothrow_constructible_v =
3021  is_nothrow_constructible<_Tp, _Args...>::value;
3022 template <typename _Tp>
3023  inline constexpr bool is_nothrow_default_constructible_v =
3024  is_nothrow_default_constructible<_Tp>::value;
3025 template <typename _Tp>
3026  inline constexpr bool is_nothrow_copy_constructible_v =
3027  is_nothrow_copy_constructible<_Tp>::value;
3028 template <typename _Tp>
3029  inline constexpr bool is_nothrow_move_constructible_v =
3030  is_nothrow_move_constructible<_Tp>::value;
3031 template <typename _Tp, typename _Up>
3032  inline constexpr bool is_nothrow_assignable_v =
3033  is_nothrow_assignable<_Tp, _Up>::value;
3034 template <typename _Tp>
3035  inline constexpr bool is_nothrow_copy_assignable_v =
3036  is_nothrow_copy_assignable<_Tp>::value;
3037 template <typename _Tp>
3038  inline constexpr bool is_nothrow_move_assignable_v =
3039  is_nothrow_move_assignable<_Tp>::value;
3040 template <typename _Tp>
3041  inline constexpr bool is_nothrow_destructible_v =
3042  is_nothrow_destructible<_Tp>::value;
3043 template <typename _Tp>
3044  inline constexpr bool has_virtual_destructor_v =
3045  has_virtual_destructor<_Tp>::value;
3046 template <typename _Tp>
3047  inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
3048 template <typename _Tp>
3049  inline constexpr size_t rank_v = rank<_Tp>::value;
3050 template <typename _Tp, unsigned _Idx = 0>
3051  inline constexpr size_t extent_v = extent<_Tp, _Idx>::value;
3052 template <typename _Tp, typename _Up>
3053  inline constexpr bool is_same_v = is_same<_Tp, _Up>::value;
3054 template <typename _Base, typename _Derived>
3055  inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
3056 template <typename _From, typename _To>
3057  inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
3058 
3059 #if __GNUC__ >= 7
3060 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
3061 #elif defined(__is_identifier)
3062 // For non-GNU compilers:
3063 # if ! __is_identifier(__has_unique_object_representations)
3064 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
3065 # endif
3066 #endif
3067 
3068 #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
3069 # define __cpp_lib_has_unique_object_representations 201606
3070  /// has_unique_object_representations
3071  template<typename _Tp>
3072  struct has_unique_object_representations
3073  : bool_constant<__has_unique_object_representations(
3074  remove_cv_t<remove_all_extents_t<_Tp>>
3075  )>
3076  { };
3077 
3078  template<typename _Tp>
3079  inline constexpr bool has_unique_object_representations_v
3080  = has_unique_object_representations<_Tp>::value;
3081 #endif
3082 #undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
3083 
3084 #if __GNUC__ >= 7
3085 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
3086 #elif defined(__is_identifier)
3087 // For non-GNU compilers:
3088 # if ! __is_identifier(__is_aggregate)
3089 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
3090 # endif
3091 #endif
3092 
3093 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
3094 #define __cpp_lib_is_aggregate 201703
3095  /// is_aggregate
3096  template<typename _Tp>
3097  struct is_aggregate
3098  : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { };
3099 
3100  /// is_aggregate_v
3101  template<typename _Tp>
3102  inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
3103 #endif
3104 #undef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
3105 
3106 #endif // C++17
3107 
3108 _GLIBCXX_END_NAMESPACE_VERSION
3109 } // namespace std
3110 
3111 #endif // C++11
3112 
3113 #endif // _GLIBCXX_TYPE_TRAITS