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