1 // C++0x type_traits -*- C++ -*-
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011 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 #ifndef __GXX_EXPERIMENTAL_CXX0X__
35 # include <bits/c++0x_warning.h>
38 #include <bits/c++config.h>
40 namespace std _GLIBCXX_VISIBILITY(default)
42 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 * @addtogroup metaprogramming
50 template<typename _Tp, _Tp __v>
51 struct integral_constant
53 static constexpr _Tp value = __v;
54 typedef _Tp value_type;
55 typedef integral_constant<_Tp, __v> type;
56 constexpr operator value_type() { return value; }
59 /// typedef for true_type
60 typedef integral_constant<bool, true> true_type;
62 /// typedef for false_type
63 typedef integral_constant<bool, false> false_type;
65 template<typename _Tp, _Tp __v>
66 constexpr _Tp integral_constant<_Tp, __v>::value;
68 // Meta programming helper types.
70 template<bool, typename, typename>
81 template<typename _B1>
86 template<typename _B1, typename _B2>
87 struct __or_<_B1, _B2>
88 : public conditional<_B1::value, _B1, _B2>::type
91 template<typename _B1, typename _B2, typename _B3, typename... _Bn>
92 struct __or_<_B1, _B2, _B3, _Bn...>
93 : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
104 template<typename _B1>
109 template<typename _B1, typename _B2>
110 struct __and_<_B1, _B2>
111 : public conditional<_B1::value, _B2, _B1>::type
114 template<typename _B1, typename _B2, typename _B3, typename... _Bn>
115 struct __and_<_B1, _B2, _B3, _Bn...>
116 : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
119 template<typename _Pp>
121 : public integral_constant<bool, !_Pp::value>
124 struct __sfinae_types
127 typedef struct { char __arr[2]; } __two;
130 // primary type categories.
136 struct __is_void_helper
137 : public false_type { };
140 struct __is_void_helper<void>
141 : public true_type { };
144 template<typename _Tp>
146 : public integral_constant<bool, (__is_void_helper<typename
147 remove_cv<_Tp>::type>::value)>
151 struct __is_integral_helper
152 : public false_type { };
155 struct __is_integral_helper<bool>
156 : public true_type { };
159 struct __is_integral_helper<char>
160 : public true_type { };
163 struct __is_integral_helper<signed char>
164 : public true_type { };
167 struct __is_integral_helper<unsigned char>
168 : public true_type { };
170 #ifdef _GLIBCXX_USE_WCHAR_T
172 struct __is_integral_helper<wchar_t>
173 : public true_type { };
177 struct __is_integral_helper<char16_t>
178 : public true_type { };
181 struct __is_integral_helper<char32_t>
182 : public true_type { };
185 struct __is_integral_helper<short>
186 : public true_type { };
189 struct __is_integral_helper<unsigned short>
190 : public true_type { };
193 struct __is_integral_helper<int>
194 : public true_type { };
197 struct __is_integral_helper<unsigned int>
198 : public true_type { };
201 struct __is_integral_helper<long>
202 : public true_type { };
205 struct __is_integral_helper<unsigned long>
206 : public true_type { };
209 struct __is_integral_helper<long long>
210 : public true_type { };
213 struct __is_integral_helper<unsigned long long>
214 : public true_type { };
216 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
218 struct __is_integral_helper<__int128>
219 : public true_type { };
222 struct __is_integral_helper<unsigned __int128>
223 : public true_type { };
227 template<typename _Tp>
229 : public integral_constant<bool, (__is_integral_helper<typename
230 remove_cv<_Tp>::type>::value)>
234 struct __is_floating_point_helper
235 : public false_type { };
238 struct __is_floating_point_helper<float>
239 : public true_type { };
242 struct __is_floating_point_helper<double>
243 : public true_type { };
246 struct __is_floating_point_helper<long double>
247 : public true_type { };
249 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
251 struct __is_floating_point_helper<__float128>
252 : public true_type { };
255 /// is_floating_point
256 template<typename _Tp>
257 struct is_floating_point
258 : public integral_constant<bool, (__is_floating_point_helper<typename
259 remove_cv<_Tp>::type>::value)>
265 : public false_type { };
267 template<typename _Tp, std::size_t _Size>
268 struct is_array<_Tp[_Size]>
269 : public true_type { };
271 template<typename _Tp>
272 struct is_array<_Tp[]>
273 : public true_type { };
276 struct __is_pointer_helper
277 : public false_type { };
279 template<typename _Tp>
280 struct __is_pointer_helper<_Tp*>
281 : public true_type { };
284 template<typename _Tp>
286 : public integral_constant<bool, (__is_pointer_helper<typename
287 remove_cv<_Tp>::type>::value)>
290 /// is_lvalue_reference
292 struct is_lvalue_reference
293 : public false_type { };
295 template<typename _Tp>
296 struct is_lvalue_reference<_Tp&>
297 : public true_type { };
299 /// is_rvalue_reference
301 struct is_rvalue_reference
302 : public false_type { };
304 template<typename _Tp>
305 struct is_rvalue_reference<_Tp&&>
306 : public true_type { };
312 struct __is_member_object_pointer_helper
313 : public false_type { };
315 template<typename _Tp, typename _Cp>
316 struct __is_member_object_pointer_helper<_Tp _Cp::*>
317 : public integral_constant<bool, !is_function<_Tp>::value> { };
319 /// is_member_object_pointer
320 template<typename _Tp>
321 struct is_member_object_pointer
322 : public integral_constant<bool, (__is_member_object_pointer_helper<
323 typename remove_cv<_Tp>::type>::value)>
327 struct __is_member_function_pointer_helper
328 : public false_type { };
330 template<typename _Tp, typename _Cp>
331 struct __is_member_function_pointer_helper<_Tp _Cp::*>
332 : public integral_constant<bool, is_function<_Tp>::value> { };
334 /// is_member_function_pointer
335 template<typename _Tp>
336 struct is_member_function_pointer
337 : public integral_constant<bool, (__is_member_function_pointer_helper<
338 typename remove_cv<_Tp>::type>::value)>
342 template<typename _Tp>
344 : public integral_constant<bool, __is_enum(_Tp)>
348 template<typename _Tp>
350 : public integral_constant<bool, __is_union(_Tp)>
354 template<typename _Tp>
356 : public integral_constant<bool, __is_class(_Tp)>
362 : public false_type { };
364 template<typename _Res, typename... _ArgTypes>
365 struct is_function<_Res(_ArgTypes...)>
366 : public true_type { };
368 template<typename _Res, typename... _ArgTypes>
369 struct is_function<_Res(_ArgTypes......)>
370 : public true_type { };
372 template<typename _Res, typename... _ArgTypes>
373 struct is_function<_Res(_ArgTypes...) const>
374 : public true_type { };
376 template<typename _Res, typename... _ArgTypes>
377 struct is_function<_Res(_ArgTypes......) const>
378 : public true_type { };
380 template<typename _Res, typename... _ArgTypes>
381 struct is_function<_Res(_ArgTypes...) volatile>
382 : public true_type { };
384 template<typename _Res, typename... _ArgTypes>
385 struct is_function<_Res(_ArgTypes......) volatile>
386 : public true_type { };
388 template<typename _Res, typename... _ArgTypes>
389 struct is_function<_Res(_ArgTypes...) const volatile>
390 : public true_type { };
392 template<typename _Res, typename... _ArgTypes>
393 struct is_function<_Res(_ArgTypes......) const volatile>
394 : public true_type { };
397 struct __is_nullptr_t_helper
398 : public false_type { };
401 struct __is_nullptr_t_helper<std::nullptr_t>
402 : public true_type { };
404 // __is_nullptr_t (extension).
405 template<typename _Tp>
406 struct __is_nullptr_t
407 : public integral_constant<bool, (__is_nullptr_t_helper<typename
408 remove_cv<_Tp>::type>::value)>
411 // composite type categories.
414 template<typename _Tp>
416 : public __or_<is_lvalue_reference<_Tp>,
417 is_rvalue_reference<_Tp>>::type
421 template<typename _Tp>
423 : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
427 template<typename _Tp>
428 struct is_fundamental
429 : public __or_<is_arithmetic<_Tp>, is_void<_Tp>>::type
433 template<typename _Tp>
435 : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
440 struct is_member_pointer;
443 template<typename _Tp>
445 : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
446 is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type
450 template<typename _Tp>
452 : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
454 /// is_member_pointer
455 template<typename _Tp>
456 struct __is_member_pointer_helper
457 : public false_type { };
459 template<typename _Tp, typename _Cp>
460 struct __is_member_pointer_helper<_Tp _Cp::*>
461 : public true_type { };
463 template<typename _Tp>
464 struct is_member_pointer
465 : public integral_constant<bool, (__is_member_pointer_helper<
466 typename remove_cv<_Tp>::type>::value)>
474 : public false_type { };
476 template<typename _Tp>
477 struct is_const<_Tp const>
478 : public true_type { };
483 : public false_type { };
485 template<typename _Tp>
486 struct is_volatile<_Tp volatile>
487 : public true_type { };
490 template<typename _Tp>
492 : public integral_constant<bool, __is_trivial(_Tp)>
495 /// is_trivially_copyable (still unimplemented)
497 /// is_standard_layout
498 template<typename _Tp>
499 struct is_standard_layout
500 : public integral_constant<bool, __is_standard_layout(_Tp)>
504 // Could use is_standard_layout && is_trivial instead of the builtin.
505 template<typename _Tp>
507 : public integral_constant<bool, __is_pod(_Tp)>
511 template<typename _Tp>
512 struct is_literal_type
513 : public integral_constant<bool, __is_literal_type(_Tp)>
517 template<typename _Tp>
519 : public integral_constant<bool, __is_empty(_Tp)>
523 template<typename _Tp>
524 struct is_polymorphic
525 : public integral_constant<bool, __is_polymorphic(_Tp)>
529 template<typename _Tp>
531 : public integral_constant<bool, __is_abstract(_Tp)>
534 template<typename _Tp,
535 bool = is_integral<_Tp>::value,
536 bool = is_floating_point<_Tp>::value>
537 struct __is_signed_helper
538 : public false_type { };
540 template<typename _Tp>
541 struct __is_signed_helper<_Tp, false, true>
542 : public true_type { };
544 template<typename _Tp>
545 struct __is_signed_helper<_Tp, true, false>
546 : public integral_constant<bool, static_cast<bool>(_Tp(-1) < _Tp(0))>
550 template<typename _Tp>
552 : public integral_constant<bool, __is_signed_helper<_Tp>::value>
556 template<typename _Tp>
558 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>::type
562 // destructible and constructible type properties
565 struct add_rvalue_reference;
567 template<typename _Tp>
568 typename add_rvalue_reference<_Tp>::type declval() noexcept;
570 template<typename, unsigned = 0>
574 struct remove_all_extents;
576 template<typename _Tp>
577 struct __is_array_known_bounds
578 : public integral_constant<bool, (extent<_Tp>::value > 0)>
581 template<typename _Tp>
582 struct __is_array_unknown_bounds
583 : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>::type
586 // In N3290 is_destructible does not say anything about function
587 // types and abstract types, see LWG 2049. This implementation
588 // describes function types as trivially nothrow destructible and
589 // abstract types as destructible, iff the explicit destructor
590 // call expression is wellformed.
591 struct __do_is_destructible_impl_1
593 template<typename _Up>
594 struct __w { _Up __u; };
596 template<typename _Tp, typename
597 = decltype(declval<__w<_Tp>&>().~__w<_Tp>())>
598 static true_type __test(int);
601 static false_type __test(...);
604 template<typename _Tp>
605 struct __is_destructible_impl_1
606 : public __do_is_destructible_impl_1
608 typedef decltype(__test<_Tp>(0)) type;
611 // Special implementation for abstract types
612 struct __do_is_destructible_impl_2
614 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
615 static true_type __test(int);
618 static false_type __test(...);
621 template<typename _Tp>
622 struct __is_destructible_impl_2
623 : public __do_is_destructible_impl_2
625 typedef decltype(__test<_Tp>(0)) type;
628 template<typename _Tp,
629 bool = __or_<is_void<_Tp>,
630 __is_array_unknown_bounds<_Tp>>::value,
631 bool = __or_<is_reference<_Tp>, is_function<_Tp>>::value>
632 struct __is_destructible_safe;
634 template<typename _Tp>
635 struct __is_destructible_safe<_Tp, false, false>
636 : public conditional<is_abstract<_Tp>::value,
637 __is_destructible_impl_2<_Tp>,
638 __is_destructible_impl_1<_Tp>>::type::type
641 template<typename _Tp>
642 struct __is_destructible_safe<_Tp, true, false>
643 : public false_type { };
645 template<typename _Tp>
646 struct __is_destructible_safe<_Tp, false, true>
647 : public true_type { };
650 template<typename _Tp>
651 struct is_destructible
652 : public integral_constant<bool, (__is_destructible_safe<_Tp>::value)>
655 struct __do_is_default_constructible_impl
657 template<typename _Tp, typename = decltype(_Tp())>
658 static true_type __test(int);
661 static false_type __test(...);
664 template<typename _Tp>
665 struct __is_default_constructible_impl
666 : public __do_is_default_constructible_impl
668 typedef decltype(__test<_Tp>(0)) type;
671 template<typename _Tp>
672 struct __is_default_constructible_atom
673 : public __and_<__not_<is_void<_Tp>>,
674 __is_default_constructible_impl<_Tp>>::type
677 template<typename _Tp, bool = is_array<_Tp>::value>
678 struct __is_default_constructible_safe;
680 // The following technique is a workaround for a current core language
681 // restriction, which does not allow for array types to occur in
682 // functional casts of the form T(). Complete arrays can be default-
683 // constructed, if the element type is default-constructible, but
684 // arrays with unknown bounds are not.
685 template<typename _Tp>
686 struct __is_default_constructible_safe<_Tp, true>
687 : public __and_<__is_array_known_bounds<_Tp>,
688 __is_default_constructible_atom<typename
689 remove_all_extents<_Tp>::type>>::type
692 template<typename _Tp>
693 struct __is_default_constructible_safe<_Tp, false>
694 : public __is_default_constructible_atom<_Tp>::type
697 /// is_default_constructible
698 template<typename _Tp>
699 struct is_default_constructible
700 : public integral_constant<bool, (__is_default_constructible_safe<
705 // Implementation of is_constructible.
707 // The hardest part of this trait is the binary direct-initialization
708 // case, because we hit into a functional cast of the form T(arg).
709 // This implementation uses different strategies depending on the
710 // target type to reduce the test overhead as much as possible:
712 // a) For a reference target type, we use a static_cast expression
713 // modulo its extra cases.
715 // b) For a non-reference target type we use a ::new expression.
716 struct __do_is_static_castable_impl
718 template<typename _From, typename _To, typename
719 = decltype(static_cast<_To>(declval<_From>()))>
720 static true_type __test(int);
722 template<typename, typename>
723 static false_type __test(...);
726 template<typename _From, typename _To>
727 struct __is_static_castable_impl
728 : public __do_is_static_castable_impl
730 typedef decltype(__test<_From, _To>(0)) type;
733 template<typename _From, typename _To>
734 struct __is_static_castable_safe
735 : public __is_static_castable_impl<_From, _To>::type
738 // __is_static_castable
739 template<typename _From, typename _To>
740 struct __is_static_castable
741 : public integral_constant<bool, (__is_static_castable_safe<
745 // Implementation for non-reference types. To meet the proper
746 // variable definition semantics, we also need to test for
747 // is_destructible in this case.
748 // This form should be simplified by a single expression:
749 // ::delete ::new _Tp(declval<_Arg>()), see c++/51222.
750 struct __do_is_direct_constructible_impl
752 template<typename _Tp, typename _Arg, typename
753 = decltype(::new _Tp(declval<_Arg>()))>
754 static true_type __test(int);
756 template<typename, typename>
757 static false_type __test(...);
760 template<typename _Tp, typename _Arg>
761 struct __is_direct_constructible_impl
762 : public __do_is_direct_constructible_impl
764 typedef decltype(__test<_Tp, _Arg>(0)) type;
767 template<typename _Tp, typename _Arg>
768 struct __is_direct_constructible_new_safe
769 : public __and_<is_destructible<_Tp>,
770 __is_direct_constructible_impl<_Tp, _Arg>>::type
773 template<typename, typename>
776 template<typename, typename>
780 struct remove_reference;
782 template<typename _From, typename _To, bool
783 = __not_<__or_<is_void<_From>,
784 is_function<_From>>>::value>
785 struct __is_base_to_derived_ref;
787 // Detect whether we have a downcast situation during
788 // reference binding.
789 template<typename _From, typename _To>
790 struct __is_base_to_derived_ref<_From, _To, true>
792 typedef typename remove_cv<typename remove_reference<_From
793 >::type>::type __src_t;
794 typedef typename remove_cv<typename remove_reference<_To
795 >::type>::type __dst_t;
796 typedef __and_<__not_<is_same<__src_t, __dst_t>>,
797 is_base_of<__src_t, __dst_t>> type;
798 static constexpr bool value = type::value;
801 template<typename _From, typename _To>
802 struct __is_base_to_derived_ref<_From, _To, false>
806 template<typename _From, typename _To, bool
807 = __and_<is_lvalue_reference<_From>,
808 is_rvalue_reference<_To>>::value>
809 struct __is_lvalue_to_rvalue_ref;
811 // Detect whether we have an lvalue of non-function type
812 // bound to a reference-compatible rvalue-reference.
813 template<typename _From, typename _To>
814 struct __is_lvalue_to_rvalue_ref<_From, _To, true>
816 typedef typename remove_cv<typename remove_reference<
817 _From>::type>::type __src_t;
818 typedef typename remove_cv<typename remove_reference<
819 _To>::type>::type __dst_t;
820 typedef __and_<__not_<is_function<__src_t>>,
821 __or_<is_same<__src_t, __dst_t>,
822 is_base_of<__dst_t, __src_t>>> type;
823 static constexpr bool value = type::value;
826 template<typename _From, typename _To>
827 struct __is_lvalue_to_rvalue_ref<_From, _To, false>
831 // Here we handle direct-initialization to a reference type as
832 // equivalent to a static_cast modulo overshooting conversions.
833 // These are restricted to the following conversions:
834 // a) A base class value to a derived class reference
835 // b) An lvalue to an rvalue-reference of reference-compatible
836 // types that are not functions
837 template<typename _Tp, typename _Arg>
838 struct __is_direct_constructible_ref_cast
839 : public __and_<__is_static_castable<_Arg, _Tp>,
840 __not_<__or_<__is_base_to_derived_ref<_Arg, _Tp>,
841 __is_lvalue_to_rvalue_ref<_Arg, _Tp>
845 template<typename _Tp, typename _Arg>
846 struct __is_direct_constructible_new
847 : public conditional<is_reference<_Tp>::value,
848 __is_direct_constructible_ref_cast<_Tp, _Arg>,
849 __is_direct_constructible_new_safe<_Tp, _Arg>
853 template<typename _Tp, typename _Arg>
854 struct __is_direct_constructible
855 : public integral_constant<bool, (__is_direct_constructible_new<
859 // Since default-construction and binary direct-initialization have
860 // been handled separately, the implementation of the remaining
861 // n-ary construction cases is rather straightforward. We can use
862 // here a functional cast, because array types are excluded anyway
863 // and this form is never interpreted as a C cast.
864 struct __do_is_nary_constructible_impl
866 template<typename _Tp, typename... _Args, typename
867 = decltype(_Tp(declval<_Args>()...))>
868 static true_type __test(int);
870 template<typename, typename...>
871 static false_type __test(...);
874 template<typename _Tp, typename... _Args>
875 struct __is_nary_constructible_impl
876 : public __do_is_nary_constructible_impl
878 typedef decltype(__test<_Tp, _Args...>(0)) type;
881 template<typename _Tp, typename... _Args>
882 struct __is_nary_constructible
883 : public __is_nary_constructible_impl<_Tp, _Args...>::type
885 static_assert(sizeof...(_Args) > 1,
886 "Only useful for > 1 arguments");
889 template<typename _Tp, typename... _Args>
890 struct __is_constructible_impl
891 : public __is_nary_constructible<_Tp, _Args...>
894 template<typename _Tp, typename _Arg>
895 struct __is_constructible_impl<_Tp, _Arg>
896 : public __is_direct_constructible<_Tp, _Arg>
899 template<typename _Tp>
900 struct __is_constructible_impl<_Tp>
901 : public is_default_constructible<_Tp>
905 template<typename _Tp, typename... _Args>
906 struct is_constructible
907 : public integral_constant<bool, (__is_constructible_impl<_Tp,
911 template<typename _Tp, bool = is_void<_Tp>::value>
912 struct __is_copy_constructible_impl;
914 template<typename _Tp>
915 struct __is_copy_constructible_impl<_Tp, true>
916 : public false_type { };
918 template<typename _Tp>
919 struct __is_copy_constructible_impl<_Tp, false>
920 : public is_constructible<_Tp, const _Tp&>
923 /// is_copy_constructible
924 template<typename _Tp>
925 struct is_copy_constructible
926 : public __is_copy_constructible_impl<_Tp>
929 template<typename _Tp, bool = is_void<_Tp>::value>
930 struct __is_move_constructible_impl;
932 template<typename _Tp>
933 struct __is_move_constructible_impl<_Tp, true>
934 : public false_type { };
936 template<typename _Tp>
937 struct __is_move_constructible_impl<_Tp, false>
938 : public is_constructible<_Tp, _Tp&&>
941 /// is_move_constructible
942 template<typename _Tp>
943 struct is_move_constructible
944 : public __is_move_constructible_impl<_Tp>
947 template<typename _Tp>
948 struct __is_nt_default_constructible_atom
949 : public integral_constant<bool, noexcept(_Tp())>
952 template<typename _Tp, bool = is_array<_Tp>::value>
953 struct __is_nt_default_constructible_impl;
955 template<typename _Tp>
956 struct __is_nt_default_constructible_impl<_Tp, true>
957 : public __and_<__is_array_known_bounds<_Tp>,
958 __is_nt_default_constructible_atom<typename
959 remove_all_extents<_Tp>::type>>::type
962 template<typename _Tp>
963 struct __is_nt_default_constructible_impl<_Tp, false>
964 : public __is_nt_default_constructible_atom<_Tp>
967 /// is_nothrow_default_constructible
968 template<typename _Tp>
969 struct is_nothrow_default_constructible
970 : public __and_<is_default_constructible<_Tp>,
971 __is_nt_default_constructible_impl<_Tp>>::type
974 template<typename _Tp, typename... _Args>
975 struct __is_nt_constructible_impl
976 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
979 template<typename _Tp, typename _Arg>
980 struct __is_nt_constructible_impl<_Tp, _Arg>
981 : public integral_constant<bool,
982 noexcept(static_cast<_Tp>(declval<_Arg>()))>
985 template<typename _Tp>
986 struct __is_nt_constructible_impl<_Tp>
987 : public is_nothrow_default_constructible<_Tp>
990 /// is_nothrow_constructible
991 template<typename _Tp, typename... _Args>
992 struct is_nothrow_constructible
993 : public __and_<is_constructible<_Tp, _Args...>,
994 __is_nt_constructible_impl<_Tp, _Args...>>::type
997 template<typename _Tp, bool = is_void<_Tp>::value>
998 struct __is_nothrow_copy_constructible_impl;
1000 template<typename _Tp>
1001 struct __is_nothrow_copy_constructible_impl<_Tp, true>
1002 : public false_type { };
1004 template<typename _Tp>
1005 struct __is_nothrow_copy_constructible_impl<_Tp, false>
1006 : public is_nothrow_constructible<_Tp, const _Tp&>
1009 /// is_nothrow_copy_constructible
1010 template<typename _Tp>
1011 struct is_nothrow_copy_constructible
1012 : public __is_nothrow_copy_constructible_impl<_Tp>
1015 template<typename _Tp, bool = is_void<_Tp>::value>
1016 struct __is_nothrow_move_constructible_impl;
1018 template<typename _Tp>
1019 struct __is_nothrow_move_constructible_impl<_Tp, true>
1020 : public false_type { };
1022 template<typename _Tp>
1023 struct __is_nothrow_move_constructible_impl<_Tp, false>
1024 : public is_nothrow_constructible<_Tp, _Tp&&>
1027 /// is_nothrow_move_constructible
1028 template<typename _Tp>
1029 struct is_nothrow_move_constructible
1030 : public __is_nothrow_move_constructible_impl<_Tp>
1033 template<typename _Tp, typename _Up>
1034 class __is_assignable_helper
1035 : public __sfinae_types
1037 template<typename _Tp1, typename _Up1>
1038 static decltype(declval<_Tp1>() = declval<_Up1>(), __one())
1041 template<typename, typename>
1042 static __two __test(...);
1045 static constexpr bool value = sizeof(__test<_Tp, _Up>(0)) == 1;
1049 template<typename _Tp, typename _Up>
1050 struct is_assignable
1051 : public integral_constant<bool,
1052 __is_assignable_helper<_Tp, _Up>::value>
1055 template<typename _Tp, bool = is_void<_Tp>::value>
1056 struct __is_copy_assignable_impl;
1058 template<typename _Tp>
1059 struct __is_copy_assignable_impl<_Tp, true>
1060 : public false_type { };
1062 template<typename _Tp>
1063 struct __is_copy_assignable_impl<_Tp, false>
1064 : public is_assignable<_Tp&, const _Tp&>
1067 /// is_copy_assignable
1068 template<typename _Tp>
1069 struct is_copy_assignable
1070 : public __is_copy_assignable_impl<_Tp>
1073 template<typename _Tp, bool = is_void<_Tp>::value>
1074 struct __is_move_assignable_impl;
1076 template<typename _Tp>
1077 struct __is_move_assignable_impl<_Tp, true>
1078 : public false_type { };
1080 template<typename _Tp>
1081 struct __is_move_assignable_impl<_Tp, false>
1082 : public is_assignable<_Tp&, _Tp&&>
1085 /// is_move_assignable
1086 template<typename _Tp>
1087 struct is_move_assignable
1088 : public __is_move_assignable_impl<_Tp>
1091 template<typename _Tp, typename _Up>
1092 struct __is_nt_assignable_impl
1093 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
1096 /// is_nothrow_assignable
1097 template<typename _Tp, typename _Up>
1098 struct is_nothrow_assignable
1099 : public __and_<is_assignable<_Tp, _Up>,
1100 __is_nt_assignable_impl<_Tp, _Up>>::type
1103 template<typename _Tp, bool = is_void<_Tp>::value>
1104 struct __is_nt_copy_assignable_impl;
1106 template<typename _Tp>
1107 struct __is_nt_copy_assignable_impl<_Tp, true>
1108 : public false_type { };
1110 template<typename _Tp>
1111 struct __is_nt_copy_assignable_impl<_Tp, false>
1112 : public is_nothrow_assignable<_Tp&, const _Tp&>
1115 /// is_nothrow_copy_assignable
1116 template<typename _Tp>
1117 struct is_nothrow_copy_assignable
1118 : public __is_nt_copy_assignable_impl<_Tp>
1121 template<typename _Tp, bool = is_void<_Tp>::value>
1122 struct __is_nt_move_assignable_impl;
1124 template<typename _Tp>
1125 struct __is_nt_move_assignable_impl<_Tp, true>
1126 : public false_type { };
1128 template<typename _Tp>
1129 struct __is_nt_move_assignable_impl<_Tp, false>
1130 : public is_nothrow_assignable<_Tp&, _Tp&&>
1133 /// is_nothrow_move_assignable
1134 template<typename _Tp>
1135 struct is_nothrow_move_assignable
1136 : public __is_nt_move_assignable_impl<_Tp>
1139 /// has_trivial_default_constructor
1140 template<typename _Tp>
1141 struct has_trivial_default_constructor
1142 : public integral_constant<bool, __has_trivial_constructor(_Tp)>
1145 /// has_trivial_copy_constructor
1146 template<typename _Tp>
1147 struct has_trivial_copy_constructor
1148 : public integral_constant<bool, __has_trivial_copy(_Tp)>
1151 /// has_trivial_copy_assign
1152 template<typename _Tp>
1153 struct has_trivial_copy_assign
1154 : public integral_constant<bool, __has_trivial_assign(_Tp)>
1157 /// has_trivial_destructor
1158 template<typename _Tp>
1159 struct has_trivial_destructor
1160 : public integral_constant<bool, __has_trivial_destructor(_Tp)>
1163 /// has_virtual_destructor
1164 template<typename _Tp>
1165 struct has_virtual_destructor
1166 : public integral_constant<bool, __has_virtual_destructor(_Tp)>
1170 // type property queries.
1173 template<typename _Tp>
1175 : public integral_constant<std::size_t, __alignof__(_Tp)> { };
1180 : public integral_constant<std::size_t, 0> { };
1182 template<typename _Tp, std::size_t _Size>
1183 struct rank<_Tp[_Size]>
1184 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1186 template<typename _Tp>
1188 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1191 template<typename, unsigned _Uint>
1193 : public integral_constant<std::size_t, 0> { };
1195 template<typename _Tp, unsigned _Uint, std::size_t _Size>
1196 struct extent<_Tp[_Size], _Uint>
1197 : public integral_constant<std::size_t,
1198 _Uint == 0 ? _Size : extent<_Tp,
1202 template<typename _Tp, unsigned _Uint>
1203 struct extent<_Tp[], _Uint>
1204 : public integral_constant<std::size_t,
1205 _Uint == 0 ? 0 : extent<_Tp,
1213 template<typename, typename>
1215 : public false_type { };
1217 template<typename _Tp>
1218 struct is_same<_Tp, _Tp>
1219 : public true_type { };
1222 template<typename _Base, typename _Derived>
1224 : public integral_constant<bool, __is_base_of(_Base, _Derived)>
1227 template<typename _From, typename _To,
1228 bool = __or_<is_void<_From>, is_function<_To>,
1229 is_array<_To>>::value>
1230 struct __is_convertible_helper
1231 { static constexpr bool value = is_void<_To>::value; };
1233 template<typename _From, typename _To>
1234 class __is_convertible_helper<_From, _To, false>
1235 : public __sfinae_types
1237 template<typename _To1>
1238 static void __test_aux(_To1);
1240 template<typename _From1, typename _To1>
1241 static decltype(__test_aux<_To1>(std::declval<_From1>()), __one())
1244 template<typename, typename>
1245 static __two __test(...);
1248 static constexpr bool value = sizeof(__test<_From, _To>(0)) == 1;
1252 template<typename _From, typename _To>
1253 struct is_convertible
1254 : public integral_constant<bool,
1255 __is_convertible_helper<_From, _To>::value>
1258 /// is_explicitly_convertible
1259 template<typename _From, typename _To>
1260 struct is_explicitly_convertible
1261 : public is_constructible<_To, _From>
1265 // const-volatile modifications.
1268 template<typename _Tp>
1270 { typedef _Tp type; };
1272 template<typename _Tp>
1273 struct remove_const<_Tp const>
1274 { typedef _Tp type; };
1277 template<typename _Tp>
1278 struct remove_volatile
1279 { typedef _Tp type; };
1281 template<typename _Tp>
1282 struct remove_volatile<_Tp volatile>
1283 { typedef _Tp type; };
1286 template<typename _Tp>
1290 remove_const<typename remove_volatile<_Tp>::type>::type type;
1294 template<typename _Tp>
1296 { typedef _Tp const type; };
1299 template<typename _Tp>
1301 { typedef _Tp volatile type; };
1304 template<typename _Tp>
1308 add_const<typename add_volatile<_Tp>::type>::type type;
1312 // Reference transformations.
1314 /// remove_reference
1315 template<typename _Tp>
1316 struct remove_reference
1317 { typedef _Tp type; };
1319 template<typename _Tp>
1320 struct remove_reference<_Tp&>
1321 { typedef _Tp type; };
1323 template<typename _Tp>
1324 struct remove_reference<_Tp&&>
1325 { typedef _Tp type; };
1327 template<typename _Tp,
1328 bool = __and_<__not_<is_reference<_Tp>>,
1329 __not_<is_void<_Tp>>>::value,
1330 bool = is_rvalue_reference<_Tp>::value>
1331 struct __add_lvalue_reference_helper
1332 { typedef _Tp type; };
1334 template<typename _Tp>
1335 struct __add_lvalue_reference_helper<_Tp, true, false>
1336 { typedef _Tp& type; };
1338 template<typename _Tp>
1339 struct __add_lvalue_reference_helper<_Tp, false, true>
1340 { typedef typename remove_reference<_Tp>::type& type; };
1342 /// add_lvalue_reference
1343 template<typename _Tp>
1344 struct add_lvalue_reference
1345 : public __add_lvalue_reference_helper<_Tp>
1348 template<typename _Tp,
1349 bool = __and_<__not_<is_reference<_Tp>>,
1350 __not_<is_void<_Tp>>>::value>
1351 struct __add_rvalue_reference_helper
1352 { typedef _Tp type; };
1354 template<typename _Tp>
1355 struct __add_rvalue_reference_helper<_Tp, true>
1356 { typedef _Tp&& type; };
1358 /// add_rvalue_reference
1359 template<typename _Tp>
1360 struct add_rvalue_reference
1361 : public __add_rvalue_reference_helper<_Tp>
1365 // sign modifications.
1367 // Utility for constructing identically cv-qualified types.
1368 template<typename _Unqualified, bool _IsConst, bool _IsVol>
1369 struct __cv_selector;
1371 template<typename _Unqualified>
1372 struct __cv_selector<_Unqualified, false, false>
1373 { typedef _Unqualified __type; };
1375 template<typename _Unqualified>
1376 struct __cv_selector<_Unqualified, false, true>
1377 { typedef volatile _Unqualified __type; };
1379 template<typename _Unqualified>
1380 struct __cv_selector<_Unqualified, true, false>
1381 { typedef const _Unqualified __type; };
1383 template<typename _Unqualified>
1384 struct __cv_selector<_Unqualified, true, true>
1385 { typedef const volatile _Unqualified __type; };
1387 template<typename _Qualified, typename _Unqualified,
1388 bool _IsConst = is_const<_Qualified>::value,
1389 bool _IsVol = is_volatile<_Qualified>::value>
1390 class __match_cv_qualifiers
1392 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1395 typedef typename __match::__type __type;
1398 // Utility for finding the unsigned versions of signed integral types.
1399 template<typename _Tp>
1400 struct __make_unsigned
1401 { typedef _Tp __type; };
1404 struct __make_unsigned<char>
1405 { typedef unsigned char __type; };
1408 struct __make_unsigned<signed char>
1409 { typedef unsigned char __type; };
1412 struct __make_unsigned<short>
1413 { typedef unsigned short __type; };
1416 struct __make_unsigned<int>
1417 { typedef unsigned int __type; };
1420 struct __make_unsigned<long>
1421 { typedef unsigned long __type; };
1424 struct __make_unsigned<long long>
1425 { typedef unsigned long long __type; };
1427 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1429 struct __make_unsigned<__int128>
1430 { typedef unsigned __int128 __type; };
1433 // Select between integral and enum: not possible to be both.
1434 template<typename _Tp,
1435 bool _IsInt = is_integral<_Tp>::value,
1436 bool _IsEnum = is_enum<_Tp>::value>
1437 class __make_unsigned_selector;
1439 template<typename _Tp>
1440 class __make_unsigned_selector<_Tp, true, false>
1442 typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt;
1443 typedef typename __unsignedt::__type __unsigned_type;
1444 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1447 typedef typename __cv_unsigned::__type __type;
1450 template<typename _Tp>
1451 class __make_unsigned_selector<_Tp, false, true>
1453 // With -fshort-enums, an enum may be as small as a char.
1454 typedef unsigned char __smallest;
1455 static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1456 static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short);
1457 static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int);
1458 typedef conditional<__b2, unsigned int, unsigned long> __cond2;
1459 typedef typename __cond2::type __cond2_type;
1460 typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
1461 typedef typename __cond1::type __cond1_type;
1464 typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
1467 // Given an integral/enum type, return the corresponding unsigned
1469 // Primary template.
1471 template<typename _Tp>
1472 struct make_unsigned
1473 { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1475 // Integral, but don't define.
1477 struct make_unsigned<bool>;
1480 // Utility for finding the signed versions of unsigned integral types.
1481 template<typename _Tp>
1482 struct __make_signed
1483 { typedef _Tp __type; };
1486 struct __make_signed<char>
1487 { typedef signed char __type; };
1490 struct __make_signed<unsigned char>
1491 { typedef signed char __type; };
1494 struct __make_signed<unsigned short>
1495 { typedef signed short __type; };
1498 struct __make_signed<unsigned int>
1499 { typedef signed int __type; };
1502 struct __make_signed<unsigned long>
1503 { typedef signed long __type; };
1506 struct __make_signed<unsigned long long>
1507 { typedef signed long long __type; };
1509 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1511 struct __make_signed<unsigned __int128>
1512 { typedef __int128 __type; };
1515 // Select between integral and enum: not possible to be both.
1516 template<typename _Tp,
1517 bool _IsInt = is_integral<_Tp>::value,
1518 bool _IsEnum = is_enum<_Tp>::value>
1519 class __make_signed_selector;
1521 template<typename _Tp>
1522 class __make_signed_selector<_Tp, true, false>
1524 typedef __make_signed<typename remove_cv<_Tp>::type> __signedt;
1525 typedef typename __signedt::__type __signed_type;
1526 typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed;
1529 typedef typename __cv_signed::__type __type;
1532 template<typename _Tp>
1533 class __make_signed_selector<_Tp, false, true>
1535 // With -fshort-enums, an enum may be as small as a char.
1536 typedef signed char __smallest;
1537 static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1538 static const bool __b1 = sizeof(_Tp) <= sizeof(signed short);
1539 static const bool __b2 = sizeof(_Tp) <= sizeof(signed int);
1540 typedef conditional<__b2, signed int, signed long> __cond2;
1541 typedef typename __cond2::type __cond2_type;
1542 typedef conditional<__b1, signed short, __cond2_type> __cond1;
1543 typedef typename __cond1::type __cond1_type;
1546 typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
1549 // Given an integral/enum type, return the corresponding signed
1551 // Primary template.
1553 template<typename _Tp>
1555 { typedef typename __make_signed_selector<_Tp>::__type type; };
1557 // Integral, but don't define.
1559 struct make_signed<bool>;
1562 // array modifications.
1565 template<typename _Tp>
1566 struct remove_extent
1567 { typedef _Tp type; };
1569 template<typename _Tp, std::size_t _Size>
1570 struct remove_extent<_Tp[_Size]>
1571 { typedef _Tp type; };
1573 template<typename _Tp>
1574 struct remove_extent<_Tp[]>
1575 { typedef _Tp type; };
1577 /// remove_all_extents
1578 template<typename _Tp>
1579 struct remove_all_extents
1580 { typedef _Tp type; };
1582 template<typename _Tp, std::size_t _Size>
1583 struct remove_all_extents<_Tp[_Size]>
1584 { typedef typename remove_all_extents<_Tp>::type type; };
1586 template<typename _Tp>
1587 struct remove_all_extents<_Tp[]>
1588 { typedef typename remove_all_extents<_Tp>::type type; };
1591 // pointer modifications.
1593 template<typename _Tp, typename>
1594 struct __remove_pointer_helper
1595 { typedef _Tp type; };
1597 template<typename _Tp, typename _Up>
1598 struct __remove_pointer_helper<_Tp, _Up*>
1599 { typedef _Up type; };
1602 template<typename _Tp>
1603 struct remove_pointer
1604 : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1608 template<typename _Tp>
1610 { typedef typename remove_reference<_Tp>::type* type; };
1613 template<std::size_t _Len>
1614 struct __aligned_storage_msa
1618 unsigned char __data[_Len];
1619 struct __attribute__((__aligned__)) { } __align;
1624 * @brief Alignment type.
1626 * The value of _Align is a default-alignment which shall be the
1627 * most stringent alignment requirement for any C++ object type
1628 * whose size is no greater than _Len (3.9). The member typedef
1629 * type shall be a POD type suitable for use as uninitialized
1630 * storage for any object whose size is at most _Len and whose
1631 * alignment is a divisor of _Align.
1633 template<std::size_t _Len, std::size_t _Align =
1634 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
1635 struct aligned_storage
1639 unsigned char __data[_Len];
1640 struct __attribute__((__aligned__((_Align)))) { } __align;
1645 // Decay trait for arrays and functions, used for perfect forwarding
1646 // in make_pair, make_tuple, etc.
1647 template<typename _Up,
1648 bool _IsArray = is_array<_Up>::value,
1649 bool _IsFunction = is_function<_Up>::value>
1650 struct __decay_selector;
1653 template<typename _Up>
1654 struct __decay_selector<_Up, false, false>
1655 { typedef typename remove_cv<_Up>::type __type; };
1657 template<typename _Up>
1658 struct __decay_selector<_Up, true, false>
1659 { typedef typename remove_extent<_Up>::type* __type; };
1661 template<typename _Up>
1662 struct __decay_selector<_Up, false, true>
1663 { typedef typename add_pointer<_Up>::type __type; };
1666 template<typename _Tp>
1669 typedef typename remove_reference<_Tp>::type __remove_type;
1672 typedef typename __decay_selector<__remove_type>::__type type;
1675 template<typename _Tp>
1676 class reference_wrapper;
1678 // Helper which adds a reference to a type when given a reference_wrapper
1679 template<typename _Tp>
1680 struct __strip_reference_wrapper
1685 template<typename _Tp>
1686 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
1688 typedef _Tp& __type;
1691 template<typename _Tp>
1692 struct __strip_reference_wrapper<const reference_wrapper<_Tp> >
1694 typedef _Tp& __type;
1697 template<typename _Tp>
1698 struct __decay_and_strip
1700 typedef typename __strip_reference_wrapper<
1701 typename decay<_Tp>::type>::__type __type;
1705 // Define a nested type if some predicate holds.
1706 // Primary template.
1708 template<bool, typename _Tp = void>
1712 // Partial specialization for true.
1713 template<typename _Tp>
1714 struct enable_if<true, _Tp>
1715 { typedef _Tp type; };
1718 // A conditional expression, but for types. If true, first, if false, second.
1719 // Primary template.
1721 template<bool _Cond, typename _Iftrue, typename _Iffalse>
1723 { typedef _Iftrue type; };
1725 // Partial specialization for false.
1726 template<typename _Iftrue, typename _Iffalse>
1727 struct conditional<false, _Iftrue, _Iffalse>
1728 { typedef _Iffalse type; };
1732 template<typename... _Tp>
1735 template<typename _Tp>
1736 struct common_type<_Tp>
1737 { typedef _Tp type; };
1739 template<typename _Tp, typename _Up>
1740 struct common_type<_Tp, _Up>
1741 { typedef decltype(true ? declval<_Tp>() : declval<_Up>()) type; };
1743 template<typename _Tp, typename _Up, typename... _Vp>
1744 struct common_type<_Tp, _Up, _Vp...>
1747 common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
1751 template<typename _Tp>
1752 struct underlying_type
1754 typedef __underlying_type(_Tp) type;
1758 template<typename _Tp>
1759 struct __declval_protector
1761 static const bool __stop = false;
1762 static typename add_rvalue_reference<_Tp>::type __delegate();
1765 template<typename _Tp>
1766 inline typename add_rvalue_reference<_Tp>::type
1769 static_assert(__declval_protector<_Tp>::__stop,
1770 "declval() must not be used!");
1771 return __declval_protector<_Tp>::__delegate();
1775 template<typename _Signature>
1778 template<typename _MemPtr, typename _Arg>
1779 struct _Result_of_memobj;
1781 template<typename _Res, typename _Class, typename _Arg>
1782 struct _Result_of_memobj<_Res _Class::*, _Arg>
1785 typedef _Res _Class::* _Func;
1787 template<typename _Tp>
1788 static _Tp _S_get(const _Class&);
1789 template<typename _Tp>
1790 static decltype(*std::declval<_Tp>()) _S_get(...);
1794 decltype(_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
1798 template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
1799 struct _Result_of_memfun;
1801 template<typename _Res, typename _Class, typename _Arg, typename... _Args>
1802 struct _Result_of_memfun<_Res _Class::*, _Arg, _Args...>
1805 typedef _Res _Class::* _Func;
1807 template<typename _Tp>
1808 static _Tp _S_get(const _Class&);
1809 template<typename _Tp>
1810 static decltype(*std::declval<_Tp>()) _S_get(...);
1814 decltype((_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
1815 (std::declval<_Args>()...) )
1819 template<bool, bool, typename _Functor, typename... _ArgTypes>
1820 struct _Result_of_impl;
1822 template<typename _Functor, typename... _ArgTypes>
1823 struct _Result_of_impl<false, false, _Functor, _ArgTypes...>
1826 decltype( std::declval<_Functor>()(std::declval<_ArgTypes>()...) )
1830 template<typename _MemPtr, typename _Arg>
1831 struct _Result_of_impl<true, false, _MemPtr, _Arg>
1832 : _Result_of_memobj<typename remove_reference<_MemPtr>::type, _Arg>
1834 typedef typename _Result_of_memobj<
1835 typename remove_reference<_MemPtr>::type, _Arg>::__type
1839 template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
1840 struct _Result_of_impl<false, true, _MemPtr, _Arg, _ArgTypes...>
1841 : _Result_of_memfun<typename remove_reference<_MemPtr>::type, _Arg,
1844 typedef typename _Result_of_memfun<
1845 typename remove_reference<_MemPtr>::type, _Arg, _ArgTypes...>::__type
1849 template<typename _Functor, typename... _ArgTypes>
1850 struct result_of<_Functor(_ArgTypes...)>
1851 : _Result_of_impl<is_member_object_pointer<
1852 typename remove_reference<_Functor>::type >::value,
1853 is_member_function_pointer<
1854 typename remove_reference<_Functor>::type >::value,
1855 _Functor, _ArgTypes...>
1857 typedef typename _Result_of_impl<
1858 is_member_object_pointer<
1859 typename remove_reference<_Functor>::type >::value,
1860 is_member_function_pointer<
1861 typename remove_reference<_Functor>::type >::value,
1862 _Functor, _ArgTypes...>::__type
1867 * Use SFINAE to determine if the type _Tp has a publicly-accessible
1868 * member type _NTYPE.
1870 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
1871 template<typename _Tp> \
1872 class __has_##_NTYPE##_helper \
1875 template<typename _Up> \
1879 template<typename _Up> \
1880 static __one __test(_Wrap_type<typename _Up::_NTYPE>*); \
1882 template<typename _Up> \
1883 static __two __test(...); \
1886 static constexpr bool value = sizeof(__test<_Tp>(0)) == 1; \
1889 template<typename _Tp> \
1890 struct __has_##_NTYPE \
1891 : integral_constant<bool, __has_##_NTYPE##_helper \
1892 <typename remove_cv<_Tp>::type>::value> \
1895 // @} group metaprogramming
1896 _GLIBCXX_END_NAMESPACE_VERSION
1899 #endif // __GXX_EXPERIMENTAL_CXX0X__
1901 #endif // _GLIBCXX_TYPE_TRAITS