Define std::endian for C++2a (P0463R1)
[gcc.git] / libstdc++-v3 / include / std / type_traits
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 /**
758 * @brief Utility to simplify expressions used in unevaluated operands
759 * @ingroup utilities
760 */
761
762 template<typename _Tp, typename _Up = _Tp&&>
763 _Up
764 __declval(int);
765
766 template<typename _Tp>
767 _Tp
768 __declval(long);
769
770 template<typename _Tp>
771 auto declval() noexcept -> decltype(__declval<_Tp>(0));
772
773 template<typename, unsigned = 0>
774 struct extent;
775
776 template<typename>
777 struct remove_all_extents;
778
779 template<typename _Tp>
780 struct __is_array_known_bounds
781 : public integral_constant<bool, (extent<_Tp>::value > 0)>
782 { };
783
784 template<typename _Tp>
785 struct __is_array_unknown_bounds
786 : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>
787 { };
788
789 // In N3290 is_destructible does not say anything about function
790 // types and abstract types, see LWG 2049. This implementation
791 // describes function types as non-destructible and all complete
792 // object types as destructible, iff the explicit destructor
793 // call expression is wellformed.
794 struct __do_is_destructible_impl
795 {
796 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
797 static true_type __test(int);
798
799 template<typename>
800 static false_type __test(...);
801 };
802
803 template<typename _Tp>
804 struct __is_destructible_impl
805 : public __do_is_destructible_impl
806 {
807 typedef decltype(__test<_Tp>(0)) type;
808 };
809
810 template<typename _Tp,
811 bool = __or_<is_void<_Tp>,
812 __is_array_unknown_bounds<_Tp>,
813 is_function<_Tp>>::value,
814 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
815 struct __is_destructible_safe;
816
817 template<typename _Tp>
818 struct __is_destructible_safe<_Tp, false, false>
819 : public __is_destructible_impl<typename
820 remove_all_extents<_Tp>::type>::type
821 { };
822
823 template<typename _Tp>
824 struct __is_destructible_safe<_Tp, true, false>
825 : public false_type { };
826
827 template<typename _Tp>
828 struct __is_destructible_safe<_Tp, false, true>
829 : public true_type { };
830
831 /// is_destructible
832 template<typename _Tp>
833 struct is_destructible
834 : public __is_destructible_safe<_Tp>::type
835 { };
836
837 // is_nothrow_destructible requires that is_destructible is
838 // satisfied as well. We realize that by mimicing the
839 // implementation of is_destructible but refer to noexcept(expr)
840 // instead of decltype(expr).
841 struct __do_is_nt_destructible_impl
842 {
843 template<typename _Tp>
844 static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
845 __test(int);
846
847 template<typename>
848 static false_type __test(...);
849 };
850
851 template<typename _Tp>
852 struct __is_nt_destructible_impl
853 : public __do_is_nt_destructible_impl
854 {
855 typedef decltype(__test<_Tp>(0)) type;
856 };
857
858 template<typename _Tp,
859 bool = __or_<is_void<_Tp>,
860 __is_array_unknown_bounds<_Tp>,
861 is_function<_Tp>>::value,
862 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
863 struct __is_nt_destructible_safe;
864
865 template<typename _Tp>
866 struct __is_nt_destructible_safe<_Tp, false, false>
867 : public __is_nt_destructible_impl<typename
868 remove_all_extents<_Tp>::type>::type
869 { };
870
871 template<typename _Tp>
872 struct __is_nt_destructible_safe<_Tp, true, false>
873 : public false_type { };
874
875 template<typename _Tp>
876 struct __is_nt_destructible_safe<_Tp, false, true>
877 : public true_type { };
878
879 /// is_nothrow_destructible
880 template<typename _Tp>
881 struct is_nothrow_destructible
882 : public __is_nt_destructible_safe<_Tp>::type
883 { };
884
885 struct __do_is_default_constructible_impl
886 {
887 template<typename _Tp, typename = decltype(_Tp())>
888 static true_type __test(int);
889
890 template<typename>
891 static false_type __test(...);
892 };
893
894 template<typename _Tp>
895 struct __is_default_constructible_impl
896 : public __do_is_default_constructible_impl
897 {
898 typedef decltype(__test<_Tp>(0)) type;
899 };
900
901 template<typename _Tp>
902 struct __is_default_constructible_atom
903 : public __and_<__not_<is_void<_Tp>>,
904 __is_default_constructible_impl<_Tp>>
905 { };
906
907 template<typename _Tp, bool = is_array<_Tp>::value>
908 struct __is_default_constructible_safe;
909
910 // The following technique is a workaround for a current core language
911 // restriction, which does not allow for array types to occur in
912 // functional casts of the form T(). Complete arrays can be default-
913 // constructed, if the element type is default-constructible, but
914 // arrays with unknown bounds are not.
915 template<typename _Tp>
916 struct __is_default_constructible_safe<_Tp, true>
917 : public __and_<__is_array_known_bounds<_Tp>,
918 __is_default_constructible_atom<typename
919 remove_all_extents<_Tp>::type>>
920 { };
921
922 template<typename _Tp>
923 struct __is_default_constructible_safe<_Tp, false>
924 : public __is_default_constructible_atom<_Tp>::type
925 { };
926
927 /// is_default_constructible
928 template<typename _Tp>
929 struct is_default_constructible
930 : public __is_default_constructible_safe<_Tp>::type
931 { };
932
933 /// is_constructible
934 template<typename _Tp, typename... _Args>
935 struct is_constructible
936 : public __bool_constant<__is_constructible(_Tp, _Args...)>
937 { };
938
939 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
940 struct __is_copy_constructible_impl;
941
942 template<typename _Tp>
943 struct __is_copy_constructible_impl<_Tp, false>
944 : public false_type { };
945
946 template<typename _Tp>
947 struct __is_copy_constructible_impl<_Tp, true>
948 : public is_constructible<_Tp, const _Tp&>
949 { };
950
951 /// is_copy_constructible
952 template<typename _Tp>
953 struct is_copy_constructible
954 : public __is_copy_constructible_impl<_Tp>
955 { };
956
957 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
958 struct __is_move_constructible_impl;
959
960 template<typename _Tp>
961 struct __is_move_constructible_impl<_Tp, false>
962 : public false_type { };
963
964 template<typename _Tp>
965 struct __is_move_constructible_impl<_Tp, true>
966 : public is_constructible<_Tp, _Tp&&>
967 { };
968
969 /// is_move_constructible
970 template<typename _Tp>
971 struct is_move_constructible
972 : public __is_move_constructible_impl<_Tp>
973 { };
974
975 template<typename _Tp>
976 struct __is_nt_default_constructible_atom
977 : public integral_constant<bool, noexcept(_Tp())>
978 { };
979
980 template<typename _Tp, bool = is_array<_Tp>::value>
981 struct __is_nt_default_constructible_impl;
982
983 template<typename _Tp>
984 struct __is_nt_default_constructible_impl<_Tp, true>
985 : public __and_<__is_array_known_bounds<_Tp>,
986 __is_nt_default_constructible_atom<typename
987 remove_all_extents<_Tp>::type>>
988 { };
989
990 template<typename _Tp>
991 struct __is_nt_default_constructible_impl<_Tp, false>
992 : public __is_nt_default_constructible_atom<_Tp>
993 { };
994
995 /// is_nothrow_default_constructible
996 template<typename _Tp>
997 struct is_nothrow_default_constructible
998 : public __and_<is_default_constructible<_Tp>,
999 __is_nt_default_constructible_impl<_Tp>>
1000 { };
1001
1002 template<typename _Tp, typename... _Args>
1003 struct __is_nt_constructible_impl
1004 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
1005 { };
1006
1007 template<typename _Tp, typename _Arg>
1008 struct __is_nt_constructible_impl<_Tp, _Arg>
1009 : public integral_constant<bool,
1010 noexcept(static_cast<_Tp>(declval<_Arg>()))>
1011 { };
1012
1013 template<typename _Tp>
1014 struct __is_nt_constructible_impl<_Tp>
1015 : public is_nothrow_default_constructible<_Tp>
1016 { };
1017
1018 /// is_nothrow_constructible
1019 template<typename _Tp, typename... _Args>
1020 struct is_nothrow_constructible
1021 : public __and_<is_constructible<_Tp, _Args...>,
1022 __is_nt_constructible_impl<_Tp, _Args...>>
1023 { };
1024
1025 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1026 struct __is_nothrow_copy_constructible_impl;
1027
1028 template<typename _Tp>
1029 struct __is_nothrow_copy_constructible_impl<_Tp, false>
1030 : public false_type { };
1031
1032 template<typename _Tp>
1033 struct __is_nothrow_copy_constructible_impl<_Tp, true>
1034 : public is_nothrow_constructible<_Tp, const _Tp&>
1035 { };
1036
1037 /// is_nothrow_copy_constructible
1038 template<typename _Tp>
1039 struct is_nothrow_copy_constructible
1040 : public __is_nothrow_copy_constructible_impl<_Tp>
1041 { };
1042
1043 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1044 struct __is_nothrow_move_constructible_impl;
1045
1046 template<typename _Tp>
1047 struct __is_nothrow_move_constructible_impl<_Tp, false>
1048 : public false_type { };
1049
1050 template<typename _Tp>
1051 struct __is_nothrow_move_constructible_impl<_Tp, true>
1052 : public is_nothrow_constructible<_Tp, _Tp&&>
1053 { };
1054
1055 /// is_nothrow_move_constructible
1056 template<typename _Tp>
1057 struct is_nothrow_move_constructible
1058 : public __is_nothrow_move_constructible_impl<_Tp>
1059 { };
1060
1061 /// is_assignable
1062 template<typename _Tp, typename _Up>
1063 struct is_assignable
1064 : public __bool_constant<__is_assignable(_Tp, _Up)>
1065 { };
1066
1067 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1068 struct __is_copy_assignable_impl;
1069
1070 template<typename _Tp>
1071 struct __is_copy_assignable_impl<_Tp, false>
1072 : public false_type { };
1073
1074 template<typename _Tp>
1075 struct __is_copy_assignable_impl<_Tp, true>
1076 : public is_assignable<_Tp&, const _Tp&>
1077 { };
1078
1079 /// is_copy_assignable
1080 template<typename _Tp>
1081 struct is_copy_assignable
1082 : public __is_copy_assignable_impl<_Tp>
1083 { };
1084
1085 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1086 struct __is_move_assignable_impl;
1087
1088 template<typename _Tp>
1089 struct __is_move_assignable_impl<_Tp, false>
1090 : public false_type { };
1091
1092 template<typename _Tp>
1093 struct __is_move_assignable_impl<_Tp, true>
1094 : public is_assignable<_Tp&, _Tp&&>
1095 { };
1096
1097 /// is_move_assignable
1098 template<typename _Tp>
1099 struct is_move_assignable
1100 : public __is_move_assignable_impl<_Tp>
1101 { };
1102
1103 template<typename _Tp, typename _Up>
1104 struct __is_nt_assignable_impl
1105 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
1106 { };
1107
1108 /// is_nothrow_assignable
1109 template<typename _Tp, typename _Up>
1110 struct is_nothrow_assignable
1111 : public __and_<is_assignable<_Tp, _Up>,
1112 __is_nt_assignable_impl<_Tp, _Up>>
1113 { };
1114
1115 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1116 struct __is_nt_copy_assignable_impl;
1117
1118 template<typename _Tp>
1119 struct __is_nt_copy_assignable_impl<_Tp, false>
1120 : public false_type { };
1121
1122 template<typename _Tp>
1123 struct __is_nt_copy_assignable_impl<_Tp, true>
1124 : public is_nothrow_assignable<_Tp&, const _Tp&>
1125 { };
1126
1127 /// is_nothrow_copy_assignable
1128 template<typename _Tp>
1129 struct is_nothrow_copy_assignable
1130 : public __is_nt_copy_assignable_impl<_Tp>
1131 { };
1132
1133 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1134 struct __is_nt_move_assignable_impl;
1135
1136 template<typename _Tp>
1137 struct __is_nt_move_assignable_impl<_Tp, false>
1138 : public false_type { };
1139
1140 template<typename _Tp>
1141 struct __is_nt_move_assignable_impl<_Tp, true>
1142 : public is_nothrow_assignable<_Tp&, _Tp&&>
1143 { };
1144
1145 /// is_nothrow_move_assignable
1146 template<typename _Tp>
1147 struct is_nothrow_move_assignable
1148 : public __is_nt_move_assignable_impl<_Tp>
1149 { };
1150
1151 /// is_trivially_constructible
1152 template<typename _Tp, typename... _Args>
1153 struct is_trivially_constructible
1154 : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)>
1155 { };
1156
1157 /// is_trivially_default_constructible
1158 template<typename _Tp>
1159 struct is_trivially_default_constructible
1160 : public is_trivially_constructible<_Tp>::type
1161 { };
1162
1163 struct __do_is_implicitly_default_constructible_impl
1164 {
1165 template <typename _Tp>
1166 static void __helper(const _Tp&);
1167
1168 template <typename _Tp>
1169 static true_type __test(const _Tp&,
1170 decltype(__helper<const _Tp&>({}))* = 0);
1171
1172 static false_type __test(...);
1173 };
1174
1175 template<typename _Tp>
1176 struct __is_implicitly_default_constructible_impl
1177 : public __do_is_implicitly_default_constructible_impl
1178 {
1179 typedef decltype(__test(declval<_Tp>())) type;
1180 };
1181
1182 template<typename _Tp>
1183 struct __is_implicitly_default_constructible_safe
1184 : public __is_implicitly_default_constructible_impl<_Tp>::type
1185 { };
1186
1187 template <typename _Tp>
1188 struct __is_implicitly_default_constructible
1189 : public __and_<is_default_constructible<_Tp>,
1190 __is_implicitly_default_constructible_safe<_Tp>>
1191 { };
1192
1193 /// is_trivially_copy_constructible
1194
1195 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1196 struct __is_trivially_copy_constructible_impl;
1197
1198 template<typename _Tp>
1199 struct __is_trivially_copy_constructible_impl<_Tp, false>
1200 : public false_type { };
1201
1202 template<typename _Tp>
1203 struct __is_trivially_copy_constructible_impl<_Tp, true>
1204 : public __and_<is_copy_constructible<_Tp>,
1205 integral_constant<bool,
1206 __is_trivially_constructible(_Tp, const _Tp&)>>
1207 { };
1208
1209 template<typename _Tp>
1210 struct is_trivially_copy_constructible
1211 : public __is_trivially_copy_constructible_impl<_Tp>
1212 { };
1213
1214 /// is_trivially_move_constructible
1215
1216 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1217 struct __is_trivially_move_constructible_impl;
1218
1219 template<typename _Tp>
1220 struct __is_trivially_move_constructible_impl<_Tp, false>
1221 : public false_type { };
1222
1223 template<typename _Tp>
1224 struct __is_trivially_move_constructible_impl<_Tp, true>
1225 : public __and_<is_move_constructible<_Tp>,
1226 integral_constant<bool,
1227 __is_trivially_constructible(_Tp, _Tp&&)>>
1228 { };
1229
1230 template<typename _Tp>
1231 struct is_trivially_move_constructible
1232 : public __is_trivially_move_constructible_impl<_Tp>
1233 { };
1234
1235 /// is_trivially_assignable
1236 template<typename _Tp, typename _Up>
1237 struct is_trivially_assignable
1238 : public __bool_constant<__is_trivially_assignable(_Tp, _Up)>
1239 { };
1240
1241 /// is_trivially_copy_assignable
1242
1243 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1244 struct __is_trivially_copy_assignable_impl;
1245
1246 template<typename _Tp>
1247 struct __is_trivially_copy_assignable_impl<_Tp, false>
1248 : public false_type { };
1249
1250 template<typename _Tp>
1251 struct __is_trivially_copy_assignable_impl<_Tp, true>
1252 : public __and_<is_copy_assignable<_Tp>,
1253 integral_constant<bool,
1254 __is_trivially_assignable(_Tp&, const _Tp&)>>
1255 { };
1256
1257 template<typename _Tp>
1258 struct is_trivially_copy_assignable
1259 : public __is_trivially_copy_assignable_impl<_Tp>
1260 { };
1261
1262 /// is_trivially_move_assignable
1263
1264 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1265 struct __is_trivially_move_assignable_impl;
1266
1267 template<typename _Tp>
1268 struct __is_trivially_move_assignable_impl<_Tp, false>
1269 : public false_type { };
1270
1271 template<typename _Tp>
1272 struct __is_trivially_move_assignable_impl<_Tp, true>
1273 : public __and_<is_move_assignable<_Tp>,
1274 integral_constant<bool,
1275 __is_trivially_assignable(_Tp&, _Tp&&)>>
1276 { };
1277
1278 template<typename _Tp>
1279 struct is_trivially_move_assignable
1280 : public __is_trivially_move_assignable_impl<_Tp>
1281 { };
1282
1283 /// is_trivially_destructible
1284 template<typename _Tp>
1285 struct is_trivially_destructible
1286 : public __and_<is_destructible<_Tp>, integral_constant<bool,
1287 __has_trivial_destructor(_Tp)>>
1288 { };
1289
1290
1291 /// has_virtual_destructor
1292 template<typename _Tp>
1293 struct has_virtual_destructor
1294 : public integral_constant<bool, __has_virtual_destructor(_Tp)>
1295 { };
1296
1297
1298 // type property queries.
1299
1300 /// alignment_of
1301 template<typename _Tp>
1302 struct alignment_of
1303 : public integral_constant<std::size_t, __alignof__(_Tp)> { };
1304
1305 /// rank
1306 template<typename>
1307 struct rank
1308 : public integral_constant<std::size_t, 0> { };
1309
1310 template<typename _Tp, std::size_t _Size>
1311 struct rank<_Tp[_Size]>
1312 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1313
1314 template<typename _Tp>
1315 struct rank<_Tp[]>
1316 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1317
1318 /// extent
1319 template<typename, unsigned _Uint>
1320 struct extent
1321 : public integral_constant<std::size_t, 0> { };
1322
1323 template<typename _Tp, unsigned _Uint, std::size_t _Size>
1324 struct extent<_Tp[_Size], _Uint>
1325 : public integral_constant<std::size_t,
1326 _Uint == 0 ? _Size : extent<_Tp,
1327 _Uint - 1>::value>
1328 { };
1329
1330 template<typename _Tp, unsigned _Uint>
1331 struct extent<_Tp[], _Uint>
1332 : public integral_constant<std::size_t,
1333 _Uint == 0 ? 0 : extent<_Tp,
1334 _Uint - 1>::value>
1335 { };
1336
1337
1338 // Type relations.
1339
1340 /// is_same
1341 template<typename, typename>
1342 struct is_same
1343 : public false_type { };
1344
1345 template<typename _Tp>
1346 struct is_same<_Tp, _Tp>
1347 : public true_type { };
1348
1349 /// is_base_of
1350 template<typename _Base, typename _Derived>
1351 struct is_base_of
1352 : public integral_constant<bool, __is_base_of(_Base, _Derived)>
1353 { };
1354
1355 template<typename _From, typename _To,
1356 bool = __or_<is_void<_From>, is_function<_To>,
1357 is_array<_To>>::value>
1358 struct __is_convertible_helper
1359 { typedef typename is_void<_To>::type type; };
1360
1361 template<typename _From, typename _To>
1362 class __is_convertible_helper<_From, _To, false>
1363 {
1364 template<typename _To1>
1365 static void __test_aux(_To1);
1366
1367 template<typename _From1, typename _To1,
1368 typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
1369 static true_type
1370 __test(int);
1371
1372 template<typename, typename>
1373 static false_type
1374 __test(...);
1375
1376 public:
1377 typedef decltype(__test<_From, _To>(0)) type;
1378 };
1379
1380
1381 /// is_convertible
1382 template<typename _From, typename _To>
1383 struct is_convertible
1384 : public __is_convertible_helper<_From, _To>::type
1385 { };
1386
1387
1388 // Const-volatile modifications.
1389
1390 /// remove_const
1391 template<typename _Tp>
1392 struct remove_const
1393 { typedef _Tp type; };
1394
1395 template<typename _Tp>
1396 struct remove_const<_Tp const>
1397 { typedef _Tp type; };
1398
1399 /// remove_volatile
1400 template<typename _Tp>
1401 struct remove_volatile
1402 { typedef _Tp type; };
1403
1404 template<typename _Tp>
1405 struct remove_volatile<_Tp volatile>
1406 { typedef _Tp type; };
1407
1408 /// remove_cv
1409 template<typename _Tp>
1410 struct remove_cv
1411 {
1412 typedef typename
1413 remove_const<typename remove_volatile<_Tp>::type>::type type;
1414 };
1415
1416 /// add_const
1417 template<typename _Tp>
1418 struct add_const
1419 { typedef _Tp const type; };
1420
1421 /// add_volatile
1422 template<typename _Tp>
1423 struct add_volatile
1424 { typedef _Tp volatile type; };
1425
1426 /// add_cv
1427 template<typename _Tp>
1428 struct add_cv
1429 {
1430 typedef typename
1431 add_const<typename add_volatile<_Tp>::type>::type type;
1432 };
1433
1434 #if __cplusplus > 201103L
1435
1436 #define __cpp_lib_transformation_trait_aliases 201304
1437
1438 /// Alias template for remove_const
1439 template<typename _Tp>
1440 using remove_const_t = typename remove_const<_Tp>::type;
1441
1442 /// Alias template for remove_volatile
1443 template<typename _Tp>
1444 using remove_volatile_t = typename remove_volatile<_Tp>::type;
1445
1446 /// Alias template for remove_cv
1447 template<typename _Tp>
1448 using remove_cv_t = typename remove_cv<_Tp>::type;
1449
1450 /// Alias template for add_const
1451 template<typename _Tp>
1452 using add_const_t = typename add_const<_Tp>::type;
1453
1454 /// Alias template for add_volatile
1455 template<typename _Tp>
1456 using add_volatile_t = typename add_volatile<_Tp>::type;
1457
1458 /// Alias template for add_cv
1459 template<typename _Tp>
1460 using add_cv_t = typename add_cv<_Tp>::type;
1461 #endif
1462
1463 // Reference transformations.
1464
1465 /// remove_reference
1466 template<typename _Tp>
1467 struct remove_reference
1468 { typedef _Tp type; };
1469
1470 template<typename _Tp>
1471 struct remove_reference<_Tp&>
1472 { typedef _Tp type; };
1473
1474 template<typename _Tp>
1475 struct remove_reference<_Tp&&>
1476 { typedef _Tp type; };
1477
1478 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1479 struct __add_lvalue_reference_helper
1480 { typedef _Tp type; };
1481
1482 template<typename _Tp>
1483 struct __add_lvalue_reference_helper<_Tp, true>
1484 { typedef _Tp& type; };
1485
1486 /// add_lvalue_reference
1487 template<typename _Tp>
1488 struct add_lvalue_reference
1489 : public __add_lvalue_reference_helper<_Tp>
1490 { };
1491
1492 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1493 struct __add_rvalue_reference_helper
1494 { typedef _Tp type; };
1495
1496 template<typename _Tp>
1497 struct __add_rvalue_reference_helper<_Tp, true>
1498 { typedef _Tp&& type; };
1499
1500 /// add_rvalue_reference
1501 template<typename _Tp>
1502 struct add_rvalue_reference
1503 : public __add_rvalue_reference_helper<_Tp>
1504 { };
1505
1506 #if __cplusplus > 201103L
1507 /// Alias template for remove_reference
1508 template<typename _Tp>
1509 using remove_reference_t = typename remove_reference<_Tp>::type;
1510
1511 /// Alias template for add_lvalue_reference
1512 template<typename _Tp>
1513 using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1514
1515 /// Alias template for add_rvalue_reference
1516 template<typename _Tp>
1517 using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1518 #endif
1519
1520 // Sign modifications.
1521
1522 // Utility for constructing identically cv-qualified types.
1523 template<typename _Unqualified, bool _IsConst, bool _IsVol>
1524 struct __cv_selector;
1525
1526 template<typename _Unqualified>
1527 struct __cv_selector<_Unqualified, false, false>
1528 { typedef _Unqualified __type; };
1529
1530 template<typename _Unqualified>
1531 struct __cv_selector<_Unqualified, false, true>
1532 { typedef volatile _Unqualified __type; };
1533
1534 template<typename _Unqualified>
1535 struct __cv_selector<_Unqualified, true, false>
1536 { typedef const _Unqualified __type; };
1537
1538 template<typename _Unqualified>
1539 struct __cv_selector<_Unqualified, true, true>
1540 { typedef const volatile _Unqualified __type; };
1541
1542 template<typename _Qualified, typename _Unqualified,
1543 bool _IsConst = is_const<_Qualified>::value,
1544 bool _IsVol = is_volatile<_Qualified>::value>
1545 class __match_cv_qualifiers
1546 {
1547 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1548
1549 public:
1550 typedef typename __match::__type __type;
1551 };
1552
1553 // Utility for finding the unsigned versions of signed integral types.
1554 template<typename _Tp>
1555 struct __make_unsigned
1556 { typedef _Tp __type; };
1557
1558 template<>
1559 struct __make_unsigned<char>
1560 { typedef unsigned char __type; };
1561
1562 template<>
1563 struct __make_unsigned<signed char>
1564 { typedef unsigned char __type; };
1565
1566 template<>
1567 struct __make_unsigned<short>
1568 { typedef unsigned short __type; };
1569
1570 template<>
1571 struct __make_unsigned<int>
1572 { typedef unsigned int __type; };
1573
1574 template<>
1575 struct __make_unsigned<long>
1576 { typedef unsigned long __type; };
1577
1578 template<>
1579 struct __make_unsigned<long long>
1580 { typedef unsigned long long __type; };
1581
1582 #if defined(_GLIBCXX_USE_WCHAR_T) && !defined(__WCHAR_UNSIGNED__)
1583 template<>
1584 struct __make_unsigned<wchar_t> : __make_unsigned<__WCHAR_TYPE__>
1585 { };
1586 #endif
1587
1588 #if defined(__GLIBCXX_TYPE_INT_N_0)
1589 template<>
1590 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
1591 { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; };
1592 #endif
1593 #if defined(__GLIBCXX_TYPE_INT_N_1)
1594 template<>
1595 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
1596 { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; };
1597 #endif
1598 #if defined(__GLIBCXX_TYPE_INT_N_2)
1599 template<>
1600 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
1601 { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; };
1602 #endif
1603 #if defined(__GLIBCXX_TYPE_INT_N_3)
1604 template<>
1605 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
1606 { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; };
1607 #endif
1608
1609 // Select between integral and enum: not possible to be both.
1610 template<typename _Tp,
1611 bool _IsInt = is_integral<_Tp>::value,
1612 bool _IsEnum = is_enum<_Tp>::value>
1613 class __make_unsigned_selector;
1614
1615 template<typename _Tp>
1616 class __make_unsigned_selector<_Tp, true, false>
1617 {
1618 typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt;
1619 typedef typename __unsignedt::__type __unsigned_type;
1620 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1621
1622 public:
1623 typedef typename __cv_unsigned::__type __type;
1624 };
1625
1626 template<typename _Tp>
1627 class __make_unsigned_selector<_Tp, false, true>
1628 {
1629 // With -fshort-enums, an enum may be as small as a char.
1630 typedef unsigned char __smallest;
1631 static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1632 static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short);
1633 static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int);
1634 static const bool __b3 = sizeof(_Tp) <= sizeof(unsigned long);
1635 typedef conditional<__b3, unsigned long, unsigned long long> __cond3;
1636 typedef typename __cond3::type __cond3_type;
1637 typedef conditional<__b2, unsigned int, __cond3_type> __cond2;
1638 typedef typename __cond2::type __cond2_type;
1639 typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
1640 typedef typename __cond1::type __cond1_type;
1641
1642 typedef typename conditional<__b0, __smallest, __cond1_type>::type
1643 __unsigned_type;
1644 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1645
1646 public:
1647 typedef typename __cv_unsigned::__type __type;
1648 };
1649
1650 // Given an integral/enum type, return the corresponding unsigned
1651 // integer type.
1652 // Primary template.
1653 /// make_unsigned
1654 template<typename _Tp>
1655 struct make_unsigned
1656 { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1657
1658 // Integral, but don't define.
1659 template<>
1660 struct make_unsigned<bool>;
1661
1662
1663 // Utility for finding the signed versions of unsigned integral types.
1664 template<typename _Tp>
1665 struct __make_signed
1666 { typedef _Tp __type; };
1667
1668 template<>
1669 struct __make_signed<char>
1670 { typedef signed char __type; };
1671
1672 template<>
1673 struct __make_signed<unsigned char>
1674 { typedef signed char __type; };
1675
1676 template<>
1677 struct __make_signed<unsigned short>
1678 { typedef signed short __type; };
1679
1680 template<>
1681 struct __make_signed<unsigned int>
1682 { typedef signed int __type; };
1683
1684 template<>
1685 struct __make_signed<unsigned long>
1686 { typedef signed long __type; };
1687
1688 template<>
1689 struct __make_signed<unsigned long long>
1690 { typedef signed long long __type; };
1691
1692 #if defined(_GLIBCXX_USE_WCHAR_T) && defined(__WCHAR_UNSIGNED__)
1693 template<>
1694 struct __make_signed<wchar_t> : __make_signed<__WCHAR_TYPE__>
1695 { };
1696 #endif
1697
1698 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
1699 template<>
1700 struct __make_signed<char16_t> : __make_signed<uint_least16_t>
1701 { };
1702 template<>
1703 struct __make_signed<char32_t> : __make_signed<uint_least32_t>
1704 { };
1705 #endif
1706
1707 #if defined(__GLIBCXX_TYPE_INT_N_0)
1708 template<>
1709 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
1710 { typedef __GLIBCXX_TYPE_INT_N_0 __type; };
1711 #endif
1712 #if defined(__GLIBCXX_TYPE_INT_N_1)
1713 template<>
1714 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
1715 { typedef __GLIBCXX_TYPE_INT_N_1 __type; };
1716 #endif
1717 #if defined(__GLIBCXX_TYPE_INT_N_2)
1718 template<>
1719 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
1720 { typedef __GLIBCXX_TYPE_INT_N_2 __type; };
1721 #endif
1722 #if defined(__GLIBCXX_TYPE_INT_N_3)
1723 template<>
1724 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
1725 { typedef __GLIBCXX_TYPE_INT_N_3 __type; };
1726 #endif
1727
1728 // Select between integral and enum: not possible to be both.
1729 template<typename _Tp,
1730 bool _IsInt = is_integral<_Tp>::value,
1731 bool _IsEnum = is_enum<_Tp>::value>
1732 class __make_signed_selector;
1733
1734 template<typename _Tp>
1735 class __make_signed_selector<_Tp, true, false>
1736 {
1737 typedef __make_signed<typename remove_cv<_Tp>::type> __signedt;
1738 typedef typename __signedt::__type __signed_type;
1739 typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed;
1740
1741 public:
1742 typedef typename __cv_signed::__type __type;
1743 };
1744
1745 template<typename _Tp>
1746 class __make_signed_selector<_Tp, false, true>
1747 {
1748 typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type;
1749
1750 public:
1751 typedef typename __make_signed_selector<__unsigned_type>::__type __type;
1752 };
1753
1754 // Given an integral/enum type, return the corresponding signed
1755 // integer type.
1756 // Primary template.
1757 /// make_signed
1758 template<typename _Tp>
1759 struct make_signed
1760 { typedef typename __make_signed_selector<_Tp>::__type type; };
1761
1762 // Integral, but don't define.
1763 template<>
1764 struct make_signed<bool>;
1765
1766 #if __cplusplus > 201103L
1767 /// Alias template for make_signed
1768 template<typename _Tp>
1769 using make_signed_t = typename make_signed<_Tp>::type;
1770
1771 /// Alias template for make_unsigned
1772 template<typename _Tp>
1773 using make_unsigned_t = typename make_unsigned<_Tp>::type;
1774 #endif
1775
1776 // Array modifications.
1777
1778 /// remove_extent
1779 template<typename _Tp>
1780 struct remove_extent
1781 { typedef _Tp type; };
1782
1783 template<typename _Tp, std::size_t _Size>
1784 struct remove_extent<_Tp[_Size]>
1785 { typedef _Tp type; };
1786
1787 template<typename _Tp>
1788 struct remove_extent<_Tp[]>
1789 { typedef _Tp type; };
1790
1791 /// remove_all_extents
1792 template<typename _Tp>
1793 struct remove_all_extents
1794 { typedef _Tp type; };
1795
1796 template<typename _Tp, std::size_t _Size>
1797 struct remove_all_extents<_Tp[_Size]>
1798 { typedef typename remove_all_extents<_Tp>::type type; };
1799
1800 template<typename _Tp>
1801 struct remove_all_extents<_Tp[]>
1802 { typedef typename remove_all_extents<_Tp>::type type; };
1803
1804 #if __cplusplus > 201103L
1805 /// Alias template for remove_extent
1806 template<typename _Tp>
1807 using remove_extent_t = typename remove_extent<_Tp>::type;
1808
1809 /// Alias template for remove_all_extents
1810 template<typename _Tp>
1811 using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1812 #endif
1813
1814 // Pointer modifications.
1815
1816 template<typename _Tp, typename>
1817 struct __remove_pointer_helper
1818 { typedef _Tp type; };
1819
1820 template<typename _Tp, typename _Up>
1821 struct __remove_pointer_helper<_Tp, _Up*>
1822 { typedef _Up type; };
1823
1824 /// remove_pointer
1825 template<typename _Tp>
1826 struct remove_pointer
1827 : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1828 { };
1829
1830 /// add_pointer
1831 template<typename _Tp, bool = __or_<__is_referenceable<_Tp>,
1832 is_void<_Tp>>::value>
1833 struct __add_pointer_helper
1834 { typedef _Tp type; };
1835
1836 template<typename _Tp>
1837 struct __add_pointer_helper<_Tp, true>
1838 { typedef typename remove_reference<_Tp>::type* type; };
1839
1840 template<typename _Tp>
1841 struct add_pointer
1842 : public __add_pointer_helper<_Tp>
1843 { };
1844
1845 #if __cplusplus > 201103L
1846 /// Alias template for remove_pointer
1847 template<typename _Tp>
1848 using remove_pointer_t = typename remove_pointer<_Tp>::type;
1849
1850 /// Alias template for add_pointer
1851 template<typename _Tp>
1852 using add_pointer_t = typename add_pointer<_Tp>::type;
1853 #endif
1854
1855 template<std::size_t _Len>
1856 struct __aligned_storage_msa
1857 {
1858 union __type
1859 {
1860 unsigned char __data[_Len];
1861 struct __attribute__((__aligned__)) { } __align;
1862 };
1863 };
1864
1865 /**
1866 * @brief Alignment type.
1867 *
1868 * The value of _Align is a default-alignment which shall be the
1869 * most stringent alignment requirement for any C++ object type
1870 * whose size is no greater than _Len (3.9). The member typedef
1871 * type shall be a POD type suitable for use as uninitialized
1872 * storage for any object whose size is at most _Len and whose
1873 * alignment is a divisor of _Align.
1874 */
1875 template<std::size_t _Len, std::size_t _Align =
1876 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
1877 struct aligned_storage
1878 {
1879 union type
1880 {
1881 unsigned char __data[_Len];
1882 struct __attribute__((__aligned__((_Align)))) { } __align;
1883 };
1884 };
1885
1886 template <typename... _Types>
1887 struct __strictest_alignment
1888 {
1889 static const size_t _S_alignment = 0;
1890 static const size_t _S_size = 0;
1891 };
1892
1893 template <typename _Tp, typename... _Types>
1894 struct __strictest_alignment<_Tp, _Types...>
1895 {
1896 static const size_t _S_alignment =
1897 alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment
1898 ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment;
1899 static const size_t _S_size =
1900 sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size
1901 ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size;
1902 };
1903
1904 /**
1905 * @brief Provide aligned storage for types.
1906 *
1907 * [meta.trans.other]
1908 *
1909 * Provides aligned storage for any of the provided types of at
1910 * least size _Len.
1911 *
1912 * @see aligned_storage
1913 */
1914 template <size_t _Len, typename... _Types>
1915 struct aligned_union
1916 {
1917 private:
1918 static_assert(sizeof...(_Types) != 0, "At least one type is required");
1919
1920 using __strictest = __strictest_alignment<_Types...>;
1921 static const size_t _S_len = _Len > __strictest::_S_size
1922 ? _Len : __strictest::_S_size;
1923 public:
1924 /// The value of the strictest alignment of _Types.
1925 static const size_t alignment_value = __strictest::_S_alignment;
1926 /// The storage.
1927 typedef typename aligned_storage<_S_len, alignment_value>::type type;
1928 };
1929
1930 template <size_t _Len, typename... _Types>
1931 const size_t aligned_union<_Len, _Types...>::alignment_value;
1932
1933 // Decay trait for arrays and functions, used for perfect forwarding
1934 // in make_pair, make_tuple, etc.
1935 template<typename _Up,
1936 bool _IsArray = is_array<_Up>::value,
1937 bool _IsFunction = is_function<_Up>::value>
1938 struct __decay_selector;
1939
1940 // NB: DR 705.
1941 template<typename _Up>
1942 struct __decay_selector<_Up, false, false>
1943 { typedef typename remove_cv<_Up>::type __type; };
1944
1945 template<typename _Up>
1946 struct __decay_selector<_Up, true, false>
1947 { typedef typename remove_extent<_Up>::type* __type; };
1948
1949 template<typename _Up>
1950 struct __decay_selector<_Up, false, true>
1951 { typedef typename add_pointer<_Up>::type __type; };
1952
1953 /// decay
1954 template<typename _Tp>
1955 class decay
1956 {
1957 typedef typename remove_reference<_Tp>::type __remove_type;
1958
1959 public:
1960 typedef typename __decay_selector<__remove_type>::__type type;
1961 };
1962
1963 template<typename _Tp>
1964 class reference_wrapper;
1965
1966 // Helper which adds a reference to a type when given a reference_wrapper
1967 template<typename _Tp>
1968 struct __strip_reference_wrapper
1969 {
1970 typedef _Tp __type;
1971 };
1972
1973 template<typename _Tp>
1974 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
1975 {
1976 typedef _Tp& __type;
1977 };
1978
1979 template<typename _Tp>
1980 struct __decay_and_strip
1981 {
1982 typedef typename __strip_reference_wrapper<
1983 typename decay<_Tp>::type>::__type __type;
1984 };
1985
1986
1987 // Primary template.
1988 /// Define a member typedef @c type only if a boolean constant is true.
1989 template<bool, typename _Tp = void>
1990 struct enable_if
1991 { };
1992
1993 // Partial specialization for true.
1994 template<typename _Tp>
1995 struct enable_if<true, _Tp>
1996 { typedef _Tp type; };
1997
1998 template<typename... _Cond>
1999 using _Require = typename enable_if<__and_<_Cond...>::value>::type;
2000
2001 // Primary template.
2002 /// Define a member typedef @c type to one of two argument types.
2003 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2004 struct conditional
2005 { typedef _Iftrue type; };
2006
2007 // Partial specialization for false.
2008 template<typename _Iftrue, typename _Iffalse>
2009 struct conditional<false, _Iftrue, _Iffalse>
2010 { typedef _Iffalse type; };
2011
2012 /// common_type
2013 template<typename... _Tp>
2014 struct common_type;
2015
2016 // Sfinae-friendly common_type implementation:
2017
2018 struct __do_common_type_impl
2019 {
2020 template<typename _Tp, typename _Up>
2021 static __success_type<typename decay<decltype
2022 (true ? std::declval<_Tp>()
2023 : std::declval<_Up>())>::type> _S_test(int);
2024
2025 template<typename, typename>
2026 static __failure_type _S_test(...);
2027 };
2028
2029 template<typename _Tp, typename _Up>
2030 struct __common_type_impl
2031 : private __do_common_type_impl
2032 {
2033 typedef decltype(_S_test<_Tp, _Up>(0)) type;
2034 };
2035
2036 struct __do_member_type_wrapper
2037 {
2038 template<typename _Tp>
2039 static __success_type<typename _Tp::type> _S_test(int);
2040
2041 template<typename>
2042 static __failure_type _S_test(...);
2043 };
2044
2045 template<typename _Tp>
2046 struct __member_type_wrapper
2047 : private __do_member_type_wrapper
2048 {
2049 typedef decltype(_S_test<_Tp>(0)) type;
2050 };
2051
2052 template<typename _CTp, typename... _Args>
2053 struct __expanded_common_type_wrapper
2054 {
2055 typedef common_type<typename _CTp::type, _Args...> type;
2056 };
2057
2058 template<typename... _Args>
2059 struct __expanded_common_type_wrapper<__failure_type, _Args...>
2060 { typedef __failure_type type; };
2061
2062 template<typename _Tp>
2063 struct common_type<_Tp>
2064 { typedef typename decay<_Tp>::type type; };
2065
2066 template<typename _Tp, typename _Up>
2067 struct common_type<_Tp, _Up>
2068 : public __common_type_impl<_Tp, _Up>::type
2069 { };
2070
2071 template<typename _Tp, typename _Up, typename... _Vp>
2072 struct common_type<_Tp, _Up, _Vp...>
2073 : public __expanded_common_type_wrapper<typename __member_type_wrapper<
2074 common_type<_Tp, _Up>>::type, _Vp...>::type
2075 { };
2076
2077 /// The underlying type of an enum.
2078 template<typename _Tp>
2079 struct underlying_type
2080 {
2081 typedef __underlying_type(_Tp) type;
2082 };
2083
2084 template<typename _Tp>
2085 struct __declval_protector
2086 {
2087 static const bool __stop = false;
2088 };
2089
2090 template<typename _Tp>
2091 auto declval() noexcept -> decltype(__declval<_Tp>(0))
2092 {
2093 static_assert(__declval_protector<_Tp>::__stop,
2094 "declval() must not be used!");
2095 return __declval<_Tp>(0);
2096 }
2097
2098 /// result_of
2099 template<typename _Signature>
2100 class result_of;
2101
2102 // Sfinae-friendly result_of implementation:
2103
2104 #define __cpp_lib_result_of_sfinae 201210
2105
2106 struct __invoke_memfun_ref { };
2107 struct __invoke_memfun_deref { };
2108 struct __invoke_memobj_ref { };
2109 struct __invoke_memobj_deref { };
2110 struct __invoke_other { };
2111
2112 // Associate a tag type with a specialization of __success_type.
2113 template<typename _Tp, typename _Tag>
2114 struct __result_of_success : __success_type<_Tp>
2115 { using __invoke_type = _Tag; };
2116
2117 // [func.require] paragraph 1 bullet 1:
2118 struct __result_of_memfun_ref_impl
2119 {
2120 template<typename _Fp, typename _Tp1, typename... _Args>
2121 static __result_of_success<decltype(
2122 (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
2123 ), __invoke_memfun_ref> _S_test(int);
2124
2125 template<typename...>
2126 static __failure_type _S_test(...);
2127 };
2128
2129 template<typename _MemPtr, typename _Arg, typename... _Args>
2130 struct __result_of_memfun_ref
2131 : private __result_of_memfun_ref_impl
2132 {
2133 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2134 };
2135
2136 // [func.require] paragraph 1 bullet 2:
2137 struct __result_of_memfun_deref_impl
2138 {
2139 template<typename _Fp, typename _Tp1, typename... _Args>
2140 static __result_of_success<decltype(
2141 ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
2142 ), __invoke_memfun_deref> _S_test(int);
2143
2144 template<typename...>
2145 static __failure_type _S_test(...);
2146 };
2147
2148 template<typename _MemPtr, typename _Arg, typename... _Args>
2149 struct __result_of_memfun_deref
2150 : private __result_of_memfun_deref_impl
2151 {
2152 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2153 };
2154
2155 // [func.require] paragraph 1 bullet 3:
2156 struct __result_of_memobj_ref_impl
2157 {
2158 template<typename _Fp, typename _Tp1>
2159 static __result_of_success<decltype(
2160 std::declval<_Tp1>().*std::declval<_Fp>()
2161 ), __invoke_memobj_ref> _S_test(int);
2162
2163 template<typename, typename>
2164 static __failure_type _S_test(...);
2165 };
2166
2167 template<typename _MemPtr, typename _Arg>
2168 struct __result_of_memobj_ref
2169 : private __result_of_memobj_ref_impl
2170 {
2171 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2172 };
2173
2174 // [func.require] paragraph 1 bullet 4:
2175 struct __result_of_memobj_deref_impl
2176 {
2177 template<typename _Fp, typename _Tp1>
2178 static __result_of_success<decltype(
2179 (*std::declval<_Tp1>()).*std::declval<_Fp>()
2180 ), __invoke_memobj_deref> _S_test(int);
2181
2182 template<typename, typename>
2183 static __failure_type _S_test(...);
2184 };
2185
2186 template<typename _MemPtr, typename _Arg>
2187 struct __result_of_memobj_deref
2188 : private __result_of_memobj_deref_impl
2189 {
2190 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2191 };
2192
2193 template<typename _MemPtr, typename _Arg>
2194 struct __result_of_memobj;
2195
2196 template<typename _Res, typename _Class, typename _Arg>
2197 struct __result_of_memobj<_Res _Class::*, _Arg>
2198 {
2199 typedef typename remove_cv<typename remove_reference<
2200 _Arg>::type>::type _Argval;
2201 typedef _Res _Class::* _MemPtr;
2202 typedef typename conditional<__or_<is_same<_Argval, _Class>,
2203 is_base_of<_Class, _Argval>>::value,
2204 __result_of_memobj_ref<_MemPtr, _Arg>,
2205 __result_of_memobj_deref<_MemPtr, _Arg>
2206 >::type::type type;
2207 };
2208
2209 template<typename _MemPtr, typename _Arg, typename... _Args>
2210 struct __result_of_memfun;
2211
2212 template<typename _Res, typename _Class, typename _Arg, typename... _Args>
2213 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
2214 {
2215 typedef typename remove_cv<typename remove_reference<
2216 _Arg>::type>::type _Argval;
2217 typedef _Res _Class::* _MemPtr;
2218 typedef typename conditional<__or_<is_same<_Argval, _Class>,
2219 is_base_of<_Class, _Argval>>::value,
2220 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
2221 __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
2222 >::type::type type;
2223 };
2224
2225 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2226 // 2219. INVOKE-ing a pointer to member with a reference_wrapper
2227 // as the object expression
2228
2229 // Used by result_of, invoke etc. to unwrap a reference_wrapper.
2230 template<typename _Tp, typename _Up = typename decay<_Tp>::type>
2231 struct __inv_unwrap
2232 {
2233 using type = _Tp;
2234 };
2235
2236 template<typename _Tp, typename _Up>
2237 struct __inv_unwrap<_Tp, reference_wrapper<_Up>>
2238 {
2239 using type = _Up&;
2240 };
2241
2242 template<bool, bool, typename _Functor, typename... _ArgTypes>
2243 struct __result_of_impl
2244 {
2245 typedef __failure_type type;
2246 };
2247
2248 template<typename _MemPtr, typename _Arg>
2249 struct __result_of_impl<true, false, _MemPtr, _Arg>
2250 : public __result_of_memobj<typename decay<_MemPtr>::type,
2251 typename __inv_unwrap<_Arg>::type>
2252 { };
2253
2254 template<typename _MemPtr, typename _Arg, typename... _Args>
2255 struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
2256 : public __result_of_memfun<typename decay<_MemPtr>::type,
2257 typename __inv_unwrap<_Arg>::type, _Args...>
2258 { };
2259
2260 // [func.require] paragraph 1 bullet 5:
2261 struct __result_of_other_impl
2262 {
2263 template<typename _Fn, typename... _Args>
2264 static __result_of_success<decltype(
2265 std::declval<_Fn>()(std::declval<_Args>()...)
2266 ), __invoke_other> _S_test(int);
2267
2268 template<typename...>
2269 static __failure_type _S_test(...);
2270 };
2271
2272 template<typename _Functor, typename... _ArgTypes>
2273 struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2274 : private __result_of_other_impl
2275 {
2276 typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
2277 };
2278
2279 // __invoke_result (std::invoke_result for C++11)
2280 template<typename _Functor, typename... _ArgTypes>
2281 struct __invoke_result
2282 : public __result_of_impl<
2283 is_member_object_pointer<
2284 typename remove_reference<_Functor>::type
2285 >::value,
2286 is_member_function_pointer<
2287 typename remove_reference<_Functor>::type
2288 >::value,
2289 _Functor, _ArgTypes...
2290 >::type
2291 { };
2292
2293 template<typename _Functor, typename... _ArgTypes>
2294 struct result_of<_Functor(_ArgTypes...)>
2295 : public __invoke_result<_Functor, _ArgTypes...>
2296 { };
2297
2298 #if __cplusplus > 201103L
2299 /// Alias template for aligned_storage
2300 template<size_t _Len, size_t _Align =
2301 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
2302 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
2303
2304 template <size_t _Len, typename... _Types>
2305 using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
2306
2307 /// Alias template for decay
2308 template<typename _Tp>
2309 using decay_t = typename decay<_Tp>::type;
2310
2311 /// Alias template for enable_if
2312 template<bool _Cond, typename _Tp = void>
2313 using enable_if_t = typename enable_if<_Cond, _Tp>::type;
2314
2315 /// Alias template for conditional
2316 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2317 using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
2318
2319 /// Alias template for common_type
2320 template<typename... _Tp>
2321 using common_type_t = typename common_type<_Tp...>::type;
2322
2323 /// Alias template for underlying_type
2324 template<typename _Tp>
2325 using underlying_type_t = typename underlying_type<_Tp>::type;
2326
2327 /// Alias template for result_of
2328 template<typename _Tp>
2329 using result_of_t = typename result_of<_Tp>::type;
2330 #endif
2331
2332 template<typename...> using __void_t = void;
2333
2334 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
2335 #define __cpp_lib_void_t 201411
2336 /// A metafunction that always yields void, used for detecting valid types.
2337 template<typename...> using void_t = void;
2338 #endif
2339
2340 /// Implementation of the detection idiom (negative case).
2341 template<typename _Default, typename _AlwaysVoid,
2342 template<typename...> class _Op, typename... _Args>
2343 struct __detector
2344 {
2345 using value_t = false_type;
2346 using type = _Default;
2347 };
2348
2349 /// Implementation of the detection idiom (positive case).
2350 template<typename _Default, template<typename...> class _Op,
2351 typename... _Args>
2352 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
2353 {
2354 using value_t = true_type;
2355 using type = _Op<_Args...>;
2356 };
2357
2358 // Detect whether _Op<_Args...> is a valid type, use _Default if not.
2359 template<typename _Default, template<typename...> class _Op,
2360 typename... _Args>
2361 using __detected_or = __detector<_Default, void, _Op, _Args...>;
2362
2363 // _Op<_Args...> if that is a valid type, otherwise _Default.
2364 template<typename _Default, template<typename...> class _Op,
2365 typename... _Args>
2366 using __detected_or_t
2367 = typename __detected_or<_Default, _Op, _Args...>::type;
2368
2369 /// @} group metaprogramming
2370
2371 /**
2372 * Use SFINAE to determine if the type _Tp has a publicly-accessible
2373 * member type _NTYPE.
2374 */
2375 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2376 template<typename _Tp, typename = __void_t<>> \
2377 struct __has_##_NTYPE \
2378 : false_type \
2379 { }; \
2380 template<typename _Tp> \
2381 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \
2382 : true_type \
2383 { };
2384
2385 template <typename _Tp>
2386 struct __is_swappable;
2387
2388 template <typename _Tp>
2389 struct __is_nothrow_swappable;
2390
2391 template<typename... _Elements>
2392 class tuple;
2393
2394 template<typename>
2395 struct __is_tuple_like_impl : false_type
2396 { };
2397
2398 template<typename... _Tps>
2399 struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
2400 { };
2401
2402 // Internal type trait that allows us to sfinae-protect tuple_cat.
2403 template<typename _Tp>
2404 struct __is_tuple_like
2405 : public __is_tuple_like_impl<typename remove_cv<
2406 typename remove_reference<_Tp>::type>::type>::type
2407 { };
2408
2409 template<typename _Tp>
2410 inline
2411 typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
2412 is_move_constructible<_Tp>,
2413 is_move_assignable<_Tp>>::value>::type
2414 swap(_Tp&, _Tp&)
2415 noexcept(__and_<is_nothrow_move_constructible<_Tp>,
2416 is_nothrow_move_assignable<_Tp>>::value);
2417
2418 template<typename _Tp, size_t _Nm>
2419 inline
2420 typename enable_if<__is_swappable<_Tp>::value>::type
2421 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
2422 noexcept(__is_nothrow_swappable<_Tp>::value);
2423
2424 namespace __swappable_details {
2425 using std::swap;
2426
2427 struct __do_is_swappable_impl
2428 {
2429 template<typename _Tp, typename
2430 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))>
2431 static true_type __test(int);
2432
2433 template<typename>
2434 static false_type __test(...);
2435 };
2436
2437 struct __do_is_nothrow_swappable_impl
2438 {
2439 template<typename _Tp>
2440 static __bool_constant<
2441 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))
2442 > __test(int);
2443
2444 template<typename>
2445 static false_type __test(...);
2446 };
2447
2448 } // namespace __swappable_details
2449
2450 template<typename _Tp>
2451 struct __is_swappable_impl
2452 : public __swappable_details::__do_is_swappable_impl
2453 {
2454 typedef decltype(__test<_Tp>(0)) type;
2455 };
2456
2457 template<typename _Tp>
2458 struct __is_nothrow_swappable_impl
2459 : public __swappable_details::__do_is_nothrow_swappable_impl
2460 {
2461 typedef decltype(__test<_Tp>(0)) type;
2462 };
2463
2464 template<typename _Tp>
2465 struct __is_swappable
2466 : public __is_swappable_impl<_Tp>::type
2467 { };
2468
2469 template<typename _Tp>
2470 struct __is_nothrow_swappable
2471 : public __is_nothrow_swappable_impl<_Tp>::type
2472 { };
2473
2474 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
2475 #define __cpp_lib_is_swappable 201603
2476 /// Metafunctions used for detecting swappable types: p0185r1
2477
2478 /// is_swappable
2479 template<typename _Tp>
2480 struct is_swappable
2481 : public __is_swappable_impl<_Tp>::type
2482 { };
2483
2484 /// is_nothrow_swappable
2485 template<typename _Tp>
2486 struct is_nothrow_swappable
2487 : public __is_nothrow_swappable_impl<_Tp>::type
2488 { };
2489
2490 #if __cplusplus >= 201402L
2491 /// is_swappable_v
2492 template<typename _Tp>
2493 _GLIBCXX17_INLINE constexpr bool is_swappable_v =
2494 is_swappable<_Tp>::value;
2495
2496 /// is_nothrow_swappable_v
2497 template<typename _Tp>
2498 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v =
2499 is_nothrow_swappable<_Tp>::value;
2500 #endif // __cplusplus >= 201402L
2501
2502 namespace __swappable_with_details {
2503 using std::swap;
2504
2505 struct __do_is_swappable_with_impl
2506 {
2507 template<typename _Tp, typename _Up, typename
2508 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
2509 typename
2510 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))>
2511 static true_type __test(int);
2512
2513 template<typename, typename>
2514 static false_type __test(...);
2515 };
2516
2517 struct __do_is_nothrow_swappable_with_impl
2518 {
2519 template<typename _Tp, typename _Up>
2520 static __bool_constant<
2521 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
2522 &&
2523 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()))
2524 > __test(int);
2525
2526 template<typename, typename>
2527 static false_type __test(...);
2528 };
2529
2530 } // namespace __swappable_with_details
2531
2532 template<typename _Tp, typename _Up>
2533 struct __is_swappable_with_impl
2534 : public __swappable_with_details::__do_is_swappable_with_impl
2535 {
2536 typedef decltype(__test<_Tp, _Up>(0)) type;
2537 };
2538
2539 // Optimization for the homogenous lvalue case, not required:
2540 template<typename _Tp>
2541 struct __is_swappable_with_impl<_Tp&, _Tp&>
2542 : public __swappable_details::__do_is_swappable_impl
2543 {
2544 typedef decltype(__test<_Tp&>(0)) type;
2545 };
2546
2547 template<typename _Tp, typename _Up>
2548 struct __is_nothrow_swappable_with_impl
2549 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl
2550 {
2551 typedef decltype(__test<_Tp, _Up>(0)) type;
2552 };
2553
2554 // Optimization for the homogenous lvalue case, not required:
2555 template<typename _Tp>
2556 struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&>
2557 : public __swappable_details::__do_is_nothrow_swappable_impl
2558 {
2559 typedef decltype(__test<_Tp&>(0)) type;
2560 };
2561
2562 /// is_swappable_with
2563 template<typename _Tp, typename _Up>
2564 struct is_swappable_with
2565 : public __is_swappable_with_impl<_Tp, _Up>::type
2566 { };
2567
2568 /// is_nothrow_swappable_with
2569 template<typename _Tp, typename _Up>
2570 struct is_nothrow_swappable_with
2571 : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type
2572 { };
2573
2574 #if __cplusplus >= 201402L
2575 /// is_swappable_with_v
2576 template<typename _Tp, typename _Up>
2577 _GLIBCXX17_INLINE constexpr bool is_swappable_with_v =
2578 is_swappable_with<_Tp, _Up>::value;
2579
2580 /// is_nothrow_swappable_with_v
2581 template<typename _Tp, typename _Up>
2582 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v =
2583 is_nothrow_swappable_with<_Tp, _Up>::value;
2584 #endif // __cplusplus >= 201402L
2585
2586 #endif// c++1z or gnu++11
2587
2588 // __is_invocable (std::is_invocable for C++11)
2589
2590 template<typename _Result, typename _Ret, typename = void>
2591 struct __is_invocable_impl : false_type { };
2592
2593 template<typename _Result, typename _Ret>
2594 struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>>
2595 : is_convertible<typename _Result::type, _Ret>::type
2596 { };
2597
2598 template<typename _Result>
2599 struct __is_invocable_impl<_Result, void, __void_t<typename _Result::type>>
2600 : true_type
2601 { };
2602
2603 template<typename _Fn, typename... _ArgTypes>
2604 struct __is_invocable
2605 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2606 { };
2607
2608 template<typename _Fn, typename _Tp, typename... _Args>
2609 constexpr bool __call_is_nt(__invoke_memfun_ref)
2610 {
2611 using _Up = typename __inv_unwrap<_Tp>::type;
2612 return noexcept((std::declval<_Up>().*std::declval<_Fn>())(
2613 std::declval<_Args>()...));
2614 }
2615
2616 template<typename _Fn, typename _Tp, typename... _Args>
2617 constexpr bool __call_is_nt(__invoke_memfun_deref)
2618 {
2619 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())(
2620 std::declval<_Args>()...));
2621 }
2622
2623 template<typename _Fn, typename _Tp>
2624 constexpr bool __call_is_nt(__invoke_memobj_ref)
2625 {
2626 using _Up = typename __inv_unwrap<_Tp>::type;
2627 return noexcept(std::declval<_Up>().*std::declval<_Fn>());
2628 }
2629
2630 template<typename _Fn, typename _Tp>
2631 constexpr bool __call_is_nt(__invoke_memobj_deref)
2632 {
2633 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>());
2634 }
2635
2636 template<typename _Fn, typename... _Args>
2637 constexpr bool __call_is_nt(__invoke_other)
2638 {
2639 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...));
2640 }
2641
2642 template<typename _Result, typename _Fn, typename... _Args>
2643 struct __call_is_nothrow
2644 : __bool_constant<
2645 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{})
2646 >
2647 { };
2648
2649 template<typename _Fn, typename... _Args>
2650 using __call_is_nothrow_
2651 = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>;
2652
2653 // __is_nothrow_invocable (std::is_nothrow_invocable for C++11)
2654 template<typename _Fn, typename... _Args>
2655 struct __is_nothrow_invocable
2656 : __and_<__is_invocable<_Fn, _Args...>,
2657 __call_is_nothrow_<_Fn, _Args...>>::type
2658 { };
2659
2660 struct __nonesuch {
2661 __nonesuch() = delete;
2662 ~__nonesuch() = delete;
2663 __nonesuch(__nonesuch const&) = delete;
2664 void operator=(__nonesuch const&) = delete;
2665 };
2666
2667 #if __cplusplus >= 201703L
2668 # define __cpp_lib_is_invocable 201703
2669
2670 /// std::invoke_result
2671 template<typename _Functor, typename... _ArgTypes>
2672 struct invoke_result
2673 : public __invoke_result<_Functor, _ArgTypes...>
2674 { };
2675
2676 /// std::invoke_result_t
2677 template<typename _Fn, typename... _Args>
2678 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
2679
2680 /// std::is_invocable
2681 template<typename _Fn, typename... _ArgTypes>
2682 struct is_invocable
2683 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2684 { };
2685
2686 /// std::is_invocable_r
2687 template<typename _Ret, typename _Fn, typename... _ArgTypes>
2688 struct is_invocable_r
2689 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type
2690 { };
2691
2692 /// std::is_nothrow_invocable
2693 template<typename _Fn, typename... _ArgTypes>
2694 struct is_nothrow_invocable
2695 : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>,
2696 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
2697 { };
2698
2699 template<typename _Result, typename _Ret, typename = void>
2700 struct __is_nt_invocable_impl : false_type { };
2701
2702 template<typename _Result, typename _Ret>
2703 struct __is_nt_invocable_impl<_Result, _Ret,
2704 __void_t<typename _Result::type>>
2705 : __and_<is_convertible<typename _Result::type, _Ret>,
2706 is_nothrow_constructible<_Ret, typename _Result::type>>
2707 { };
2708
2709 template<typename _Result>
2710 struct __is_nt_invocable_impl<_Result, void,
2711 __void_t<typename _Result::type>>
2712 : true_type
2713 { };
2714
2715 /// std::is_nothrow_invocable_r
2716 template<typename _Ret, typename _Fn, typename... _ArgTypes>
2717 struct is_nothrow_invocable_r
2718 : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>,
2719 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
2720 { };
2721
2722 /// std::is_invocable_v
2723 template<typename _Fn, typename... _Args>
2724 inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
2725
2726 /// std::is_nothrow_invocable_v
2727 template<typename _Fn, typename... _Args>
2728 inline constexpr bool is_nothrow_invocable_v
2729 = is_nothrow_invocable<_Fn, _Args...>::value;
2730
2731 /// std::is_invocable_r_v
2732 template<typename _Fn, typename... _Args>
2733 inline constexpr bool is_invocable_r_v
2734 = is_invocable_r<_Fn, _Args...>::value;
2735
2736 /// std::is_nothrow_invocable_r_v
2737 template<typename _Fn, typename... _Args>
2738 inline constexpr bool is_nothrow_invocable_r_v
2739 = is_nothrow_invocable_r<_Fn, _Args...>::value;
2740 #endif // C++17
2741
2742 #if __cplusplus >= 201703L
2743 # define __cpp_lib_type_trait_variable_templates 201510L
2744 template <typename _Tp>
2745 inline constexpr bool is_void_v = is_void<_Tp>::value;
2746 template <typename _Tp>
2747 inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
2748 template <typename _Tp>
2749 inline constexpr bool is_integral_v = is_integral<_Tp>::value;
2750 template <typename _Tp>
2751 inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
2752 template <typename _Tp>
2753 inline constexpr bool is_array_v = is_array<_Tp>::value;
2754 template <typename _Tp>
2755 inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
2756 template <typename _Tp>
2757 inline constexpr bool is_lvalue_reference_v =
2758 is_lvalue_reference<_Tp>::value;
2759 template <typename _Tp>
2760 inline constexpr bool is_rvalue_reference_v =
2761 is_rvalue_reference<_Tp>::value;
2762 template <typename _Tp>
2763 inline constexpr bool is_member_object_pointer_v =
2764 is_member_object_pointer<_Tp>::value;
2765 template <typename _Tp>
2766 inline constexpr bool is_member_function_pointer_v =
2767 is_member_function_pointer<_Tp>::value;
2768 template <typename _Tp>
2769 inline constexpr bool is_enum_v = is_enum<_Tp>::value;
2770 template <typename _Tp>
2771 inline constexpr bool is_union_v = is_union<_Tp>::value;
2772 template <typename _Tp>
2773 inline constexpr bool is_class_v = is_class<_Tp>::value;
2774 template <typename _Tp>
2775 inline constexpr bool is_function_v = is_function<_Tp>::value;
2776 template <typename _Tp>
2777 inline constexpr bool is_reference_v = is_reference<_Tp>::value;
2778 template <typename _Tp>
2779 inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
2780 template <typename _Tp>
2781 inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
2782 template <typename _Tp>
2783 inline constexpr bool is_object_v = is_object<_Tp>::value;
2784 template <typename _Tp>
2785 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
2786 template <typename _Tp>
2787 inline constexpr bool is_compound_v = is_compound<_Tp>::value;
2788 template <typename _Tp>
2789 inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
2790 template <typename _Tp>
2791 inline constexpr bool is_const_v = is_const<_Tp>::value;
2792 template <typename _Tp>
2793 inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
2794 template <typename _Tp>
2795 inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
2796 template <typename _Tp>
2797 inline constexpr bool is_trivially_copyable_v =
2798 is_trivially_copyable<_Tp>::value;
2799 template <typename _Tp>
2800 inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
2801 template <typename _Tp>
2802 inline constexpr bool is_pod_v = is_pod<_Tp>::value;
2803 template <typename _Tp>
2804 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
2805 template <typename _Tp>
2806 inline constexpr bool is_empty_v = is_empty<_Tp>::value;
2807 template <typename _Tp>
2808 inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
2809 template <typename _Tp>
2810 inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
2811 template <typename _Tp>
2812 inline constexpr bool is_final_v = is_final<_Tp>::value;
2813 template <typename _Tp>
2814 inline constexpr bool is_signed_v = is_signed<_Tp>::value;
2815 template <typename _Tp>
2816 inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
2817 template <typename _Tp, typename... _Args>
2818 inline constexpr bool is_constructible_v =
2819 is_constructible<_Tp, _Args...>::value;
2820 template <typename _Tp>
2821 inline constexpr bool is_default_constructible_v =
2822 is_default_constructible<_Tp>::value;
2823 template <typename _Tp>
2824 inline constexpr bool is_copy_constructible_v =
2825 is_copy_constructible<_Tp>::value;
2826 template <typename _Tp>
2827 inline constexpr bool is_move_constructible_v =
2828 is_move_constructible<_Tp>::value;
2829 template <typename _Tp, typename _Up>
2830 inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
2831 template <typename _Tp>
2832 inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
2833 template <typename _Tp>
2834 inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
2835 template <typename _Tp>
2836 inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
2837 template <typename _Tp, typename... _Args>
2838 inline constexpr bool is_trivially_constructible_v =
2839 is_trivially_constructible<_Tp, _Args...>::value;
2840 template <typename _Tp>
2841 inline constexpr bool is_trivially_default_constructible_v =
2842 is_trivially_default_constructible<_Tp>::value;
2843 template <typename _Tp>
2844 inline constexpr bool is_trivially_copy_constructible_v =
2845 is_trivially_copy_constructible<_Tp>::value;
2846 template <typename _Tp>
2847 inline constexpr bool is_trivially_move_constructible_v =
2848 is_trivially_move_constructible<_Tp>::value;
2849 template <typename _Tp, typename _Up>
2850 inline constexpr bool is_trivially_assignable_v =
2851 is_trivially_assignable<_Tp, _Up>::value;
2852 template <typename _Tp>
2853 inline constexpr bool is_trivially_copy_assignable_v =
2854 is_trivially_copy_assignable<_Tp>::value;
2855 template <typename _Tp>
2856 inline constexpr bool is_trivially_move_assignable_v =
2857 is_trivially_move_assignable<_Tp>::value;
2858 template <typename _Tp>
2859 inline constexpr bool is_trivially_destructible_v =
2860 is_trivially_destructible<_Tp>::value;
2861 template <typename _Tp, typename... _Args>
2862 inline constexpr bool is_nothrow_constructible_v =
2863 is_nothrow_constructible<_Tp, _Args...>::value;
2864 template <typename _Tp>
2865 inline constexpr bool is_nothrow_default_constructible_v =
2866 is_nothrow_default_constructible<_Tp>::value;
2867 template <typename _Tp>
2868 inline constexpr bool is_nothrow_copy_constructible_v =
2869 is_nothrow_copy_constructible<_Tp>::value;
2870 template <typename _Tp>
2871 inline constexpr bool is_nothrow_move_constructible_v =
2872 is_nothrow_move_constructible<_Tp>::value;
2873 template <typename _Tp, typename _Up>
2874 inline constexpr bool is_nothrow_assignable_v =
2875 is_nothrow_assignable<_Tp, _Up>::value;
2876 template <typename _Tp>
2877 inline constexpr bool is_nothrow_copy_assignable_v =
2878 is_nothrow_copy_assignable<_Tp>::value;
2879 template <typename _Tp>
2880 inline constexpr bool is_nothrow_move_assignable_v =
2881 is_nothrow_move_assignable<_Tp>::value;
2882 template <typename _Tp>
2883 inline constexpr bool is_nothrow_destructible_v =
2884 is_nothrow_destructible<_Tp>::value;
2885 template <typename _Tp>
2886 inline constexpr bool has_virtual_destructor_v =
2887 has_virtual_destructor<_Tp>::value;
2888 template <typename _Tp>
2889 inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
2890 template <typename _Tp>
2891 inline constexpr size_t rank_v = rank<_Tp>::value;
2892 template <typename _Tp, unsigned _Idx = 0>
2893 inline constexpr size_t extent_v = extent<_Tp, _Idx>::value;
2894 template <typename _Tp, typename _Up>
2895 inline constexpr bool is_same_v = is_same<_Tp, _Up>::value;
2896 template <typename _Base, typename _Derived>
2897 inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
2898 template <typename _From, typename _To>
2899 inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
2900
2901 #if __GNUC__ >= 7
2902 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
2903 #elif defined(__is_identifier)
2904 // For non-GNU compilers:
2905 # if ! __is_identifier(__has_unique_object_representations)
2906 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
2907 # endif
2908 #endif
2909
2910 #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
2911 # define __cpp_lib_has_unique_object_representations 201606
2912 /// has_unique_object_representations
2913 template<typename _Tp>
2914 struct has_unique_object_representations
2915 : bool_constant<__has_unique_object_representations(
2916 remove_cv_t<remove_all_extents_t<_Tp>>
2917 )>
2918 { };
2919 #endif
2920 #undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
2921
2922 #if __GNUC__ >= 7
2923 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
2924 #elif defined(__is_identifier)
2925 // For non-GNU compilers:
2926 # if ! __is_identifier(__is_aggregate)
2927 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
2928 # endif
2929 #endif
2930
2931 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2932 #define __cpp_lib_is_aggregate 201703
2933 /// is_aggregate
2934 template<typename _Tp>
2935 struct is_aggregate
2936 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { };
2937
2938 /// is_aggregate_v
2939 template<typename _Tp>
2940 inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
2941 #endif
2942 #undef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2943
2944 #endif // C++17
2945
2946 #if __cplusplus > 201703L
2947 /// Byte order
2948 enum class endian
2949 {
2950 little = __ORDER_LITTLE_ENDIAN__,
2951 big = __ORDER_BIG_ENDIAN__,
2952 native = __BYTE_ORDER__
2953 };
2954 #endif // C++2a
2955
2956 _GLIBCXX_END_NAMESPACE_VERSION
2957 } // namespace std
2958
2959 #endif // C++11
2960
2961 #endif // _GLIBCXX_TYPE_TRAITS