1 // C++11 <type_traits> -*- C++ -*-
3 // Copyright (C) 2007-2017 Free Software Foundation, Inc.
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)
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.
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.
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/>.
25 /** @file include/type_traits
26 * This is a Standard C++ Library header.
29 #ifndef _GLIBCXX_TYPE_TRAITS
30 #define _GLIBCXX_TYPE_TRAITS 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
35 # include <bits/c++0x_warning.h>
38 #include <bits/c++config.h>
40 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
41 # if defined (__UINT_LEAST16_TYPE__) && defined(__UINT_LEAST32_TYPE__)
44 typedef __UINT_LEAST16_TYPE__ uint_least16_t;
45 typedef __UINT_LEAST32_TYPE__ uint_least32_t;
52 namespace std _GLIBCXX_VISIBILITY(default)
54 _GLIBCXX_BEGIN_NAMESPACE_VERSION
57 * @defgroup metaprogramming Metaprogramming
60 * Template utilities for compile-time introspection and modification,
61 * including type classification traits, type property inspection traits
62 * and type transformation traits.
68 template<typename _Tp, _Tp __v>
69 struct integral_constant
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
77 #define __cpp_lib_integral_constant_callable 201304
79 constexpr value_type operator()() const { return value; }
83 template<typename _Tp, _Tp __v>
84 constexpr _Tp integral_constant<_Tp, __v>::value;
86 /// The type used as a compile-time boolean with true value.
87 typedef integral_constant<bool, true> true_type;
89 /// The type used as a compile-time boolean with false value.
90 typedef integral_constant<bool, false> false_type;
93 using __bool_constant = integral_constant<bool, __v>;
95 #if __cplusplus > 201402L
96 # define __cpp_lib_bool_constant 201505
98 using bool_constant = integral_constant<bool, __v>;
101 // Meta programming helper types.
103 template<bool, typename, typename>
106 template<typename...>
114 template<typename _B1>
119 template<typename _B1, typename _B2>
120 struct __or_<_B1, _B2>
121 : public conditional<_B1::value, _B1, _B2>::type
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
129 template<typename...>
137 template<typename _B1>
142 template<typename _B1, typename _B2>
143 struct __and_<_B1, _B2>
144 : public conditional<_B1::value, _B2, _B1>::type
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
152 template<typename _Pp>
154 : public integral_constant<bool, !_Pp::value>
157 #if __cplusplus > 201402L
159 #define __cpp_lib_logical_traits 201510
161 template<typename... _Bn>
166 template<typename... _Bn>
171 template<typename _Pp>
176 template<typename... _Bn>
177 inline constexpr bool conjunction_v
178 = conjunction<_Bn...>::value;
180 template<typename... _Bn>
181 inline constexpr bool disjunction_v
182 = disjunction<_Bn...>::value;
184 template<typename _Pp>
185 inline constexpr bool negation_v
186 = negation<_Pp>::value;
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.
195 template<typename _Tp>
196 struct __success_type
197 { typedef _Tp type; };
199 struct __failure_type
202 // Primary type categories.
208 struct __is_void_helper
209 : public false_type { };
212 struct __is_void_helper<void>
213 : public true_type { };
216 template<typename _Tp>
218 : public __is_void_helper<typename remove_cv<_Tp>::type>::type
222 struct __is_integral_helper
223 : public false_type { };
226 struct __is_integral_helper<bool>
227 : public true_type { };
230 struct __is_integral_helper<char>
231 : public true_type { };
234 struct __is_integral_helper<signed char>
235 : public true_type { };
238 struct __is_integral_helper<unsigned char>
239 : public true_type { };
241 #ifdef _GLIBCXX_USE_WCHAR_T
243 struct __is_integral_helper<wchar_t>
244 : public true_type { };
248 struct __is_integral_helper<char16_t>
249 : public true_type { };
252 struct __is_integral_helper<char32_t>
253 : public true_type { };
256 struct __is_integral_helper<short>
257 : public true_type { };
260 struct __is_integral_helper<unsigned short>
261 : public true_type { };
264 struct __is_integral_helper<int>
265 : public true_type { };
268 struct __is_integral_helper<unsigned int>
269 : public true_type { };
272 struct __is_integral_helper<long>
273 : public true_type { };
276 struct __is_integral_helper<unsigned long>
277 : public true_type { };
280 struct __is_integral_helper<long long>
281 : public true_type { };
284 struct __is_integral_helper<unsigned long long>
285 : public true_type { };
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)
291 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
292 : public true_type { };
295 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
296 : public true_type { };
298 #if defined(__GLIBCXX_TYPE_INT_N_1)
300 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
301 : public true_type { };
304 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
305 : public true_type { };
307 #if defined(__GLIBCXX_TYPE_INT_N_2)
309 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
310 : public true_type { };
313 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
314 : public true_type { };
316 #if defined(__GLIBCXX_TYPE_INT_N_3)
318 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
319 : public true_type { };
322 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
323 : public true_type { };
327 template<typename _Tp>
329 : public __is_integral_helper<typename remove_cv<_Tp>::type>::type
333 struct __is_floating_point_helper
334 : public false_type { };
337 struct __is_floating_point_helper<float>
338 : public true_type { };
341 struct __is_floating_point_helper<double>
342 : public true_type { };
345 struct __is_floating_point_helper<long double>
346 : public true_type { };
348 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
350 struct __is_floating_point_helper<__float128>
351 : public true_type { };
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
363 : public false_type { };
365 template<typename _Tp, std::size_t _Size>
366 struct is_array<_Tp[_Size]>
367 : public true_type { };
369 template<typename _Tp>
370 struct is_array<_Tp[]>
371 : public true_type { };
374 struct __is_pointer_helper
375 : public false_type { };
377 template<typename _Tp>
378 struct __is_pointer_helper<_Tp*>
379 : public true_type { };
382 template<typename _Tp>
384 : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type
387 /// is_lvalue_reference
389 struct is_lvalue_reference
390 : public false_type { };
392 template<typename _Tp>
393 struct is_lvalue_reference<_Tp&>
394 : public true_type { };
396 /// is_rvalue_reference
398 struct is_rvalue_reference
399 : public false_type { };
401 template<typename _Tp>
402 struct is_rvalue_reference<_Tp&&>
403 : public true_type { };
409 struct __is_member_object_pointer_helper
410 : public false_type { };
412 template<typename _Tp, typename _Cp>
413 struct __is_member_object_pointer_helper<_Tp _Cp::*>
414 : public integral_constant<bool, !is_function<_Tp>::value> { };
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
424 struct __is_member_function_pointer_helper
425 : public false_type { };
427 template<typename _Tp, typename _Cp>
428 struct __is_member_function_pointer_helper<_Tp _Cp::*>
429 : public integral_constant<bool, is_function<_Tp>::value> { };
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
439 template<typename _Tp>
441 : public integral_constant<bool, __is_enum(_Tp)>
445 template<typename _Tp>
447 : public integral_constant<bool, __is_union(_Tp)>
451 template<typename _Tp>
453 : public integral_constant<bool, __is_class(_Tp)>
459 : public false_type { };
461 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
462 struct is_function<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL>
463 : public true_type { };
465 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
466 struct is_function<_Res(_ArgTypes...) & _GLIBCXX_NOEXCEPT_QUAL>
467 : public true_type { };
469 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
470 struct is_function<_Res(_ArgTypes...) && _GLIBCXX_NOEXCEPT_QUAL>
471 : public true_type { };
473 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
474 struct is_function<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL>
475 : public true_type { };
477 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
478 struct is_function<_Res(_ArgTypes......) & _GLIBCXX_NOEXCEPT_QUAL>
479 : public true_type { };
481 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
482 struct is_function<_Res(_ArgTypes......) && _GLIBCXX_NOEXCEPT_QUAL>
483 : public true_type { };
485 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
486 struct is_function<_Res(_ArgTypes...) const _GLIBCXX_NOEXCEPT_QUAL>
487 : public true_type { };
489 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
490 struct is_function<_Res(_ArgTypes...) const & _GLIBCXX_NOEXCEPT_QUAL>
491 : public true_type { };
493 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
494 struct is_function<_Res(_ArgTypes...) const && _GLIBCXX_NOEXCEPT_QUAL>
495 : public true_type { };
497 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
498 struct is_function<_Res(_ArgTypes......) const _GLIBCXX_NOEXCEPT_QUAL>
499 : public true_type { };
501 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
502 struct is_function<_Res(_ArgTypes......) const & _GLIBCXX_NOEXCEPT_QUAL>
503 : public true_type { };
505 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
506 struct is_function<_Res(_ArgTypes......) const && _GLIBCXX_NOEXCEPT_QUAL>
507 : public true_type { };
509 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
510 struct is_function<_Res(_ArgTypes...) volatile _GLIBCXX_NOEXCEPT_QUAL>
511 : public true_type { };
513 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
514 struct is_function<_Res(_ArgTypes...) volatile & _GLIBCXX_NOEXCEPT_QUAL>
515 : public true_type { };
517 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
518 struct is_function<_Res(_ArgTypes...) volatile && _GLIBCXX_NOEXCEPT_QUAL>
519 : public true_type { };
521 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
522 struct is_function<_Res(_ArgTypes......) volatile _GLIBCXX_NOEXCEPT_QUAL>
523 : public true_type { };
525 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
526 struct is_function<_Res(_ArgTypes......) volatile & _GLIBCXX_NOEXCEPT_QUAL>
527 : public true_type { };
529 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
530 struct is_function<_Res(_ArgTypes......) volatile && _GLIBCXX_NOEXCEPT_QUAL>
531 : public true_type { };
533 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
534 struct is_function<_Res(_ArgTypes...) const volatile _GLIBCXX_NOEXCEPT_QUAL>
535 : public true_type { };
537 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
538 struct is_function<_Res(_ArgTypes...) const volatile & _GLIBCXX_NOEXCEPT_QUAL>
539 : public true_type { };
541 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
542 struct is_function<_Res(_ArgTypes...) const volatile && _GLIBCXX_NOEXCEPT_QUAL>
543 : public true_type { };
545 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
546 struct is_function<_Res(_ArgTypes......) const volatile _GLIBCXX_NOEXCEPT_QUAL>
547 : public true_type { };
549 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
550 struct is_function<_Res(_ArgTypes......) const volatile & _GLIBCXX_NOEXCEPT_QUAL>
551 : public true_type { };
553 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
554 struct is_function<_Res(_ArgTypes......) const volatile && _GLIBCXX_NOEXCEPT_QUAL>
555 : public true_type { };
557 #define __cpp_lib_is_null_pointer 201309
560 struct __is_null_pointer_helper
561 : public false_type { };
564 struct __is_null_pointer_helper<std::nullptr_t>
565 : public true_type { };
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
573 /// __is_nullptr_t (extension).
574 template<typename _Tp>
575 struct __is_nullptr_t
576 : public is_null_pointer<_Tp>
579 // Composite type categories.
582 template<typename _Tp>
584 : public __or_<is_lvalue_reference<_Tp>,
585 is_rvalue_reference<_Tp>>::type
589 template<typename _Tp>
591 : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
595 template<typename _Tp>
596 struct is_fundamental
597 : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
598 is_null_pointer<_Tp>>::type
602 template<typename _Tp>
604 : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
609 struct is_member_pointer;
612 template<typename _Tp>
614 : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
615 is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
619 template<typename _Tp>
621 : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
623 template<typename _Tp>
624 struct __is_member_pointer_helper
625 : public false_type { };
627 template<typename _Tp, typename _Cp>
628 struct __is_member_pointer_helper<_Tp _Cp::*>
629 : public true_type { };
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
637 // Utility to detect referenceable types ([defns.referenceable]).
639 template<typename _Tp>
640 struct __is_referenceable
641 : public __or_<is_object<_Tp>, is_reference<_Tp>>::type
644 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
645 struct __is_referenceable<_Res(_Args...) _GLIBCXX_NOEXCEPT_QUAL>
649 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
650 struct __is_referenceable<_Res(_Args......) _GLIBCXX_NOEXCEPT_QUAL>
659 : public false_type { };
661 template<typename _Tp>
662 struct is_const<_Tp const>
663 : public true_type { };
668 : public false_type { };
670 template<typename _Tp>
671 struct is_volatile<_Tp volatile>
672 : public true_type { };
675 template<typename _Tp>
677 : public integral_constant<bool, __is_trivial(_Tp)>
680 // is_trivially_copyable
681 template<typename _Tp>
682 struct is_trivially_copyable
683 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
686 /// is_standard_layout
687 template<typename _Tp>
688 struct is_standard_layout
689 : public integral_constant<bool, __is_standard_layout(_Tp)>
693 // Could use is_standard_layout && is_trivial instead of the builtin.
694 template<typename _Tp>
696 : public integral_constant<bool, __is_pod(_Tp)>
700 template<typename _Tp>
701 struct is_literal_type
702 : public integral_constant<bool, __is_literal_type(_Tp)>
706 template<typename _Tp>
708 : public integral_constant<bool, __is_empty(_Tp)>
712 template<typename _Tp>
713 struct is_polymorphic
714 : public integral_constant<bool, __is_polymorphic(_Tp)>
717 #if __cplusplus >= 201402L
718 #define __cpp_lib_is_final 201402L
720 template<typename _Tp>
722 : public integral_constant<bool, __is_final(_Tp)>
727 template<typename _Tp>
729 : public integral_constant<bool, __is_abstract(_Tp)>
732 template<typename _Tp,
733 bool = is_arithmetic<_Tp>::value>
734 struct __is_signed_helper
735 : public false_type { };
737 template<typename _Tp>
738 struct __is_signed_helper<_Tp, true>
739 : public integral_constant<bool, _Tp(-1) < _Tp(0)>
743 template<typename _Tp>
745 : public __is_signed_helper<_Tp>::type
749 template<typename _Tp>
751 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>
755 // Destructible and constructible type properties.
758 * @brief Utility to simplify expressions used in unevaluated operands
762 template<typename _Tp, typename _Up = _Tp&&>
766 template<typename _Tp>
770 template<typename _Tp>
771 auto declval() noexcept -> decltype(__declval<_Tp>(0));
773 template<typename, unsigned = 0>
777 struct remove_all_extents;
779 template<typename _Tp>
780 struct __is_array_known_bounds
781 : public integral_constant<bool, (extent<_Tp>::value > 0)>
784 template<typename _Tp>
785 struct __is_array_unknown_bounds
786 : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>
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
796 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
797 static true_type __test(int);
800 static false_type __test(...);
803 template<typename _Tp>
804 struct __is_destructible_impl
805 : public __do_is_destructible_impl
807 typedef decltype(__test<_Tp>(0)) type;
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;
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
823 template<typename _Tp>
824 struct __is_destructible_safe<_Tp, true, false>
825 : public false_type { };
827 template<typename _Tp>
828 struct __is_destructible_safe<_Tp, false, true>
829 : public true_type { };
832 template<typename _Tp>
833 struct is_destructible
834 : public __is_destructible_safe<_Tp>::type
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
843 template<typename _Tp>
844 static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
848 static false_type __test(...);
851 template<typename _Tp>
852 struct __is_nt_destructible_impl
853 : public __do_is_nt_destructible_impl
855 typedef decltype(__test<_Tp>(0)) type;
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;
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
871 template<typename _Tp>
872 struct __is_nt_destructible_safe<_Tp, true, false>
873 : public false_type { };
875 template<typename _Tp>
876 struct __is_nt_destructible_safe<_Tp, false, true>
877 : public true_type { };
879 /// is_nothrow_destructible
880 template<typename _Tp>
881 struct is_nothrow_destructible
882 : public __is_nt_destructible_safe<_Tp>::type
885 struct __do_is_default_constructible_impl
887 template<typename _Tp, typename = decltype(_Tp())>
888 static true_type __test(int);
891 static false_type __test(...);
894 template<typename _Tp>
895 struct __is_default_constructible_impl
896 : public __do_is_default_constructible_impl
898 typedef decltype(__test<_Tp>(0)) type;
901 template<typename _Tp>
902 struct __is_default_constructible_atom
903 : public __and_<__not_<is_void<_Tp>>,
904 __is_default_constructible_impl<_Tp>>
907 template<typename _Tp, bool = is_array<_Tp>::value>
908 struct __is_default_constructible_safe;
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>>
922 template<typename _Tp>
923 struct __is_default_constructible_safe<_Tp, false>
924 : public __is_default_constructible_atom<_Tp>::type
927 /// is_default_constructible
928 template<typename _Tp>
929 struct is_default_constructible
930 : public __is_default_constructible_safe<_Tp>::type
934 template<typename _Tp, typename... _Args>
935 struct is_constructible
936 : public __bool_constant<__is_constructible(_Tp, _Args...)>
939 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
940 struct __is_copy_constructible_impl;
942 template<typename _Tp>
943 struct __is_copy_constructible_impl<_Tp, false>
944 : public false_type { };
946 template<typename _Tp>
947 struct __is_copy_constructible_impl<_Tp, true>
948 : public is_constructible<_Tp, const _Tp&>
951 /// is_copy_constructible
952 template<typename _Tp>
953 struct is_copy_constructible
954 : public __is_copy_constructible_impl<_Tp>
957 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
958 struct __is_move_constructible_impl;
960 template<typename _Tp>
961 struct __is_move_constructible_impl<_Tp, false>
962 : public false_type { };
964 template<typename _Tp>
965 struct __is_move_constructible_impl<_Tp, true>
966 : public is_constructible<_Tp, _Tp&&>
969 /// is_move_constructible
970 template<typename _Tp>
971 struct is_move_constructible
972 : public __is_move_constructible_impl<_Tp>
975 template<typename _Tp>
976 struct __is_nt_default_constructible_atom
977 : public integral_constant<bool, noexcept(_Tp())>
980 template<typename _Tp, bool = is_array<_Tp>::value>
981 struct __is_nt_default_constructible_impl;
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>>
990 template<typename _Tp>
991 struct __is_nt_default_constructible_impl<_Tp, false>
992 : public __is_nt_default_constructible_atom<_Tp>
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>>
1002 template<typename _Tp, typename... _Args>
1003 struct __is_nt_constructible_impl
1004 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
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>()))>
1013 template<typename _Tp>
1014 struct __is_nt_constructible_impl<_Tp>
1015 : public is_nothrow_default_constructible<_Tp>
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...>>
1025 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1026 struct __is_nothrow_copy_constructible_impl;
1028 template<typename _Tp>
1029 struct __is_nothrow_copy_constructible_impl<_Tp, false>
1030 : public false_type { };
1032 template<typename _Tp>
1033 struct __is_nothrow_copy_constructible_impl<_Tp, true>
1034 : public is_nothrow_constructible<_Tp, const _Tp&>
1037 /// is_nothrow_copy_constructible
1038 template<typename _Tp>
1039 struct is_nothrow_copy_constructible
1040 : public __is_nothrow_copy_constructible_impl<_Tp>
1043 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1044 struct __is_nothrow_move_constructible_impl;
1046 template<typename _Tp>
1047 struct __is_nothrow_move_constructible_impl<_Tp, false>
1048 : public false_type { };
1050 template<typename _Tp>
1051 struct __is_nothrow_move_constructible_impl<_Tp, true>
1052 : public is_nothrow_constructible<_Tp, _Tp&&>
1055 /// is_nothrow_move_constructible
1056 template<typename _Tp>
1057 struct is_nothrow_move_constructible
1058 : public __is_nothrow_move_constructible_impl<_Tp>
1062 template<typename _Tp, typename _Up>
1063 struct is_assignable
1064 : public __bool_constant<__is_assignable(_Tp, _Up)>
1067 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1068 struct __is_copy_assignable_impl;
1070 template<typename _Tp>
1071 struct __is_copy_assignable_impl<_Tp, false>
1072 : public false_type { };
1074 template<typename _Tp>
1075 struct __is_copy_assignable_impl<_Tp, true>
1076 : public is_assignable<_Tp&, const _Tp&>
1079 /// is_copy_assignable
1080 template<typename _Tp>
1081 struct is_copy_assignable
1082 : public __is_copy_assignable_impl<_Tp>
1085 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1086 struct __is_move_assignable_impl;
1088 template<typename _Tp>
1089 struct __is_move_assignable_impl<_Tp, false>
1090 : public false_type { };
1092 template<typename _Tp>
1093 struct __is_move_assignable_impl<_Tp, true>
1094 : public is_assignable<_Tp&, _Tp&&>
1097 /// is_move_assignable
1098 template<typename _Tp>
1099 struct is_move_assignable
1100 : public __is_move_assignable_impl<_Tp>
1103 template<typename _Tp, typename _Up>
1104 struct __is_nt_assignable_impl
1105 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
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>>
1115 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1116 struct __is_nt_copy_assignable_impl;
1118 template<typename _Tp>
1119 struct __is_nt_copy_assignable_impl<_Tp, false>
1120 : public false_type { };
1122 template<typename _Tp>
1123 struct __is_nt_copy_assignable_impl<_Tp, true>
1124 : public is_nothrow_assignable<_Tp&, const _Tp&>
1127 /// is_nothrow_copy_assignable
1128 template<typename _Tp>
1129 struct is_nothrow_copy_assignable
1130 : public __is_nt_copy_assignable_impl<_Tp>
1133 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1134 struct __is_nt_move_assignable_impl;
1136 template<typename _Tp>
1137 struct __is_nt_move_assignable_impl<_Tp, false>
1138 : public false_type { };
1140 template<typename _Tp>
1141 struct __is_nt_move_assignable_impl<_Tp, true>
1142 : public is_nothrow_assignable<_Tp&, _Tp&&>
1145 /// is_nothrow_move_assignable
1146 template<typename _Tp>
1147 struct is_nothrow_move_assignable
1148 : public __is_nt_move_assignable_impl<_Tp>
1151 /// is_trivially_constructible
1152 template<typename _Tp, typename... _Args>
1153 struct is_trivially_constructible
1154 : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)>
1157 /// is_trivially_default_constructible
1158 template<typename _Tp>
1159 struct is_trivially_default_constructible
1160 : public is_trivially_constructible<_Tp>::type
1163 struct __do_is_implicitly_default_constructible_impl
1165 template <typename _Tp>
1166 static void __helper(const _Tp&);
1168 template <typename _Tp>
1169 static true_type __test(const _Tp&,
1170 decltype(__helper<const _Tp&>({}))* = 0);
1172 static false_type __test(...);
1175 template<typename _Tp>
1176 struct __is_implicitly_default_constructible_impl
1177 : public __do_is_implicitly_default_constructible_impl
1179 typedef decltype(__test(declval<_Tp>())) type;
1182 template<typename _Tp>
1183 struct __is_implicitly_default_constructible_safe
1184 : public __is_implicitly_default_constructible_impl<_Tp>::type
1187 template <typename _Tp>
1188 struct __is_implicitly_default_constructible
1189 : public __and_<is_default_constructible<_Tp>,
1190 __is_implicitly_default_constructible_safe<_Tp>>
1193 /// is_trivially_copy_constructible
1195 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1196 struct __is_trivially_copy_constructible_impl;
1198 template<typename _Tp>
1199 struct __is_trivially_copy_constructible_impl<_Tp, false>
1200 : public false_type { };
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&)>>
1209 template<typename _Tp>
1210 struct is_trivially_copy_constructible
1211 : public __is_trivially_copy_constructible_impl<_Tp>
1214 /// is_trivially_move_constructible
1216 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1217 struct __is_trivially_move_constructible_impl;
1219 template<typename _Tp>
1220 struct __is_trivially_move_constructible_impl<_Tp, false>
1221 : public false_type { };
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&&)>>
1230 template<typename _Tp>
1231 struct is_trivially_move_constructible
1232 : public __is_trivially_move_constructible_impl<_Tp>
1235 /// is_trivially_assignable
1236 template<typename _Tp, typename _Up>
1237 struct is_trivially_assignable
1238 : public __bool_constant<__is_trivially_assignable(_Tp, _Up)>
1241 /// is_trivially_copy_assignable
1243 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1244 struct __is_trivially_copy_assignable_impl;
1246 template<typename _Tp>
1247 struct __is_trivially_copy_assignable_impl<_Tp, false>
1248 : public false_type { };
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&)>>
1257 template<typename _Tp>
1258 struct is_trivially_copy_assignable
1259 : public __is_trivially_copy_assignable_impl<_Tp>
1262 /// is_trivially_move_assignable
1264 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1265 struct __is_trivially_move_assignable_impl;
1267 template<typename _Tp>
1268 struct __is_trivially_move_assignable_impl<_Tp, false>
1269 : public false_type { };
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&&)>>
1278 template<typename _Tp>
1279 struct is_trivially_move_assignable
1280 : public __is_trivially_move_assignable_impl<_Tp>
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)>>
1291 /// has_virtual_destructor
1292 template<typename _Tp>
1293 struct has_virtual_destructor
1294 : public integral_constant<bool, __has_virtual_destructor(_Tp)>
1298 // type property queries.
1301 template<typename _Tp>
1303 : public integral_constant<std::size_t, __alignof__(_Tp)> { };
1308 : public integral_constant<std::size_t, 0> { };
1310 template<typename _Tp, std::size_t _Size>
1311 struct rank<_Tp[_Size]>
1312 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1314 template<typename _Tp>
1316 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1319 template<typename, unsigned _Uint>
1321 : public integral_constant<std::size_t, 0> { };
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,
1330 template<typename _Tp, unsigned _Uint>
1331 struct extent<_Tp[], _Uint>
1332 : public integral_constant<std::size_t,
1333 _Uint == 0 ? 0 : extent<_Tp,
1341 template<typename, typename>
1343 : public false_type { };
1345 template<typename _Tp>
1346 struct is_same<_Tp, _Tp>
1347 : public true_type { };
1350 template<typename _Base, typename _Derived>
1352 : public integral_constant<bool, __is_base_of(_Base, _Derived)>
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; };
1361 template<typename _From, typename _To>
1362 class __is_convertible_helper<_From, _To, false>
1364 template<typename _To1>
1365 static void __test_aux(_To1);
1367 template<typename _From1, typename _To1,
1368 typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
1372 template<typename, typename>
1377 typedef decltype(__test<_From, _To>(0)) type;
1382 template<typename _From, typename _To>
1383 struct is_convertible
1384 : public __is_convertible_helper<_From, _To>::type
1388 // Const-volatile modifications.
1391 template<typename _Tp>
1393 { typedef _Tp type; };
1395 template<typename _Tp>
1396 struct remove_const<_Tp const>
1397 { typedef _Tp type; };
1400 template<typename _Tp>
1401 struct remove_volatile
1402 { typedef _Tp type; };
1404 template<typename _Tp>
1405 struct remove_volatile<_Tp volatile>
1406 { typedef _Tp type; };
1409 template<typename _Tp>
1413 remove_const<typename remove_volatile<_Tp>::type>::type type;
1417 template<typename _Tp>
1419 { typedef _Tp const type; };
1422 template<typename _Tp>
1424 { typedef _Tp volatile type; };
1427 template<typename _Tp>
1431 add_const<typename add_volatile<_Tp>::type>::type type;
1434 #if __cplusplus > 201103L
1436 #define __cpp_lib_transformation_trait_aliases 201304
1438 /// Alias template for remove_const
1439 template<typename _Tp>
1440 using remove_const_t = typename remove_const<_Tp>::type;
1442 /// Alias template for remove_volatile
1443 template<typename _Tp>
1444 using remove_volatile_t = typename remove_volatile<_Tp>::type;
1446 /// Alias template for remove_cv
1447 template<typename _Tp>
1448 using remove_cv_t = typename remove_cv<_Tp>::type;
1450 /// Alias template for add_const
1451 template<typename _Tp>
1452 using add_const_t = typename add_const<_Tp>::type;
1454 /// Alias template for add_volatile
1455 template<typename _Tp>
1456 using add_volatile_t = typename add_volatile<_Tp>::type;
1458 /// Alias template for add_cv
1459 template<typename _Tp>
1460 using add_cv_t = typename add_cv<_Tp>::type;
1463 // Reference transformations.
1465 /// remove_reference
1466 template<typename _Tp>
1467 struct remove_reference
1468 { typedef _Tp type; };
1470 template<typename _Tp>
1471 struct remove_reference<_Tp&>
1472 { typedef _Tp type; };
1474 template<typename _Tp>
1475 struct remove_reference<_Tp&&>
1476 { typedef _Tp type; };
1478 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1479 struct __add_lvalue_reference_helper
1480 { typedef _Tp type; };
1482 template<typename _Tp>
1483 struct __add_lvalue_reference_helper<_Tp, true>
1484 { typedef _Tp& type; };
1486 /// add_lvalue_reference
1487 template<typename _Tp>
1488 struct add_lvalue_reference
1489 : public __add_lvalue_reference_helper<_Tp>
1492 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1493 struct __add_rvalue_reference_helper
1494 { typedef _Tp type; };
1496 template<typename _Tp>
1497 struct __add_rvalue_reference_helper<_Tp, true>
1498 { typedef _Tp&& type; };
1500 /// add_rvalue_reference
1501 template<typename _Tp>
1502 struct add_rvalue_reference
1503 : public __add_rvalue_reference_helper<_Tp>
1506 #if __cplusplus > 201103L
1507 /// Alias template for remove_reference
1508 template<typename _Tp>
1509 using remove_reference_t = typename remove_reference<_Tp>::type;
1511 /// Alias template for add_lvalue_reference
1512 template<typename _Tp>
1513 using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1515 /// Alias template for add_rvalue_reference
1516 template<typename _Tp>
1517 using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1520 // Sign modifications.
1522 // Utility for constructing identically cv-qualified types.
1523 template<typename _Unqualified, bool _IsConst, bool _IsVol>
1524 struct __cv_selector;
1526 template<typename _Unqualified>
1527 struct __cv_selector<_Unqualified, false, false>
1528 { typedef _Unqualified __type; };
1530 template<typename _Unqualified>
1531 struct __cv_selector<_Unqualified, false, true>
1532 { typedef volatile _Unqualified __type; };
1534 template<typename _Unqualified>
1535 struct __cv_selector<_Unqualified, true, false>
1536 { typedef const _Unqualified __type; };
1538 template<typename _Unqualified>
1539 struct __cv_selector<_Unqualified, true, true>
1540 { typedef const volatile _Unqualified __type; };
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
1547 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1550 typedef typename __match::__type __type;
1553 // Utility for finding the unsigned versions of signed integral types.
1554 template<typename _Tp>
1555 struct __make_unsigned
1556 { typedef _Tp __type; };
1559 struct __make_unsigned<char>
1560 { typedef unsigned char __type; };
1563 struct __make_unsigned<signed char>
1564 { typedef unsigned char __type; };
1567 struct __make_unsigned<short>
1568 { typedef unsigned short __type; };
1571 struct __make_unsigned<int>
1572 { typedef unsigned int __type; };
1575 struct __make_unsigned<long>
1576 { typedef unsigned long __type; };
1579 struct __make_unsigned<long long>
1580 { typedef unsigned long long __type; };
1582 #if defined(_GLIBCXX_USE_WCHAR_T) && !defined(__WCHAR_UNSIGNED__)
1584 struct __make_unsigned<wchar_t> : __make_unsigned<__WCHAR_TYPE__>
1588 #if defined(__GLIBCXX_TYPE_INT_N_0)
1590 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
1591 { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; };
1593 #if defined(__GLIBCXX_TYPE_INT_N_1)
1595 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
1596 { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; };
1598 #if defined(__GLIBCXX_TYPE_INT_N_2)
1600 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
1601 { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; };
1603 #if defined(__GLIBCXX_TYPE_INT_N_3)
1605 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
1606 { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; };
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;
1615 template<typename _Tp>
1616 class __make_unsigned_selector<_Tp, true, false>
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;
1623 typedef typename __cv_unsigned::__type __type;
1626 template<typename _Tp>
1627 class __make_unsigned_selector<_Tp, false, true>
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;
1642 typedef typename conditional<__b0, __smallest, __cond1_type>::type
1644 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1647 typedef typename __cv_unsigned::__type __type;
1650 // Given an integral/enum type, return the corresponding unsigned
1652 // Primary template.
1654 template<typename _Tp>
1655 struct make_unsigned
1656 { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1658 // Integral, but don't define.
1660 struct make_unsigned<bool>;
1663 // Utility for finding the signed versions of unsigned integral types.
1664 template<typename _Tp>
1665 struct __make_signed
1666 { typedef _Tp __type; };
1669 struct __make_signed<char>
1670 { typedef signed char __type; };
1673 struct __make_signed<unsigned char>
1674 { typedef signed char __type; };
1677 struct __make_signed<unsigned short>
1678 { typedef signed short __type; };
1681 struct __make_signed<unsigned int>
1682 { typedef signed int __type; };
1685 struct __make_signed<unsigned long>
1686 { typedef signed long __type; };
1689 struct __make_signed<unsigned long long>
1690 { typedef signed long long __type; };
1692 #if defined(_GLIBCXX_USE_WCHAR_T) && defined(__WCHAR_UNSIGNED__)
1694 struct __make_signed<wchar_t> : __make_signed<__WCHAR_TYPE__>
1698 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
1700 struct __make_signed<char16_t> : __make_signed<uint_least16_t>
1703 struct __make_signed<char32_t> : __make_signed<uint_least32_t>
1707 #if defined(__GLIBCXX_TYPE_INT_N_0)
1709 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
1710 { typedef __GLIBCXX_TYPE_INT_N_0 __type; };
1712 #if defined(__GLIBCXX_TYPE_INT_N_1)
1714 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
1715 { typedef __GLIBCXX_TYPE_INT_N_1 __type; };
1717 #if defined(__GLIBCXX_TYPE_INT_N_2)
1719 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
1720 { typedef __GLIBCXX_TYPE_INT_N_2 __type; };
1722 #if defined(__GLIBCXX_TYPE_INT_N_3)
1724 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
1725 { typedef __GLIBCXX_TYPE_INT_N_3 __type; };
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;
1734 template<typename _Tp>
1735 class __make_signed_selector<_Tp, true, false>
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;
1742 typedef typename __cv_signed::__type __type;
1745 template<typename _Tp>
1746 class __make_signed_selector<_Tp, false, true>
1748 typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type;
1751 typedef typename __make_signed_selector<__unsigned_type>::__type __type;
1754 // Given an integral/enum type, return the corresponding signed
1756 // Primary template.
1758 template<typename _Tp>
1760 { typedef typename __make_signed_selector<_Tp>::__type type; };
1762 // Integral, but don't define.
1764 struct make_signed<bool>;
1766 #if __cplusplus > 201103L
1767 /// Alias template for make_signed
1768 template<typename _Tp>
1769 using make_signed_t = typename make_signed<_Tp>::type;
1771 /// Alias template for make_unsigned
1772 template<typename _Tp>
1773 using make_unsigned_t = typename make_unsigned<_Tp>::type;
1776 // Array modifications.
1779 template<typename _Tp>
1780 struct remove_extent
1781 { typedef _Tp type; };
1783 template<typename _Tp, std::size_t _Size>
1784 struct remove_extent<_Tp[_Size]>
1785 { typedef _Tp type; };
1787 template<typename _Tp>
1788 struct remove_extent<_Tp[]>
1789 { typedef _Tp type; };
1791 /// remove_all_extents
1792 template<typename _Tp>
1793 struct remove_all_extents
1794 { typedef _Tp type; };
1796 template<typename _Tp, std::size_t _Size>
1797 struct remove_all_extents<_Tp[_Size]>
1798 { typedef typename remove_all_extents<_Tp>::type type; };
1800 template<typename _Tp>
1801 struct remove_all_extents<_Tp[]>
1802 { typedef typename remove_all_extents<_Tp>::type type; };
1804 #if __cplusplus > 201103L
1805 /// Alias template for remove_extent
1806 template<typename _Tp>
1807 using remove_extent_t = typename remove_extent<_Tp>::type;
1809 /// Alias template for remove_all_extents
1810 template<typename _Tp>
1811 using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1814 // Pointer modifications.
1816 template<typename _Tp, typename>
1817 struct __remove_pointer_helper
1818 { typedef _Tp type; };
1820 template<typename _Tp, typename _Up>
1821 struct __remove_pointer_helper<_Tp, _Up*>
1822 { typedef _Up type; };
1825 template<typename _Tp>
1826 struct remove_pointer
1827 : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1831 template<typename _Tp, bool = __or_<__is_referenceable<_Tp>,
1832 is_void<_Tp>>::value>
1833 struct __add_pointer_helper
1834 { typedef _Tp type; };
1836 template<typename _Tp>
1837 struct __add_pointer_helper<_Tp, true>
1838 { typedef typename remove_reference<_Tp>::type* type; };
1840 template<typename _Tp>
1842 : public __add_pointer_helper<_Tp>
1845 #if __cplusplus > 201103L
1846 /// Alias template for remove_pointer
1847 template<typename _Tp>
1848 using remove_pointer_t = typename remove_pointer<_Tp>::type;
1850 /// Alias template for add_pointer
1851 template<typename _Tp>
1852 using add_pointer_t = typename add_pointer<_Tp>::type;
1855 template<std::size_t _Len>
1856 struct __aligned_storage_msa
1860 unsigned char __data[_Len];
1861 struct __attribute__((__aligned__)) { } __align;
1866 * @brief Alignment type.
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.
1875 template<std::size_t _Len, std::size_t _Align =
1876 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
1877 struct aligned_storage
1881 unsigned char __data[_Len];
1882 struct __attribute__((__aligned__((_Align)))) { } __align;
1886 template <typename... _Types>
1887 struct __strictest_alignment
1889 static const size_t _S_alignment = 0;
1890 static const size_t _S_size = 0;
1893 template <typename _Tp, typename... _Types>
1894 struct __strictest_alignment<_Tp, _Types...>
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;
1905 * @brief Provide aligned storage for types.
1907 * [meta.trans.other]
1909 * Provides aligned storage for any of the provided types of at
1912 * @see aligned_storage
1914 template <size_t _Len, typename... _Types>
1915 struct aligned_union
1918 static_assert(sizeof...(_Types) != 0, "At least one type is required");
1920 using __strictest = __strictest_alignment<_Types...>;
1921 static const size_t _S_len = _Len > __strictest::_S_size
1922 ? _Len : __strictest::_S_size;
1924 /// The value of the strictest alignment of _Types.
1925 static const size_t alignment_value = __strictest::_S_alignment;
1927 typedef typename aligned_storage<_S_len, alignment_value>::type type;
1930 template <size_t _Len, typename... _Types>
1931 const size_t aligned_union<_Len, _Types...>::alignment_value;
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;
1941 template<typename _Up>
1942 struct __decay_selector<_Up, false, false>
1943 { typedef typename remove_cv<_Up>::type __type; };
1945 template<typename _Up>
1946 struct __decay_selector<_Up, true, false>
1947 { typedef typename remove_extent<_Up>::type* __type; };
1949 template<typename _Up>
1950 struct __decay_selector<_Up, false, true>
1951 { typedef typename add_pointer<_Up>::type __type; };
1954 template<typename _Tp>
1957 typedef typename remove_reference<_Tp>::type __remove_type;
1960 typedef typename __decay_selector<__remove_type>::__type type;
1963 template<typename _Tp>
1964 class reference_wrapper;
1966 // Helper which adds a reference to a type when given a reference_wrapper
1967 template<typename _Tp>
1968 struct __strip_reference_wrapper
1973 template<typename _Tp>
1974 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
1976 typedef _Tp& __type;
1979 template<typename _Tp>
1980 struct __decay_and_strip
1982 typedef typename __strip_reference_wrapper<
1983 typename decay<_Tp>::type>::__type __type;
1987 // Primary template.
1988 /// Define a member typedef @c type only if a boolean constant is true.
1989 template<bool, typename _Tp = void>
1993 // Partial specialization for true.
1994 template<typename _Tp>
1995 struct enable_if<true, _Tp>
1996 { typedef _Tp type; };
1998 template<typename... _Cond>
1999 using _Require = typename enable_if<__and_<_Cond...>::value>::type;
2001 // Primary template.
2002 /// Define a member typedef @c type to one of two argument types.
2003 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2005 { typedef _Iftrue type; };
2007 // Partial specialization for false.
2008 template<typename _Iftrue, typename _Iffalse>
2009 struct conditional<false, _Iftrue, _Iffalse>
2010 { typedef _Iffalse type; };
2013 template<typename... _Tp>
2016 // Sfinae-friendly common_type implementation:
2018 struct __do_common_type_impl
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);
2025 template<typename, typename>
2026 static __failure_type _S_test(...);
2029 template<typename _Tp, typename _Up>
2030 struct __common_type_impl
2031 : private __do_common_type_impl
2033 typedef decltype(_S_test<_Tp, _Up>(0)) type;
2036 struct __do_member_type_wrapper
2038 template<typename _Tp>
2039 static __success_type<typename _Tp::type> _S_test(int);
2042 static __failure_type _S_test(...);
2045 template<typename _Tp>
2046 struct __member_type_wrapper
2047 : private __do_member_type_wrapper
2049 typedef decltype(_S_test<_Tp>(0)) type;
2052 template<typename _CTp, typename... _Args>
2053 struct __expanded_common_type_wrapper
2055 typedef common_type<typename _CTp::type, _Args...> type;
2058 template<typename... _Args>
2059 struct __expanded_common_type_wrapper<__failure_type, _Args...>
2060 { typedef __failure_type type; };
2062 template<typename _Tp>
2063 struct common_type<_Tp>
2064 { typedef typename decay<_Tp>::type type; };
2066 template<typename _Tp, typename _Up>
2067 struct common_type<_Tp, _Up>
2068 : public __common_type_impl<_Tp, _Up>::type
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
2077 /// The underlying type of an enum.
2078 template<typename _Tp>
2079 struct underlying_type
2081 typedef __underlying_type(_Tp) type;
2084 template<typename _Tp>
2085 struct __declval_protector
2087 static const bool __stop = false;
2090 template<typename _Tp>
2091 auto declval() noexcept -> decltype(__declval<_Tp>(0))
2093 static_assert(__declval_protector<_Tp>::__stop,
2094 "declval() must not be used!");
2095 return __declval<_Tp>(0);
2099 template<typename _Signature>
2102 // Sfinae-friendly result_of implementation:
2104 #define __cpp_lib_result_of_sfinae 201210
2106 struct __invoke_memfun_ref { };
2107 struct __invoke_memfun_deref { };
2108 struct __invoke_memobj_ref { };
2109 struct __invoke_memobj_deref { };
2110 struct __invoke_other { };
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; };
2117 // [func.require] paragraph 1 bullet 1:
2118 struct __result_of_memfun_ref_impl
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);
2125 template<typename...>
2126 static __failure_type _S_test(...);
2129 template<typename _MemPtr, typename _Arg, typename... _Args>
2130 struct __result_of_memfun_ref
2131 : private __result_of_memfun_ref_impl
2133 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2136 // [func.require] paragraph 1 bullet 2:
2137 struct __result_of_memfun_deref_impl
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);
2144 template<typename...>
2145 static __failure_type _S_test(...);
2148 template<typename _MemPtr, typename _Arg, typename... _Args>
2149 struct __result_of_memfun_deref
2150 : private __result_of_memfun_deref_impl
2152 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2155 // [func.require] paragraph 1 bullet 3:
2156 struct __result_of_memobj_ref_impl
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);
2163 template<typename, typename>
2164 static __failure_type _S_test(...);
2167 template<typename _MemPtr, typename _Arg>
2168 struct __result_of_memobj_ref
2169 : private __result_of_memobj_ref_impl
2171 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2174 // [func.require] paragraph 1 bullet 4:
2175 struct __result_of_memobj_deref_impl
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);
2182 template<typename, typename>
2183 static __failure_type _S_test(...);
2186 template<typename _MemPtr, typename _Arg>
2187 struct __result_of_memobj_deref
2188 : private __result_of_memobj_deref_impl
2190 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2193 template<typename _MemPtr, typename _Arg>
2194 struct __result_of_memobj;
2196 template<typename _Res, typename _Class, typename _Arg>
2197 struct __result_of_memobj<_Res _Class::*, _Arg>
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>
2209 template<typename _MemPtr, typename _Arg, typename... _Args>
2210 struct __result_of_memfun;
2212 template<typename _Res, typename _Class, typename _Arg, typename... _Args>
2213 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
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...>
2225 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2226 // 2219. INVOKE-ing a pointer to member with a reference_wrapper
2227 // as the object expression
2229 // Used by result_of, invoke etc. to unwrap a reference_wrapper.
2230 template<typename _Tp, typename _Up = typename decay<_Tp>::type>
2236 template<typename _Tp, typename _Up>
2237 struct __inv_unwrap<_Tp, reference_wrapper<_Up>>
2242 template<bool, bool, typename _Functor, typename... _ArgTypes>
2243 struct __result_of_impl
2245 typedef __failure_type type;
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>
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...>
2260 // [func.require] paragraph 1 bullet 5:
2261 struct __result_of_other_impl
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);
2268 template<typename...>
2269 static __failure_type _S_test(...);
2272 template<typename _Functor, typename... _ArgTypes>
2273 struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2274 : private __result_of_other_impl
2276 typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
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
2286 is_member_function_pointer<
2287 typename remove_reference<_Functor>::type
2289 _Functor, _ArgTypes...
2293 template<typename _Functor, typename... _ArgTypes>
2294 struct result_of<_Functor(_ArgTypes...)>
2295 : public __invoke_result<_Functor, _ArgTypes...>
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;
2304 template <size_t _Len, typename... _Types>
2305 using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
2307 /// Alias template for decay
2308 template<typename _Tp>
2309 using decay_t = typename decay<_Tp>::type;
2311 /// Alias template for enable_if
2312 template<bool _Cond, typename _Tp = void>
2313 using enable_if_t = typename enable_if<_Cond, _Tp>::type;
2315 /// Alias template for conditional
2316 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2317 using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
2319 /// Alias template for common_type
2320 template<typename... _Tp>
2321 using common_type_t = typename common_type<_Tp...>::type;
2323 /// Alias template for underlying_type
2324 template<typename _Tp>
2325 using underlying_type_t = typename underlying_type<_Tp>::type;
2327 /// Alias template for result_of
2328 template<typename _Tp>
2329 using result_of_t = typename result_of<_Tp>::type;
2332 template<typename...> using __void_t = void;
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;
2340 /// Implementation of the detection idiom (negative case).
2341 template<typename _Default, typename _AlwaysVoid,
2342 template<typename...> class _Op, typename... _Args>
2345 using value_t = false_type;
2346 using type = _Default;
2349 /// Implementation of the detection idiom (positive case).
2350 template<typename _Default, template<typename...> class _Op,
2352 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
2354 using value_t = true_type;
2355 using type = _Op<_Args...>;
2358 // Detect whether _Op<_Args...> is a valid type, use _Default if not.
2359 template<typename _Default, template<typename...> class _Op,
2361 using __detected_or = __detector<_Default, void, _Op, _Args...>;
2363 // _Op<_Args...> if that is a valid type, otherwise _Default.
2364 template<typename _Default, template<typename...> class _Op,
2366 using __detected_or_t
2367 = typename __detected_or<_Default, _Op, _Args...>::type;
2369 /// @} group metaprogramming
2372 * Use SFINAE to determine if the type _Tp has a publicly-accessible
2373 * member type _NTYPE.
2375 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2376 template<typename _Tp, typename = __void_t<>> \
2377 struct __has_##_NTYPE \
2380 template<typename _Tp> \
2381 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \
2385 template <typename _Tp>
2386 struct __is_swappable;
2388 template <typename _Tp>
2389 struct __is_nothrow_swappable;
2391 template<typename... _Elements>
2395 struct __is_tuple_like_impl : false_type
2398 template<typename... _Tps>
2399 struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
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
2409 template<typename _Tp>
2411 typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
2412 is_move_constructible<_Tp>,
2413 is_move_assignable<_Tp>>::value>::type
2415 noexcept(__and_<is_nothrow_move_constructible<_Tp>,
2416 is_nothrow_move_assignable<_Tp>>::value);
2418 template<typename _Tp, size_t _Nm>
2420 typename enable_if<__is_swappable<_Tp>::value>::type
2421 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
2422 noexcept(__is_nothrow_swappable<_Tp>::value);
2424 namespace __swappable_details {
2427 struct __do_is_swappable_impl
2429 template<typename _Tp, typename
2430 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))>
2431 static true_type __test(int);
2434 static false_type __test(...);
2437 struct __do_is_nothrow_swappable_impl
2439 template<typename _Tp>
2440 static __bool_constant<
2441 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))
2445 static false_type __test(...);
2448 } // namespace __swappable_details
2450 template<typename _Tp>
2451 struct __is_swappable_impl
2452 : public __swappable_details::__do_is_swappable_impl
2454 typedef decltype(__test<_Tp>(0)) type;
2457 template<typename _Tp>
2458 struct __is_nothrow_swappable_impl
2459 : public __swappable_details::__do_is_nothrow_swappable_impl
2461 typedef decltype(__test<_Tp>(0)) type;
2464 template<typename _Tp>
2465 struct __is_swappable
2466 : public __is_swappable_impl<_Tp>::type
2469 template<typename _Tp>
2470 struct __is_nothrow_swappable
2471 : public __is_nothrow_swappable_impl<_Tp>::type
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
2479 template<typename _Tp>
2481 : public __is_swappable_impl<_Tp>::type
2484 /// is_nothrow_swappable
2485 template<typename _Tp>
2486 struct is_nothrow_swappable
2487 : public __is_nothrow_swappable_impl<_Tp>::type
2490 #if __cplusplus >= 201402L
2492 template<typename _Tp>
2493 _GLIBCXX17_INLINE constexpr bool is_swappable_v =
2494 is_swappable<_Tp>::value;
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
2502 namespace __swappable_with_details {
2505 struct __do_is_swappable_with_impl
2507 template<typename _Tp, typename _Up, typename
2508 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
2510 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))>
2511 static true_type __test(int);
2513 template<typename, typename>
2514 static false_type __test(...);
2517 struct __do_is_nothrow_swappable_with_impl
2519 template<typename _Tp, typename _Up>
2520 static __bool_constant<
2521 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
2523 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()))
2526 template<typename, typename>
2527 static false_type __test(...);
2530 } // namespace __swappable_with_details
2532 template<typename _Tp, typename _Up>
2533 struct __is_swappable_with_impl
2534 : public __swappable_with_details::__do_is_swappable_with_impl
2536 typedef decltype(__test<_Tp, _Up>(0)) type;
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
2544 typedef decltype(__test<_Tp&>(0)) type;
2547 template<typename _Tp, typename _Up>
2548 struct __is_nothrow_swappable_with_impl
2549 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl
2551 typedef decltype(__test<_Tp, _Up>(0)) type;
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
2559 typedef decltype(__test<_Tp&>(0)) type;
2562 /// is_swappable_with
2563 template<typename _Tp, typename _Up>
2564 struct is_swappable_with
2565 : public __is_swappable_with_impl<_Tp, _Up>::type
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
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;
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
2586 #endif// c++1z or gnu++11
2588 // __is_invocable (std::is_invocable for C++11)
2590 template<typename _Result, typename _Ret, typename = void>
2591 struct __is_invocable_impl : false_type { };
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
2598 template<typename _Result>
2599 struct __is_invocable_impl<_Result, void, __void_t<typename _Result::type>>
2603 template<typename _Fn, typename... _ArgTypes>
2604 struct __is_invocable
2605 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2608 template<typename _Fn, typename _Tp, typename... _Args>
2609 constexpr bool __call_is_nt(__invoke_memfun_ref)
2611 using _Up = typename __inv_unwrap<_Tp>::type;
2612 return noexcept((std::declval<_Up>().*std::declval<_Fn>())(
2613 std::declval<_Args>()...));
2616 template<typename _Fn, typename _Tp, typename... _Args>
2617 constexpr bool __call_is_nt(__invoke_memfun_deref)
2619 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())(
2620 std::declval<_Args>()...));
2623 template<typename _Fn, typename _Tp>
2624 constexpr bool __call_is_nt(__invoke_memobj_ref)
2626 using _Up = typename __inv_unwrap<_Tp>::type;
2627 return noexcept(std::declval<_Up>().*std::declval<_Fn>());
2630 template<typename _Fn, typename _Tp>
2631 constexpr bool __call_is_nt(__invoke_memobj_deref)
2633 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>());
2636 template<typename _Fn, typename... _Args>
2637 constexpr bool __call_is_nt(__invoke_other)
2639 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...));
2642 template<typename _Result, typename _Fn, typename... _Args>
2643 struct __call_is_nothrow
2645 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{})
2649 template<typename _Fn, typename... _Args>
2650 using __call_is_nothrow_
2651 = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>;
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
2661 __nonesuch() = delete;
2662 ~__nonesuch() = delete;
2663 __nonesuch(__nonesuch const&) = delete;
2664 void operator=(__nonesuch const&) = delete;
2667 #if __cplusplus >= 201703L
2668 # define __cpp_lib_is_invocable 201703
2670 /// std::invoke_result
2671 template<typename _Functor, typename... _ArgTypes>
2672 struct invoke_result
2673 : public __invoke_result<_Functor, _ArgTypes...>
2676 /// std::invoke_result_t
2677 template<typename _Fn, typename... _Args>
2678 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
2680 /// std::is_invocable
2681 template<typename _Fn, typename... _ArgTypes>
2683 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
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
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
2699 template<typename _Result, typename _Ret, typename = void>
2700 struct __is_nt_invocable_impl : false_type { };
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>>
2709 template<typename _Result>
2710 struct __is_nt_invocable_impl<_Result, void,
2711 __void_t<typename _Result::type>>
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
2722 /// std::is_invocable_v
2723 template<typename _Fn, typename... _Args>
2724 inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
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;
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;
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;
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;
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
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>>
2920 #undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
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
2931 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2932 #define __cpp_lib_is_aggregate 201703
2934 template<typename _Tp>
2936 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { };
2939 template<typename _Tp>
2940 inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
2942 #undef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2946 #if __cplusplus > 201703L
2950 little = __ORDER_LITTLE_ENDIAN__,
2951 big = __ORDER_BIG_ENDIAN__,
2952 native = __BYTE_ORDER__
2956 _GLIBCXX_END_NAMESPACE_VERSION
2961 #endif // _GLIBCXX_TYPE_TRAITS