type_traits revision 275472
10Sduke// -*- C++ -*- 213254Sjwilhelm//===------------------------ type_traits ---------------------------------===// 30Sduke// 40Sduke// The LLVM Compiler Infrastructure 50Sduke// 60Sduke// This file is dual licensed under the MIT and the University of Illinois Open 70Sduke// Source Licenses. See LICENSE.TXT for details. 80Sduke// 90Sduke//===----------------------------------------------------------------------===// 100Sduke 110Sduke#ifndef _LIBCPP_TYPE_TRAITS 120Sduke#define _LIBCPP_TYPE_TRAITS 130Sduke 140Sduke/* 150Sduke type_traits synopsis 160Sduke 170Sdukenamespace std 180Sduke{ 191472Strims 201472Strims // helper class: 211472Strims template <class T, T v> struct integral_constant; 220Sduke typedef integral_constant<bool, true> true_type; 230Sduke typedef integral_constant<bool, false> false_type; 240Sduke 251879Sstefank // helper traits 261879Sstefank template <bool, class T = void> struct enable_if; 271879Sstefank template <bool, class T, class F> struct conditional; 281879Sstefank 291879Sstefank // Primary classification traits: 301879Sstefank template <class T> struct is_void; 311879Sstefank template <class T> struct is_null_pointer; // C++14 321879Sstefank template <class T> struct is_integral; 336219Smorris template <class T> struct is_floating_point; 341879Sstefank template <class T> struct is_array; 351879Sstefank template <class T> struct is_pointer; 361879Sstefank template <class T> struct is_lvalue_reference; 371879Sstefank template <class T> struct is_rvalue_reference; 381879Sstefank template <class T> struct is_member_object_pointer; 391879Sstefank template <class T> struct is_member_function_pointer; 400Sduke template <class T> struct is_enum; 410Sduke template <class T> struct is_union; 420Sduke template <class T> struct is_class; 430Sduke template <class T> struct is_function; 440Sduke 450Sduke // Secondary classification traits: 460Sduke template <class T> struct is_reference; 470Sduke template <class T> struct is_arithmetic; 480Sduke template <class T> struct is_fundamental; 4910006Sthartmann template <class T> struct is_member_pointer; 500Sduke template <class T> struct is_scalar; 510Sduke template <class T> struct is_object; 520Sduke template <class T> struct is_compound; 530Sduke 540Sduke // Const-volatile properties and transformations: 550Sduke template <class T> struct is_const; 560Sduke template <class T> struct is_volatile; 570Sduke template <class T> struct remove_const; 580Sduke template <class T> struct remove_volatile; 590Sduke template <class T> struct remove_cv; 600Sduke template <class T> struct add_const; 61212Snever template <class T> struct add_volatile; 620Sduke template <class T> struct add_cv; 630Sduke 640Sduke // Reference transformations: 65212Snever template <class T> struct remove_reference; 66212Snever template <class T> struct add_lvalue_reference; 67212Snever template <class T> struct add_rvalue_reference; 680Sduke 690Sduke // Pointer transformations: 700Sduke template <class T> struct remove_pointer; 710Sduke template <class T> struct add_pointer; 720Sduke 730Sduke // Integral properties: 740Sduke template <class T> struct is_signed; 750Sduke template <class T> struct is_unsigned; 760Sduke template <class T> struct make_signed; 770Sduke template <class T> struct make_unsigned; 780Sduke 790Sduke // Array properties and transformations: 800Sduke template <class T> struct rank; 810Sduke template <class T, unsigned I = 0> struct extent; 820Sduke template <class T> struct remove_extent; 836467Skvn template <class T> struct remove_all_extents; 840Sduke 850Sduke // Member introspection: 860Sduke template <class T> struct is_pod; 870Sduke template <class T> struct is_trivial; 880Sduke template <class T> struct is_trivially_copyable; 890Sduke template <class T> struct is_standard_layout; 900Sduke template <class T> struct is_literal_type; 910Sduke template <class T> struct is_empty; 920Sduke template <class T> struct is_polymorphic; 930Sduke template <class T> struct is_abstract; 942972Skvn 950Sduke template <class T, class... Args> struct is_constructible; 960Sduke template <class T> struct is_default_constructible; 970Sduke template <class T> struct is_copy_constructible; 980Sduke template <class T> struct is_move_constructible; 990Sduke template <class T, class U> struct is_assignable; 1006467Skvn template <class T> struct is_copy_assignable; 1016467Skvn template <class T> struct is_move_assignable; 1026467Skvn template <class T> struct is_destructible; 10310006Sthartmann 1046467Skvn template <class T, class... Args> struct is_trivially_constructible; 1056467Skvn template <class T> struct is_trivially_default_constructible; 1066467Skvn template <class T> struct is_trivially_copy_constructible; 1076467Skvn template <class T> struct is_trivially_move_constructible; 1086467Skvn template <class T, class U> struct is_trivially_assignable; 1096467Skvn template <class T> struct is_trivially_copy_assignable; 1100Sduke template <class T> struct is_trivially_move_assignable; 1110Sduke template <class T> struct is_trivially_destructible; 1120Sduke 1130Sduke template <class T, class... Args> struct is_nothrow_constructible; 1140Sduke template <class T> struct is_nothrow_default_constructible; 1150Sduke template <class T> struct is_nothrow_copy_constructible; 1160Sduke template <class T> struct is_nothrow_move_constructible; 1170Sduke template <class T, class U> struct is_nothrow_assignable; 1180Sduke template <class T> struct is_nothrow_copy_assignable; 1190Sduke template <class T> struct is_nothrow_move_assignable; 1200Sduke template <class T> struct is_nothrow_destructible; 1210Sduke 1220Sduke template <class T> struct has_virtual_destructor; 1230Sduke 1240Sduke // Relationships between types: 1250Sduke template <class T, class U> struct is_same; 1260Sduke template <class Base, class Derived> struct is_base_of; 1270Sduke template <class From, class To> struct is_convertible; 1280Sduke 1290Sduke // Alignment properties and transformations: 1300Sduke template <class T> struct alignment_of; 1310Sduke template <size_t Len, size_t Align = most_stringent_alignment_requirement> 1320Sduke struct aligned_storage; 1330Sduke template <size_t Len, class... Types> struct aligned_union; 1340Sduke 1350Sduke template <class T> struct decay; 1360Sduke template <class... T> struct common_type; 1370Sduke template <class T> struct underlying_type; 1380Sduke template <class> class result_of; // undefined 1390Sduke template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; 1400Sduke 1410Sduke // const-volatile modifications: 1420Sduke template <class T> 1430Sduke using remove_const_t = typename remove_const<T>::type; // C++14 1440Sduke template <class T> 1450Sduke using remove_volatile_t = typename remove_volatile<T>::type; // C++14 1460Sduke template <class T> 1470Sduke using remove_cv_t = typename remove_cv<T>::type; // C++14 1480Sduke template <class T> 1490Sduke using add_const_t = typename add_const<T>::type; // C++14 15013254Sjwilhelm template <class T> 15113254Sjwilhelm using add_volatile_t = typename add_volatile<T>::type; // C++14 15213254Sjwilhelm template <class T> 1530Sduke using add_cv_t = typename add_cv<T>::type; // C++14 1540Sduke 1550Sduke // reference modifications: 1560Sduke template <class T> 1570Sduke using remove_reference_t = typename remove_reference<T>::type; // C++14 1580Sduke template <class T> 1590Sduke using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14 1600Sduke template <class T> 1610Sduke using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14 1626546Sthartmann 1630Sduke // sign modifications: 1640Sduke template <class T> 1650Sduke using make_signed_t = typename make_signed<T>::type; // C++14 1660Sduke template <class T> 1670Sduke using make_unsigned_t = typename make_unsigned<T>::type; // C++14 1680Sduke 1690Sduke // array modifications: 1700Sduke template <class T> 1716546Sthartmann using remove_extent_t = typename remove_extent<T>::type; // C++14 1726546Sthartmann template <class T> 1730Sduke using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14 1740Sduke 1750Sduke // pointer modifications: 1760Sduke template <class T> 1770Sduke using remove_pointer_t = typename remove_pointer<T>::type; // C++14 1780Sduke template <class T> 1790Sduke using add_pointer_t = typename add_pointer<T>::type; // C++14 1800Sduke 1810Sduke // other transformations: 1820Sduke template <size_t Len, std::size_t Align=default-alignment> 1830Sduke using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14 1846546Sthartmann template <std::size_t Len, class... Types> 1850Sduke using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14 1866546Sthartmann template <class T> 1870Sduke using decay_t = typename decay<T>::type; // C++14 1880Sduke template <bool b, class T=void> 1890Sduke using enable_if_t = typename enable_if<b,T>::type; // C++14 1900Sduke template <bool b, class T, class F> 1910Sduke using conditional_t = typename conditional<b,T,F>::type; // C++14 1920Sduke template <class... T> 1930Sduke using common_type_t = typename common_type<T...>::type; // C++14 1940Sduke template <class T> 1950Sduke using underlying_type_t = typename underlying_type<T>::type; // C++14 1960Sduke template <class F, class... ArgTypes> 1970Sduke using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14 1980Sduke 1990Sduke} // std 2000Sduke 2010Sduke*/ 2020Sduke#include <__config> 2030Sduke#include <cstddef> 2046546Sthartmann 2050Sduke#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2060Sduke#pragma GCC system_header 2070Sduke#endif 2086546Sthartmann 2090Sduke_LIBCPP_BEGIN_NAMESPACE_STD 2100Sduke 2110Sduketemplate <bool _Bp, class _If, class _Then> 2126546Sthartmann struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; 2130Sduketemplate <class _If, class _Then> 2140Sduke struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;}; 2150Sduke 2166546Sthartmann#if _LIBCPP_STD_VER > 11 2170Sduketemplate <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; 2180Sduke#endif 2190Sduke 2200Sduketemplate <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {}; 2210Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;}; 2226546Sthartmann 2230Sduke#if _LIBCPP_STD_VER > 11 2240Sduketemplate <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; 2250Sduke#endif 2266546Sthartmann 2270Sduke 2280Sdukestruct __two {char __lx[2];}; 2290Sduke 2306546Sthartmann// helper class: 2310Sduke 232400Skvntemplate <class _Tp, _Tp __v> 233400Skvnstruct _LIBCPP_TYPE_VIS_ONLY integral_constant 2346546Sthartmann{ 235400Skvn static _LIBCPP_CONSTEXPR const _Tp value = __v; 236400Skvn typedef _Tp value_type; 237400Skvn typedef integral_constant type; 2386546Sthartmann _LIBCPP_INLINE_VISIBILITY 239400Skvn _LIBCPP_CONSTEXPR operator value_type() const {return value;} 2400Sduke#if _LIBCPP_STD_VER > 11 2410Sduke _LIBCPP_INLINE_VISIBILITY 2420Sduke constexpr value_type operator ()() const {return value;} 2436546Sthartmann#endif 2446546Sthartmann}; 2450Sduke 2460Sduketemplate <class _Tp, _Tp __v> 2470Sduke_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; 2480Sduke 2490Sduketypedef integral_constant<bool, true> true_type; 2500Sduketypedef integral_constant<bool, false> false_type; 2510Sduke 2520Sduke// is_const 2530Sduke 2540Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; 2559821Saphtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; 2569821Saph 2570Sduke// is_volatile 2580Sduke 2590Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; 2600Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; 2610Sduke 2620Sduke// remove_const 2630Sduke 2640Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; 2650Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;}; 2660Sduke#if _LIBCPP_STD_VER > 11 2670Sduketemplate <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; 2680Sduke#endif 2690Sduke 2700Sduke// remove_volatile 2710Sduke 2720Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; 2730Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;}; 2740Sduke#if _LIBCPP_STD_VER > 11 2750Sduketemplate <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; 2760Sduke#endif 2770Sduke 2780Sduke// remove_cv 2790Sduke 28013254Sjwilhelmtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv 28113254Sjwilhelm{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; 28213254Sjwilhelm#if _LIBCPP_STD_VER > 11 2830Sduketemplate <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; 2840Sduke#endif 2850Sduke 2860Sduke// is_void 2870Sduke 2880Sduketemplate <class _Tp> struct __libcpp_is_void : public false_type {}; 2890Sduketemplate <> struct __libcpp_is_void<void> : public true_type {}; 2900Sduke 2916546Sthartmanntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void 2920Sduke : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; 2930Sduke 2940Sduke// __is_nullptr_t 2950Sduke 2960Sduketemplate <class _Tp> struct __libcpp___is_nullptr : public false_type {}; 2970Sduketemplate <> struct __libcpp___is_nullptr<nullptr_t> : public true_type {}; 2980Sduke 2990Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t 3006546Sthartmann : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {}; 3016546Sthartmann 3020Sduke#if _LIBCPP_STD_VER > 11 3030Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer 3040Sduke : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {}; 3050Sduke#endif 3060Sduke 3070Sduke// is_integral 3080Sduke 3090Sduketemplate <class _Tp> struct __libcpp_is_integral : public false_type {}; 3100Sduketemplate <> struct __libcpp_is_integral<bool> : public true_type {}; 3110Sduketemplate <> struct __libcpp_is_integral<char> : public true_type {}; 3126546Sthartmanntemplate <> struct __libcpp_is_integral<signed char> : public true_type {}; 3130Sduketemplate <> struct __libcpp_is_integral<unsigned char> : public true_type {}; 3146546Sthartmanntemplate <> struct __libcpp_is_integral<wchar_t> : public true_type {}; 3150Sduke#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 3160Sduketemplate <> struct __libcpp_is_integral<char16_t> : public true_type {}; 3170Sduketemplate <> struct __libcpp_is_integral<char32_t> : public true_type {}; 3180Sduke#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 3190Sduketemplate <> struct __libcpp_is_integral<short> : public true_type {}; 3200Sduketemplate <> struct __libcpp_is_integral<unsigned short> : public true_type {}; 3210Sduketemplate <> struct __libcpp_is_integral<int> : public true_type {}; 3220Sduketemplate <> struct __libcpp_is_integral<unsigned int> : public true_type {}; 3230Sduketemplate <> struct __libcpp_is_integral<long> : public true_type {}; 3240Sduketemplate <> struct __libcpp_is_integral<unsigned long> : public true_type {}; 3250Sduketemplate <> struct __libcpp_is_integral<long long> : public true_type {}; 3260Sduketemplate <> struct __libcpp_is_integral<unsigned long long> : public true_type {}; 3270Sduke 3280Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral 3290Sduke : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; 3300Sduke 3310Sduke// is_floating_point 3326546Sthartmann 3330Sduketemplate <class _Tp> struct __libcpp_is_floating_point : public false_type {}; 3340Sduketemplate <> struct __libcpp_is_floating_point<float> : public true_type {}; 3350Sduketemplate <> struct __libcpp_is_floating_point<double> : public true_type {}; 3366546Sthartmanntemplate <> struct __libcpp_is_floating_point<long double> : public true_type {}; 3370Sduke 3380Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point 3390Sduke : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; 3406546Sthartmann 3410Sduke// is_array 3420Sduke 3430Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array 3446546Sthartmann : public false_type {}; 3450Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> 3460Sduke : public true_type {}; 3470Sduketemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> 3486546Sthartmann : public true_type {}; 3490Sduke 3500Sduke// is_pointer 3510Sduke 3526546Sthartmanntemplate <class _Tp> struct __libcpp_is_pointer : public false_type {}; 3536546Sthartmanntemplate <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; 3540Sduke 3550Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer 3560Sduke : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {}; 3570Sduke 3580Sduke// is_reference 3590Sduke 3600Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; 3610Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {}; 3620Sduke 3630Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {}; 3649821Saph#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3659821Saphtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {}; 3660Sduke#endif 3670Sduke 3680Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {}; 3690Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {}; 3700Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3710Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; 3720Sduke#endif 3730Sduke 3740Sduke#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 3750Sduke#define _LIBCPP_HAS_TYPE_TRAITS 3760Sduke#endif 3770Sduke 3780Sduke// is_union 3790Sduke 3800Sduke#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 38110006Sthartmann 3820Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union 3830Sduke : public integral_constant<bool, __is_union(_Tp)> {}; 3840Sduke 3850Sduke#else 3860Sduke 3870Sduketemplate <class _Tp> struct __libcpp_union : public false_type {}; 3880Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union 3890Sduke : public __libcpp_union<typename remove_cv<_Tp>::type> {}; 3900Sduke 3910Sduke#endif 3920Sduke 3930Sduke// is_class 3940Sduke 3950Sduke#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 3960Sduke 3970Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class 3980Sduke : public integral_constant<bool, __is_class(_Tp)> {}; 3990Sduke 4000Sduke#else 4010Sduke 4020Sdukenamespace __is_class_imp 4030Sduke{ 4040Sduketemplate <class _Tp> char __test(int _Tp::*); 4050Sduketemplate <class _Tp> __two __test(...); 4060Sduke} 4070Sduke 4080Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class 4090Sduke : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; 4100Sduke 4110Sduke#endif 4120Sduke 4130Sduke// is_same 4140Sduke 4150Sduketemplate <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; 4160Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; 4170Sduke 4180Sduke// is_function 4190Sduke 4206546Sthartmannnamespace __is_function_imp 4210Sduke{ 4220Sduketemplate <class _Tp> char __test(_Tp*); 4230Sduketemplate <class _Tp> __two __test(...); 4240Sduketemplate <class _Tp> _Tp& __source(); 4250Sduke} 4260Sduke 4270Sduketemplate <class _Tp, bool = is_class<_Tp>::value || 4280Sduke is_union<_Tp>::value || 4290Sduke is_void<_Tp>::value || 4300Sduke is_reference<_Tp>::value || 4310Sduke __is_nullptr_t<_Tp>::value > 4320Sdukestruct __libcpp_is_function 4330Sduke : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1> 4340Sduke {}; 4350Sduketemplate <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {}; 4360Sduke 4370Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function 4380Sduke : public __libcpp_is_function<_Tp> {}; 4390Sduke 4400Sduke// is_member_function_pointer 4410Sduke 4420Sduke// template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {}; 4430Sduke// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; 4440Sduke// 4450Sduke 4460Sduketemplate <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr> 4470Sdukestruct __member_pointer_traits_imp 4480Sduke{ // forward declaration; specializations later 4490Sduke}; 4500Sduke 4510Sduke 4520Sdukenamespace __libcpp_is_member_function_pointer_imp { 4530Sduke template <typename _Tp> 4540Sduke char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *); 4550Sduke 4560Sduke template <typename> 4570Sduke std::__two __test(...); 4580Sduke}; 4590Sduke 4600Sduketemplate <class _Tp> struct __libcpp_is_member_function_pointer 4610Sduke : public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {}; 4620Sduke 4636546Sthartmanntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer 4640Sduke : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {}; 4650Sduke 4660Sduke// is_member_pointer 4670Sduke 4680Sduketemplate <class _Tp> struct __libcpp_is_member_pointer : public false_type {}; 4690Sduketemplate <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; 4700Sduke 4710Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer 4720Sduke : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {}; 4730Sduke 4740Sduke// is_member_object_pointer 4750Sduke 4760Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer 4770Sduke : public integral_constant<bool, is_member_pointer<_Tp>::value && 4780Sduke !is_member_function_pointer<_Tp>::value> {}; 4790Sduke 4800Sduke// is_enum 4810Sduke 4820Sduke#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 4830Sduke 4840Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum 4850Sduke : public integral_constant<bool, __is_enum(_Tp)> {}; 4860Sduke 4870Sduke#else 4880Sduke 4890Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum 4900Sduke : public integral_constant<bool, !is_void<_Tp>::value && 4910Sduke !is_integral<_Tp>::value && 4920Sduke !is_floating_point<_Tp>::value && 4930Sduke !is_array<_Tp>::value && 4940Sduke !is_pointer<_Tp>::value && 4950Sduke !is_reference<_Tp>::value && 4960Sduke !is_member_pointer<_Tp>::value && 49710006Sthartmann !is_union<_Tp>::value && 4980Sduke !is_class<_Tp>::value && 4990Sduke !is_function<_Tp>::value > {}; 5000Sduke 5018797Smhaupt#endif 5028797Smhaupt 5038797Smhaupt// is_arithmetic 5048797Smhaupt 5058797Smhaupttemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic 5068797Smhaupt : public integral_constant<bool, is_integral<_Tp>::value || 5078797Smhaupt is_floating_point<_Tp>::value> {}; 5088797Smhaupt 5098797Smhaupt// is_fundamental 5108797Smhaupt 5118797Smhaupttemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental 5128797Smhaupt : public integral_constant<bool, is_void<_Tp>::value || 5138797Smhaupt __is_nullptr_t<_Tp>::value || 5148797Smhaupt is_arithmetic<_Tp>::value> {}; 5158797Smhaupt 5168797Smhaupt// is_scalar 5178797Smhaupt 5188797Smhaupttemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar 5198797Smhaupt : public integral_constant<bool, is_arithmetic<_Tp>::value || 5208797Smhaupt is_member_pointer<_Tp>::value || 5218797Smhaupt is_pointer<_Tp>::value || 5228797Smhaupt __is_nullptr_t<_Tp>::value || 5238797Smhaupt is_enum<_Tp>::value > {}; 5248797Smhaupt 5258797Smhaupttemplate <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {}; 5268797Smhaupt 5278797Smhaupt// is_object 5288797Smhaupt 5298797Smhaupttemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object 5308797Smhaupt : public integral_constant<bool, is_scalar<_Tp>::value || 5318797Smhaupt is_array<_Tp>::value || 5320Sduke is_union<_Tp>::value || 5330Sduke is_class<_Tp>::value > {}; 5340Sduke 5350Sduke// is_compound 5360Sduke 5370Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound 5380Sduke : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; 5390Sduke 5400Sduke// add_const 5410Sduke 5420Sduketemplate <class _Tp, bool = is_reference<_Tp>::value || 5430Sduke is_function<_Tp>::value || 5440Sduke is_const<_Tp>::value > 5450Sdukestruct __add_const {typedef _Tp type;}; 5460Sduke 5470Sduketemplate <class _Tp> 5480Sdukestruct __add_const<_Tp, false> {typedef const _Tp type;}; 5490Sduke 5500Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const 5510Sduke {typedef typename __add_const<_Tp>::type type;}; 5520Sduke 5530Sduke#if _LIBCPP_STD_VER > 11 5540Sduketemplate <class _Tp> using add_const_t = typename add_const<_Tp>::type; 5550Sduke#endif 5560Sduke 5570Sduke// add_volatile 5580Sduke 5590Sduketemplate <class _Tp, bool = is_reference<_Tp>::value || 5600Sduke is_function<_Tp>::value || 5610Sduke is_volatile<_Tp>::value > 5620Sdukestruct __add_volatile {typedef _Tp type;}; 5630Sduke 5640Sduketemplate <class _Tp> 5650Sdukestruct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; 5660Sduke 5670Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile 5680Sduke {typedef typename __add_volatile<_Tp>::type type;}; 5690Sduke 5700Sduke#if _LIBCPP_STD_VER > 11 5710Sduketemplate <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; 5720Sduke#endif 5730Sduke 5740Sduke// add_cv 5750Sduke 5760Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv 5770Sduke {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;}; 5780Sduke 5790Sduke#if _LIBCPP_STD_VER > 11 5800Sduketemplate <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; 58111331Svlivanov#endif 58211331Svlivanov 5830Sduke// remove_reference 5840Sduke 58511331Svlivanovtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;}; 58611331Svlivanovtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;}; 5870Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5880Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;}; 5890Sduke#endif 5900Sduke 5910Sduke#if _LIBCPP_STD_VER > 11 5920Sduketemplate <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; 5930Sduke#endif 5940Sduke 5950Sduke// add_lvalue_reference 5960Sduke 5970Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;}; 5980Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler 5990Sduketemplate <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;}; 6000Sduketemplate <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;}; 6010Sduketemplate <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;}; 6023475Skvntemplate <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;}; 6030Sduke 6040Sduke#if _LIBCPP_STD_VER > 11 6050Sduketemplate <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; 6060Sduke#endif 6070Sduke 6080Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 6090Sduke 6100Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;}; 6110Sduketemplate <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;}; 6120Sduketemplate <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;}; 6133475Skvntemplate <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;}; 6140Sduketemplate <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;}; 6150Sduke 6160Sduke#if _LIBCPP_STD_VER > 11 6170Sduketemplate <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; 61810006Sthartmann#endif 6196467Skvn 6206467Skvn#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 6216467Skvn 6226467Skvn#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 6236467Skvn 6246467Skvntemplate <class _Tp> 6256467Skvntypename add_rvalue_reference<_Tp>::type 6266467Skvndeclval() _NOEXCEPT; 6276467Skvn 6286467Skvn#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 6296467Skvn 6306467Skvntemplate <class _Tp> 6316467Skvntypename add_lvalue_reference<_Tp>::type 6326467Skvndeclval(); 6336467Skvn 6346467Skvn#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 6356467Skvn 6366467Skvnstruct __any 6376467Skvn{ 6386467Skvn __any(...); 6396467Skvn}; 6406467Skvn 6416467Skvn// remove_pointer 6426467Skvn 6436467Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;}; 6446467Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;}; 6456467Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;}; 6466467Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;}; 6476467Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;}; 6486467Skvn 6496467Skvn#if _LIBCPP_STD_VER > 11 6506467Skvntemplate <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; 6516467Skvn#endif 6526467Skvn 6536467Skvn// add_pointer 6546467Skvn 6556467Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer 6566467Skvn {typedef typename remove_reference<_Tp>::type* type;}; 6576467Skvn 6586467Skvn#if _LIBCPP_STD_VER > 11 6596467Skvntemplate <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; 6606467Skvn#endif 6616467Skvn 6626467Skvn// is_signed 6636467Skvn 6646467Skvntemplate <class _Tp, bool = is_integral<_Tp>::value> 6656467Skvnstruct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {}; 6666467Skvn 6676467Skvntemplate <class _Tp> 6686467Skvnstruct ___is_signed<_Tp, false> : public true_type {}; // floating point 6696467Skvn 6706467Skvntemplate <class _Tp, bool = is_arithmetic<_Tp>::value> 6716467Skvnstruct __libcpp_is_signed : public ___is_signed<_Tp> {}; 6726467Skvn 6736467Skvntemplate <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; 6746467Skvn 6756467Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; 6766467Skvn 6776467Skvn// is_unsigned 6786467Skvn 6796467Skvntemplate <class _Tp, bool = is_integral<_Tp>::value> 6806467Skvnstruct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {}; 6816467Skvn 6826467Skvntemplate <class _Tp> 6836467Skvnstruct ___is_unsigned<_Tp, false> : public false_type {}; // floating point 6846467Skvn 6856467Skvntemplate <class _Tp, bool = is_arithmetic<_Tp>::value> 6866467Skvnstruct __libcpp_is_unsigned : public ___is_unsigned<_Tp> {}; 6876467Skvn 6886467Skvntemplate <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; 6896467Skvn 6906467Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; 6916467Skvn 6926467Skvn// rank 6933475Skvn 6943475Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank 6953475Skvn : public integral_constant<size_t, 0> {}; 6963475Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> 6973475Skvn : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 6983475Skvntemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> 6990Sduke : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 7000Sduke 7010Sduke// extent 7020Sduke 7030Sduketemplate <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent 7046546Sthartmann : public integral_constant<size_t, 0> {}; 7050Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0> 7066546Sthartmann : public integral_constant<size_t, 0> {}; 7070Sduketemplate <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip> 7086546Sthartmann : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 7090Sduketemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0> 7100Sduke : public integral_constant<size_t, _Np> {}; 7110Sduketemplate <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> 7120Sduke : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 7130Sduke 7140Sduke// remove_extent 7150Sduke 7160Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent 7170Sduke {typedef _Tp type;}; 7180Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]> 7190Sduke {typedef _Tp type;}; 7200Sduketemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]> 7210Sduke {typedef _Tp type;}; 7220Sduke 7230Sduke#if _LIBCPP_STD_VER > 11 7240Sduketemplate <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; 7250Sduke#endif 7260Sduke 7270Sduke// remove_all_extents 7280Sduke 7290Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents 7300Sduke {typedef _Tp type;}; 7310Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]> 7320Sduke {typedef typename remove_all_extents<_Tp>::type type;}; 7330Sduketemplate <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]> 7340Sduke {typedef typename remove_all_extents<_Tp>::type type;}; 7350Sduke 7360Sduke#if _LIBCPP_STD_VER > 11 7370Sduketemplate <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; 7380Sduke#endif 7390Sduke 7400Sduke// decay 74112866Sthartmann 74212866Sthartmanntemplate <class _Tp> 74312866Sthartmannstruct _LIBCPP_TYPE_VIS_ONLY decay 74412866Sthartmann{ 74512866Sthartmannprivate: 74612866Sthartmann typedef typename remove_reference<_Tp>::type _Up; 74712866Sthartmannpublic: 74812866Sthartmann typedef typename conditional 74912866Sthartmann < 75012866Sthartmann is_array<_Up>::value, 75112866Sthartmann typename remove_extent<_Up>::type*, 75212866Sthartmann typename conditional 75312866Sthartmann < 75412866Sthartmann is_function<_Up>::value, 75512866Sthartmann typename add_pointer<_Up>::type, 75612866Sthartmann typename remove_cv<_Up>::type 75712866Sthartmann >::type 75812866Sthartmann >::type type; 75912866Sthartmann}; 76012866Sthartmann 76112866Sthartmann#if _LIBCPP_STD_VER > 11 76212866Sthartmanntemplate <class _Tp> using decay_t = typename decay<_Tp>::type; 76312866Sthartmann#endif 76412866Sthartmann 76512866Sthartmann// is_abstract 76612866Sthartmann 76712866Sthartmannnamespace __is_abstract_imp 76812866Sthartmann{ 76912866Sthartmanntemplate <class _Tp> char __test(_Tp (*)[1]); 77012866Sthartmanntemplate <class _Tp> __two __test(...); 77112866Sthartmann} 77212866Sthartmann 77312866Sthartmanntemplate <class _Tp, bool = is_class<_Tp>::value> 77412866Sthartmannstruct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {}; 77512866Sthartmann 77612866Sthartmanntemplate <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}; 77712866Sthartmann 77812866Sthartmanntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; 77912866Sthartmann 78012866Sthartmann// is_base_of 78112866Sthartmann 78212866Sthartmann#ifdef _LIBCPP_HAS_IS_BASE_OF 78312866Sthartmann 78412866Sthartmanntemplate <class _Bp, class _Dp> 78512866Sthartmannstruct _LIBCPP_TYPE_VIS_ONLY is_base_of 78612866Sthartmann : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; 78712866Sthartmann 78812866Sthartmann#else // __has_feature(is_base_of) 78912866Sthartmann 79012866Sthartmannnamespace __is_base_of_imp 79112866Sthartmann{ 79212866Sthartmanntemplate <class _Tp> 79312866Sthartmannstruct _Dst 79412866Sthartmann{ 7950Sduke _Dst(const volatile _Tp &); 7960Sduke}; 7970Sduketemplate <class _Tp> 7980Sdukestruct _Src 7990Sduke{ 8000Sduke operator const volatile _Tp &(); 8010Sduke template <class _Up> operator const _Dst<_Up> &(); 8020Sduke}; 8030Sduketemplate <size_t> struct __one { typedef char type; }; 8040Sduketemplate <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int); 8050Sduketemplate <class _Bp, class _Dp> __two __test(...); 8060Sduke} 8070Sduke 8080Sduketemplate <class _Bp, class _Dp> 8090Sdukestruct _LIBCPP_TYPE_VIS_ONLY is_base_of 8100Sduke : public integral_constant<bool, is_class<_Bp>::value && 8110Sduke sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; 8120Sduke 8130Sduke#endif // __has_feature(is_base_of) 8140Sduke 8150Sduke// is_convertible 8160Sduke 81733Skvn#if __has_feature(is_convertible_to) 81833Skvn 81933Skvntemplate <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible 82033Skvn : public integral_constant<bool, __is_convertible_to(_T1, _T2) && 82133Skvn !is_abstract<_T2>::value> {}; 82233Skvn 82333Skvn#else // __has_feature(is_convertible_to) 8240Sduke 8250Sdukenamespace __is_convertible_imp 8260Sduke{ 8270Sduketemplate <class _Tp> char __test(_Tp); 8280Sduketemplate <class _Tp> __two __test(...); 8290Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 8300Sduketemplate <class _Tp> _Tp&& __source(); 831668Snever#else 832783Skvntemplate <class _Tp> typename remove_reference<_Tp>::type& __source(); 833783Skvn#endif 834783Skvn 835783Skvntemplate <class _Tp, bool _IsArray = is_array<_Tp>::value, 836783Skvn bool _IsFunction = is_function<_Tp>::value, 837296Srasbold bool _IsVoid = is_void<_Tp>::value> 8380Sduke struct __is_array_function_or_void {enum {value = 0};}; 839296Srasboldtemplate <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; 840296Srasboldtemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; 8413602Scoleenptemplate <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; 8420Sduke} 8430Sduke 844296Srasboldtemplate <class _Tp, 845296Srasbold unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> 8460Sdukestruct __is_convertible_check 847296Srasbold{ 848296Srasbold static const size_t __v = 0; 8490Sduke}; 850296Srasbold 851296Srasboldtemplate <class _Tp> 852296Srasboldstruct __is_convertible_check<_Tp, 0> 853296Srasbold{ 854296Srasbold static const size_t __v = sizeof(_Tp); 855296Srasbold}; 856296Srasbold 857296Srasboldtemplate <class _T1, class _T2, 858296Srasbold unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, 859296Srasbold unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> 8600Sdukestruct __is_convertible 8610Sduke : public integral_constant<bool, 8620Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 8630Sduke sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 8640Sduke#else 8650Sduke sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 8660Sduke && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value 8670Sduke && (!is_const<typename remove_reference<_T2>::type>::value 8680Sduke || is_volatile<typename remove_reference<_T2>::type>::value) 8690Sduke && (is_same<typename remove_cv<_T1>::type, 8700Sduke typename remove_cv<typename remove_reference<_T2>::type>::type>::value 8710Sduke || is_base_of<typename remove_reference<_T2>::type, _T1>::value)) 8720Sduke#endif 8730Sduke > 8740Sduke{}; 8750Sduke 8760Sduketemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {}; 8770Sduke 8780Sduketemplate <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {}; 8793399Skvn#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 8803399Skvntemplate <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {}; 8813399Skvntemplate <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {}; 8823399Skvntemplate <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {}; 8833399Skvntemplate <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {}; 8843399Skvn#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 8853399Skvn 8863399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0> 8873399Skvn : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {}; 8883399Skvn 8893399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0> 8903399Skvn : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {}; 8913399Skvn 8923399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0> 8933399Skvn : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {}; 8943399Skvn 8953399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0> 8963399Skvn : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {}; 8973399Skvn 8983399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {}; 8993399Skvn#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 9003399Skvntemplate <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {}; 9013399Skvn#endif 9023399Skvntemplate <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {}; 9033399Skvntemplate <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {}; 9043399Skvntemplate <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {}; 9053399Skvntemplate <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {}; 9063399Skvntemplate <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {}; 9073399Skvn 9083399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {}; 9093399Skvn 9103399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; 9113399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; 9123399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; 9133399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; 9143399Skvn 9153399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; 9163399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; 9173399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; 9183399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; 9193602Scoleenp 9203399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; 9213399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; 9223399Skvntemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; 9230Sduketemplate <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; 9243399Skvn 9253399Skvntemplate <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible 9263399Skvn : public __is_convertible<_T1, _T2> 9270Sduke{ 9280Sduke static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; 9290Sduke static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; 9300Sduke}; 9313399Skvn 9323399Skvn#endif // __has_feature(is_convertible_to) 9333399Skvn 9343399Skvn// is_empty 9353399Skvn 9363399Skvn#if __has_feature(is_empty) 9373399Skvn 9383399Skvntemplate <class _Tp> 9393399Skvnstruct _LIBCPP_TYPE_VIS_ONLY is_empty 9403399Skvn : public integral_constant<bool, __is_empty(_Tp)> {}; 9413399Skvn 9423399Skvn#else // __has_feature(is_empty) 9433399Skvn 9443399Skvntemplate <class _Tp> 9453399Skvnstruct __is_empty1 9463399Skvn : public _Tp 9473399Skvn{ 9483399Skvn double __lx; 9493399Skvn}; 9503399Skvn 9513399Skvnstruct __is_empty2 9523399Skvn{ 9533399Skvn double __lx; 9543399Skvn}; 9553399Skvn 9563399Skvntemplate <class _Tp, bool = is_class<_Tp>::value> 9570Sdukestruct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; 9580Sduke 9590Sduketemplate <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; 9600Sduke 9610Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {}; 9620Sduke 9630Sduke#endif // __has_feature(is_empty) 9640Sduke 9650Sduke// is_polymorphic 9663724Sroland 967293Skvn#if __has_feature(is_polymorphic) 968293Skvn 969293Skvntemplate <class _Tp> 970293Skvnstruct _LIBCPP_TYPE_VIS_ONLY is_polymorphic 9710Sduke : public integral_constant<bool, __is_polymorphic(_Tp)> {}; 9720Sduke 9730Sduke#else 9740Sduke 9750Sduketemplate<typename _Tp> char &__is_polymorphic_impl( 9760Sduke typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0, 9770Sduke int>::type); 9780Sduketemplate<typename _Tp> __two &__is_polymorphic_impl(...); 9790Sduke 9800Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic 9810Sduke : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; 9820Sduke 9830Sduke#endif // __has_feature(is_polymorphic) 9840Sduke 9850Sduke// has_virtual_destructor 9860Sduke 9870Sduke#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 9880Sduke 9890Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor 9900Sduke : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; 9913724Sroland 992293Skvn#else // _LIBCPP_HAS_TYPE_TRAITS 993293Skvn 994293Skvntemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor 995293Skvn : public false_type {}; 9960Sduke 9970Sduke#endif // _LIBCPP_HAS_TYPE_TRAITS 9980Sduke 9990Sduke// alignment_of 10000Sduke 10010Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of 10020Sduke : public integral_constant<size_t, __alignof__(_Tp)> {}; 10030Sduke 10040Sduke// aligned_storage 10050Sduke 10060Sduketemplate <class _Hp, class _Tp> 10070Sdukestruct __type_list 10080Sduke{ 10090Sduke typedef _Hp _Head; 10100Sduke typedef _Tp _Tail; 10110Sduke}; 10120Sduke 10130Sdukestruct __nat 10140Sduke{ 10150Sduke#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 10160Sduke __nat() = delete; 10170Sduke __nat(const __nat&) = delete; 10180Sduke __nat& operator=(const __nat&) = delete; 10190Sduke ~__nat() = delete; 10200Sduke#endif 10210Sduke}; 10220Sduke 10230Sduketemplate <class _Tp> 10240Sdukestruct __align_type 10250Sduke{ 10260Sduke static const size_t value = alignment_of<_Tp>::value; 10270Sduke typedef _Tp type; 10280Sduke}; 10290Sduke 10300Sdukestruct __struct_double {long double __lx;}; 10310Sdukestruct __struct_double4 {double __lx[4];}; 1032113Scoleenp 1033113Scoleenptypedef 1034113Scoleenp __type_list<__align_type<unsigned char>, 1035113Scoleenp __type_list<__align_type<unsigned short>, 1036221Skvn __type_list<__align_type<unsigned int>, 1037221Skvn __type_list<__align_type<unsigned long>, 1038113Scoleenp __type_list<__align_type<unsigned long long>, 1039113Scoleenp __type_list<__align_type<double>, 10404676Skvn __type_list<__align_type<long double>, 10414676Skvn __type_list<__align_type<__struct_double>, 10424676Skvn __type_list<__align_type<__struct_double4>, 1043113Scoleenp __type_list<__align_type<int*>, 10444676Skvn __nat 1045113Scoleenp > > > > > > > > > > __all_types; 1046113Scoleenp 1047113Scoleenptemplate <class _TL, size_t _Align> struct __find_pod; 1048113Scoleenp 1049113Scoleenptemplate <class _Hp, size_t _Align> 1050113Scoleenpstruct __find_pod<__type_list<_Hp, __nat>, _Align> 1051113Scoleenp{ 1052113Scoleenp typedef typename conditional< 1053113Scoleenp _Align == _Hp::value, 1054113Scoleenp typename _Hp::type, 1055113Scoleenp void 1056113Scoleenp >::type type; 1057113Scoleenp}; 1058113Scoleenp 1059113Scoleenptemplate <class _Hp, class _Tp, size_t _Align> 1060113Scoleenpstruct __find_pod<__type_list<_Hp, _Tp>, _Align> 1061113Scoleenp{ 1062113Scoleenp typedef typename conditional< 1063296Srasbold _Align == _Hp::value, 1064113Scoleenp typename _Hp::type, 1065296Srasbold typename __find_pod<_Tp, _Align>::type 1066296Srasbold >::type type; 10673602Scoleenp}; 1068113Scoleenp 1069113Scoleenptemplate <class _TL, size_t _Len> struct __find_max_align; 1070296Srasbold 1071296Srasboldtemplate <class _Hp, size_t _Len> 1072113Scoleenpstruct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; 1073296Srasbold 1074296Srasboldtemplate <size_t _Len, size_t _A1, size_t _A2> 1075113Scoleenpstruct __select_align 1076296Srasbold{ 1077296Srasboldprivate: 1078296Srasbold static const size_t __min = _A2 < _A1 ? _A2 : _A1; 1079296Srasbold static const size_t __max = _A1 < _A2 ? _A2 : _A1; 1080296Srasboldpublic: 1081296Srasbold static const size_t value = _Len < __max ? __min : __max; 1082296Srasbold}; 1083296Srasbold 1084296Srasboldtemplate <class _Hp, class _Tp, size_t _Len> 1085296Srasboldstruct __find_max_align<__type_list<_Hp, _Tp>, _Len> 1086113Scoleenp : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; 1087113Scoleenp 1088113Scoleenptemplate <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1089113Scoleenpstruct _LIBCPP_TYPE_VIS_ONLY aligned_storage 1090113Scoleenp{ 1091113Scoleenp typedef typename __find_pod<__all_types, _Align>::type _Aligner; 1092113Scoleenp static_assert(!is_void<_Aligner>::value, ""); 1093113Scoleenp union type 1094113Scoleenp { 1095113Scoleenp _Aligner __align; 1096113Scoleenp unsigned char __data[_Len]; 1097113Scoleenp }; 1098113Scoleenp}; 1099113Scoleenp 1100113Scoleenp#if _LIBCPP_STD_VER > 11 1101113Scoleenptemplate <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1102113Scoleenp using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; 1103113Scoleenp#endif 1104113Scoleenp 1105113Scoleenp#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ 1106113Scoleenptemplate <size_t _Len>\ 1107113Scoleenpstruct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ 1108113Scoleenp{\ 1109113Scoleenp struct _ALIGNAS(n) type\ 1110113Scoleenp {\ 11110Sduke unsigned char __lx[_Len];\ 11120Sduke };\ 11130Sduke} 111410006Sthartmann 11150Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); 11160Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); 11170Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); 11180Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); 11190Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); 11200Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); 11210Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); 11220Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); 11230Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); 11240Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); 11250Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); 11260Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); 11270Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); 11280Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); 11290Sduke// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000) 11300Sduke#if !defined(_LIBCPP_MSVC) 11310Sduke_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); 11320Sduke#endif // !_LIBCPP_MSVC 11330Sduke 11340Sduke#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION 11350Sduke 11360Sduke#ifndef _LIBCPP_HAS_NO_VARIADICS 11370Sduke 11380Sduke// aligned_union 11390Sduke 11400Sduketemplate <size_t _I0, size_t ..._In> 11410Sdukestruct __static_max; 11420Sduke 11430Sduketemplate <size_t _I0> 114410006Sthartmannstruct __static_max<_I0> 11450Sduke{ 11460Sduke static const size_t value = _I0; 11470Sduke}; 11480Sduke 11490Sduketemplate <size_t _I0, size_t _I1, size_t ..._In> 11500Sdukestruct __static_max<_I0, _I1, _In...> 11510Sduke{ 11520Sduke static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : 11530Sduke __static_max<_I1, _In...>::value; 11540Sduke}; 11550Sduke 11560Sduketemplate <size_t _Len, class _Type0, class ..._Types> 11570Sdukestruct aligned_union 11580Sduke{ 11590Sduke static const size_t alignment_value = __static_max<__alignof__(_Type0), 11600Sduke __alignof__(_Types)...>::value; 11610Sduke static const size_t __len = __static_max<_Len, sizeof(_Type0), 11620Sduke sizeof(_Types)...>::value; 11630Sduke typedef typename aligned_storage<__len, alignment_value>::type type; 11640Sduke}; 11650Sduke 11660Sduke#if _LIBCPP_STD_VER > 11 11670Sduketemplate <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; 11680Sduke#endif 11690Sduke 11700Sduke#endif // _LIBCPP_HAS_NO_VARIADICS 11710Sduke 11720Sduke// __promote 11730Sduke 11740Sduketemplate <class _A1, class _A2 = void, class _A3 = void, 11750Sduke bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) && 11760Sduke (is_arithmetic<_A2>::value || is_void<_A2>::value) && 11770Sduke (is_arithmetic<_A3>::value || is_void<_A3>::value)> 11780Sdukeclass __promote {}; 11790Sduke 11800Sduketemplate <class _A1, class _A2, class _A3> 11810Sdukeclass __promote<_A1, _A2, _A3, true> 11820Sduke{ 11830Sdukeprivate: 11840Sduke typedef typename __promote<_A1>::type __type1; 11850Sduke typedef typename __promote<_A2>::type __type2; 11860Sduke typedef typename __promote<_A3>::type __type3; 11870Sdukepublic: 11880Sduke typedef decltype(__type1() + __type2() + __type3()) type; 11890Sduke}; 11900Sduke 11910Sduketemplate <class _A1, class _A2> 11920Sdukeclass __promote<_A1, _A2, void, true> 11930Sduke{ 11940Sdukeprivate: 11950Sduke typedef typename __promote<_A1>::type __type1; 11960Sduke typedef typename __promote<_A2>::type __type2; 11970Sdukepublic: 11980Sduke typedef decltype(__type1() + __type2()) type; 11990Sduke}; 12000Sduke 12016546Sthartmanntemplate <class _A1> 12026546Sthartmannclass __promote<_A1, void, void, true> 12030Sduke{ 12040Sdukepublic: 12050Sduke typedef typename conditional<is_arithmetic<_A1>::value, 12060Sduke typename conditional<is_integral<_A1>::value, double, _A1>::type, 12070Sduke void 12080Sduke >::type type; 12090Sduke}; 12100Sduke 12110Sduke#ifdef _LIBCPP_STORE_AS_OPTIMIZATION 12120Sduke 12130Sduke// __transform 12140Sduke 12150Sduketemplate <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;}; 12160Sduketemplate <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;}; 12170Sduketemplate <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;}; 12180Sduketemplate <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;}; 12190Sduketemplate <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; 12200Sduke 12210Sduke#endif // _LIBCPP_STORE_AS_OPTIMIZATION 12220Sduke 12230Sduke// make_signed / make_unsigned 12240Sduke 12250Sduketypedef 12260Sduke __type_list<signed char, 12270Sduke __type_list<signed short, 12280Sduke __type_list<signed int, 12290Sduke __type_list<signed long, 12300Sduke __type_list<signed long long, 12310Sduke __nat 12320Sduke > > > > > __signed_types; 12330Sduke 12340Sduketypedef 12350Sduke __type_list<unsigned char, 12360Sduke __type_list<unsigned short, 12370Sduke __type_list<unsigned int, 12380Sduke __type_list<unsigned long, 12390Sduke __type_list<unsigned long long, 12405356Srbackman __nat 12416412Sdrchase > > > > > __unsigned_types; 12420Sduke 12430Sduketemplate <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; 12440Sduke 12450Sduketemplate <class _Hp, class _Tp, size_t _Size> 12460Sdukestruct __find_first<__type_list<_Hp, _Tp>, _Size, true> 12470Sduke{ 12480Sduke typedef _Hp type; 12490Sduke}; 12500Sduke 12510Sduketemplate <class _Hp, class _Tp, size_t _Size> 12520Sdukestruct __find_first<__type_list<_Hp, _Tp>, _Size, false> 12530Sduke{ 12540Sduke typedef typename __find_first<_Tp, _Size>::type type; 12550Sduke}; 12560Sduke 12570Sduketemplate <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, 12580Sduke bool = is_volatile<typename remove_reference<_Tp>::type>::value> 12590Sdukestruct __apply_cv 12600Sduke{ 12610Sduke typedef _Up type; 12620Sduke}; 12630Sduke 12640Sduketemplate <class _Tp, class _Up> 12650Sdukestruct __apply_cv<_Tp, _Up, true, false> 12660Sduke{ 12670Sduke typedef const _Up type; 12680Sduke}; 12690Sduke 12700Sduketemplate <class _Tp, class _Up> 12716546Sthartmannstruct __apply_cv<_Tp, _Up, false, true> 12720Sduke{ 12736546Sthartmann typedef volatile _Up type; 12740Sduke}; 12750Sduke 12760Sduketemplate <class _Tp, class _Up> 12770Sdukestruct __apply_cv<_Tp, _Up, true, true> 12780Sduke{ 12790Sduke typedef const volatile _Up type; 12806837Sthartmann}; 12810Sduke 12820Sduketemplate <class _Tp, class _Up> 12830Sdukestruct __apply_cv<_Tp&, _Up, false, false> 12840Sduke{ 12850Sduke typedef _Up& type; 12860Sduke}; 12870Sduke 12886546Sthartmanntemplate <class _Tp, class _Up> 12890Sdukestruct __apply_cv<_Tp&, _Up, true, false> 12900Sduke{ 12916902Sthartmann typedef const _Up& type; 12926902Sthartmann}; 12936902Sthartmann 12946902Sthartmanntemplate <class _Tp, class _Up> 12956902Sthartmannstruct __apply_cv<_Tp&, _Up, false, true> 12966902Sthartmann{ 12976902Sthartmann typedef volatile _Up& type; 12986902Sthartmann}; 12996902Sthartmann 13006902Sthartmanntemplate <class _Tp, class _Up> 13016902Sthartmannstruct __apply_cv<_Tp&, _Up, true, true> 13026902Sthartmann{ 13036902Sthartmann typedef const volatile _Up& type; 13046902Sthartmann}; 13056902Sthartmann 13066902Sthartmanntemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 13076902Sthartmannstruct __make_signed {}; 13086902Sthartmann 13096902Sthartmanntemplate <class _Tp> 13106902Sthartmannstruct __make_signed<_Tp, true> 13116902Sthartmann{ 13126902Sthartmann typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; 13136902Sthartmann}; 13146902Sthartmann 13156902Sthartmanntemplate <> struct __make_signed<bool, true> {}; 13166902Sthartmanntemplate <> struct __make_signed< signed short, true> {typedef short type;}; 13176902Sthartmanntemplate <> struct __make_signed<unsigned short, true> {typedef short type;}; 13186902Sthartmanntemplate <> struct __make_signed< signed int, true> {typedef int type;}; 13196902Sthartmanntemplate <> struct __make_signed<unsigned int, true> {typedef int type;}; 13206902Sthartmanntemplate <> struct __make_signed< signed long, true> {typedef long type;}; 13216902Sthartmanntemplate <> struct __make_signed<unsigned long, true> {typedef long type;}; 13226902Sthartmanntemplate <> struct __make_signed< signed long long, true> {typedef long long type;}; 13236902Sthartmanntemplate <> struct __make_signed<unsigned long long, true> {typedef long long type;}; 13246902Sthartmann 13256902Sthartmanntemplate <class _Tp> 13266902Sthartmannstruct _LIBCPP_TYPE_VIS_ONLY make_signed 13276902Sthartmann{ 13286902Sthartmann typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; 13296902Sthartmann}; 13306902Sthartmann 13316902Sthartmann#if _LIBCPP_STD_VER > 11 13326902Sthartmanntemplate <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; 13336902Sthartmann#endif 13346902Sthartmann 13356902Sthartmanntemplate <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 13366902Sthartmannstruct __make_unsigned {}; 13376902Sthartmann 13386902Sthartmanntemplate <class _Tp> 13390Sdukestruct __make_unsigned<_Tp, true> 13400Sduke{ 13410Sduke typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; 13420Sduke}; 13430Sduke 13440Sduketemplate <> struct __make_unsigned<bool, true> {}; 13450Sduketemplate <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; 13460Sduketemplate <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; 13476049Srbackmantemplate <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; 13480Sduketemplate <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; 13490Sduketemplate <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; 13500Sduketemplate <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; 13510Sduketemplate <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; 13526049Srbackmantemplate <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; 13536049Srbackman 13546049Srbackmantemplate <class _Tp> 13556049Srbackmanstruct _LIBCPP_TYPE_VIS_ONLY make_unsigned 13560Sduke{ 13570Sduke typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; 13580Sduke}; 13590Sduke 13600Sduke#if _LIBCPP_STD_VER > 11 13610Sduketemplate <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; 13620Sduke#endif 13630Sduke 13640Sduke#ifdef _LIBCPP_HAS_NO_VARIADICS 13650Sduke 13660Sduketemplate <class _Tp, class _Up = void, class V = void> 13670Sdukestruct _LIBCPP_TYPE_VIS_ONLY common_type 13680Sduke{ 13690Sdukepublic: 13700Sduke typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type; 13710Sduke}; 13720Sduke 13730Sduketemplate <class _Tp> 13746546Sthartmannstruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void> 13750Sduke{ 13760Sdukepublic: 13770Sduke typedef _Tp type; 13780Sduke}; 13790Sduke 13800Sduketemplate <class _Tp, class _Up> 13810Sdukestruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> 13820Sduke{ 13830Sdukeprivate: 13840Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 13850Sduke static _Tp&& __t(); 13860Sduke static _Up&& __u(); 13872505Skvn#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 13880Sduke static _Tp __t(); 13890Sduke static _Up __u(); 13900Sduke#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 13916546Sthartmannpublic: 13926546Sthartmann typedef typename remove_reference<decltype(true ? __t() : __u())>::type type; 13930Sduke}; 13940Sduke 139510071Skmo#else // _LIBCPP_HAS_NO_VARIADICS 139610071Skmo 139710071Skmotemplate <class ..._Tp> struct common_type; 139810071Skmo 139910071Skmotemplate <class _Tp> 140010071Skmostruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> 140110071Skmo{ 140210071Skmo typedef typename decay<_Tp>::type type; 140310071Skmo}; 140410071Skmo 140510071Skmotemplate <class _Tp, class _Up> 140610071Skmostruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> 140710071Skmo{ 140810071Skmoprivate: 140910071Skmo static _Tp&& __t(); 141010071Skmo static _Up&& __u(); 141110071Skmo static bool __f(); 141210071Skmopublic: 141310071Skmo typedef typename decay<decltype(__f() ? __t() : __u())>::type type; 141410071Skmo}; 141510071Skmo 141610071Skmotemplate <class _Tp, class _Up, class ..._Vp> 141710071Skmostruct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> 141810071Skmo{ 141910071Skmo typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; 142010071Skmo}; 142110071Skmo 142210071Skmo#if _LIBCPP_STD_VER > 11 142310071Skmotemplate <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; 142410071Skmo#endif 142510071Skmo 142610071Skmo#endif // _LIBCPP_HAS_NO_VARIADICS 142710071Skmo 142810071Skmo// is_assignable 142910071Skmo 143010071Skmotemplate<typename, typename _Tp> struct __select_2nd { typedef _Tp type; }; 143110071Skmo 143210071Skmotemplate <class _Tp, class _Arg> 143310071Skmotypename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type 143410071Skmo#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 143510071Skmo__is_assignable_test(_Tp&&, _Arg&&); 143610071Skmo#else 143710071Skmo__is_assignable_test(_Tp, _Arg&); 143810071Skmo#endif 143910071Skmo 144010071Skmotemplate <class _Arg> 144110071Skmofalse_type 144210071Skmo#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 144310071Skmo__is_assignable_test(__any, _Arg&&); 144410071Skmo#else 144510071Skmo__is_assignable_test(__any, _Arg&); 144610071Skmo#endif 144710071Skmo 144810071Skmotemplate <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> 144910071Skmostruct __is_assignable_imp 145010071Skmo : public common_type 145110071Skmo < 145210071Skmo decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>())) 145310071Skmo >::type {}; 14540Sduke 14550Sduketemplate <class _Tp, class _Arg> 14560Sdukestruct __is_assignable_imp<_Tp, _Arg, true> 14570Sduke : public false_type 14580Sduke{ 14590Sduke}; 14600Sduke 14610Sduketemplate <class _Tp, class _Arg> 14626546Sthartmannstruct is_assignable 14636546Sthartmann : public __is_assignable_imp<_Tp, _Arg> {}; 14640Sduke 14656546Sthartmann// is_copy_assignable 14660Sduke 14670Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable 14680Sduke : public is_assignable<typename add_lvalue_reference<_Tp>::type, 14690Sduke const typename add_lvalue_reference<_Tp>::type> {}; 14700Sduke 14710Sduke// is_move_assignable 14720Sduke 14730Sduketemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable 14740Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 14756546Sthartmann : public is_assignable<typename add_lvalue_reference<_Tp>::type, 14766546Sthartmann const typename add_rvalue_reference<_Tp>::type> {}; 14770Sduke#else 14780Sduke : public is_copy_assignable<_Tp> {}; 14790Sduke#endif 14800Sduke 14810Sduke// is_destructible 14820Sduke 14830Sduketemplate <class _Tp> 14840Sdukestruct __destructible_test 14850Sduke{ 14860Sduke _Tp __t; 14876546Sthartmann}; 14886546Sthartmann 14890Sduketemplate <class _Tp> 14900Sdukedecltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type())) 14916902Sthartmann#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 14926902Sthartmann__is_destructible_test(_Tp&&); 14936902Sthartmann#else 14940Sduke__is_destructible_test(_Tp&); 14950Sduke#endif 14960Sduke 14970Sdukefalse_type 14980Sduke__is_destructible_test(__any); 14990Sduke 15000Sduketemplate <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value 15010Sduke || is_function<_Tp>::value> 15020Sdukestruct __destructible_imp 15030Sduke : public common_type 15040Sduke < 15050Sduke decltype(__is_destructible_test(declval<_Tp>())) 15060Sduke >::type {}; 15070Sduke 15080Sduketemplate <class _Tp> 15090Sdukestruct __destructible_imp<_Tp, true> 15100Sduke : public false_type {}; 15110Sduke 15120Sduketemplate <class _Tp> 15130Sdukestruct is_destructible 15140Sduke : public __destructible_imp<_Tp> {}; 15150Sduke 15160Sduketemplate <class _Tp> 15170Sdukestruct is_destructible<_Tp[]> 15180Sduke : public false_type {}; 15190Sduke 15200Sduke// move 15210Sduke 15220Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 15230Sduke 15240Sduketemplate <class _Tp> 15250Sdukeinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 15260Sduketypename remove_reference<_Tp>::type&& 15270Sdukemove(_Tp&& __t) _NOEXCEPT 15280Sduke{ 15290Sduke typedef typename remove_reference<_Tp>::type _Up; 15300Sduke return static_cast<_Up&&>(__t); 15310Sduke} 15320Sduke 15330Sduketemplate <class _Tp> 15340Sdukeinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 15350Sduke_Tp&& 15360Sdukeforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT 15370Sduke{ 15380Sduke return static_cast<_Tp&&>(__t); 15390Sduke} 15400Sduke 15410Sduketemplate <class _Tp> 15420Sdukeinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 154310006Sthartmann_Tp&& 15440Sdukeforward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT 15450Sduke{ 15460Sduke static_assert(!std::is_lvalue_reference<_Tp>::value, 15478797Smhaupt "Can not forward an rvalue as an lvalue."); 15480Sduke return static_cast<_Tp&&>(__t); 15490Sduke} 15500Sduke 15510Sduke#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 15520Sduke 15530Sduketemplate <class _Tp> 15540Sdukeinline _LIBCPP_INLINE_VISIBILITY 15558797Smhaupt_Tp& 15568797Smhauptmove(_Tp& __t) 15578797Smhaupt{ 15588797Smhaupt return __t; 15598797Smhaupt} 15608797Smhaupt 15618797Smhaupttemplate <class _Tp> 15628797Smhauptinline _LIBCPP_INLINE_VISIBILITY 15638797Smhauptconst _Tp& 15648797Smhauptmove(const _Tp& __t) 15658797Smhaupt{ 15668797Smhaupt return __t; 15678797Smhaupt} 15688797Smhaupt 15690Sduketemplate <class _Tp> 15700Sdukeinline _LIBCPP_INLINE_VISIBILITY 15718797Smhaupt_Tp& 15720Sdukeforward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT 15730Sduke{ 15740Sduke return __t; 15750Sduke} 15760Sduke 15770Sduke 15780Sduketemplate <class _Tp> 15790Sdukeclass __rv 15800Sduke{ 15810Sduke typedef typename remove_reference<_Tp>::type _Trr; 15820Sduke _Trr& t_; 15830Sdukepublic: 15840Sduke _LIBCPP_INLINE_VISIBILITY 15850Sduke _Trr* operator->() {return &t_;} 158610006Sthartmann _LIBCPP_INLINE_VISIBILITY 15870Sduke explicit __rv(_Trr& __t) : t_(__t) {} 15880Sduke}; 15890Sduke 15900Sduke#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 15910Sduke 15920Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 15930Sduke 1594template <class _Tp> 1595inline _LIBCPP_INLINE_VISIBILITY 1596typename decay<_Tp>::type 1597__decay_copy(_Tp&& __t) 1598{ 1599 return _VSTD::forward<_Tp>(__t); 1600} 1601 1602#else 1603 1604template <class _Tp> 1605inline _LIBCPP_INLINE_VISIBILITY 1606typename decay<_Tp>::type 1607__decay_copy(const _Tp& __t) 1608{ 1609 return _VSTD::forward<_Tp>(__t); 1610} 1611 1612#endif 1613 1614#ifndef _LIBCPP_HAS_NO_VARIADICS 1615 1616template <class _Rp, class _Class, class ..._Param> 1617struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> 1618{ 1619 typedef _Class _ClassType; 1620 typedef _Rp _ReturnType; 1621 typedef _Rp (_FnType) (_Param...); 1622}; 1623 1624template <class _Rp, class _Class, class ..._Param> 1625struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> 1626{ 1627 typedef _Class const _ClassType; 1628 typedef _Rp _ReturnType; 1629 typedef _Rp (_FnType) (_Param...); 1630}; 1631 1632template <class _Rp, class _Class, class ..._Param> 1633struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> 1634{ 1635 typedef _Class volatile _ClassType; 1636 typedef _Rp _ReturnType; 1637 typedef _Rp (_FnType) (_Param...); 1638}; 1639 1640template <class _Rp, class _Class, class ..._Param> 1641struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> 1642{ 1643 typedef _Class const volatile _ClassType; 1644 typedef _Rp _ReturnType; 1645 typedef _Rp (_FnType) (_Param...); 1646}; 1647 1648#if __has_feature(cxx_reference_qualified_functions) 1649 1650template <class _Rp, class _Class, class ..._Param> 1651struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> 1652{ 1653 typedef _Class& _ClassType; 1654 typedef _Rp _ReturnType; 1655 typedef _Rp (_FnType) (_Param...); 1656}; 1657 1658template <class _Rp, class _Class, class ..._Param> 1659struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> 1660{ 1661 typedef _Class const& _ClassType; 1662 typedef _Rp _ReturnType; 1663 typedef _Rp (_FnType) (_Param...); 1664}; 1665 1666template <class _Rp, class _Class, class ..._Param> 1667struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> 1668{ 1669 typedef _Class volatile& _ClassType; 1670 typedef _Rp _ReturnType; 1671 typedef _Rp (_FnType) (_Param...); 1672}; 1673 1674template <class _Rp, class _Class, class ..._Param> 1675struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> 1676{ 1677 typedef _Class const volatile& _ClassType; 1678 typedef _Rp _ReturnType; 1679 typedef _Rp (_FnType) (_Param...); 1680}; 1681 1682template <class _Rp, class _Class, class ..._Param> 1683struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> 1684{ 1685 typedef _Class&& _ClassType; 1686 typedef _Rp _ReturnType; 1687 typedef _Rp (_FnType) (_Param...); 1688}; 1689 1690template <class _Rp, class _Class, class ..._Param> 1691struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> 1692{ 1693 typedef _Class const&& _ClassType; 1694 typedef _Rp _ReturnType; 1695 typedef _Rp (_FnType) (_Param...); 1696}; 1697 1698template <class _Rp, class _Class, class ..._Param> 1699struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> 1700{ 1701 typedef _Class volatile&& _ClassType; 1702 typedef _Rp _ReturnType; 1703 typedef _Rp (_FnType) (_Param...); 1704}; 1705 1706template <class _Rp, class _Class, class ..._Param> 1707struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> 1708{ 1709 typedef _Class const volatile&& _ClassType; 1710 typedef _Rp _ReturnType; 1711 typedef _Rp (_FnType) (_Param...); 1712}; 1713 1714#endif // __has_feature(cxx_reference_qualified_functions) 1715 1716#else // _LIBCPP_HAS_NO_VARIADICS 1717 1718template <class _Rp, class _Class> 1719struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> 1720{ 1721 typedef _Class _ClassType; 1722 typedef _Rp _ReturnType; 1723 typedef _Rp (_FnType) (); 1724}; 1725 1726template <class _Rp, class _Class, class _P0> 1727struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> 1728{ 1729 typedef _Class _ClassType; 1730 typedef _Rp _ReturnType; 1731 typedef _Rp (_FnType) (_P0); 1732}; 1733 1734template <class _Rp, class _Class, class _P0, class _P1> 1735struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> 1736{ 1737 typedef _Class _ClassType; 1738 typedef _Rp _ReturnType; 1739 typedef _Rp (_FnType) (_P0, _P1); 1740}; 1741 1742template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1743struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> 1744{ 1745 typedef _Class _ClassType; 1746 typedef _Rp _ReturnType; 1747 typedef _Rp (_FnType) (_P0, _P1, _P2); 1748}; 1749 1750template <class _Rp, class _Class> 1751struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> 1752{ 1753 typedef _Class const _ClassType; 1754 typedef _Rp _ReturnType; 1755 typedef _Rp (_FnType) (); 1756}; 1757 1758template <class _Rp, class _Class, class _P0> 1759struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> 1760{ 1761 typedef _Class const _ClassType; 1762 typedef _Rp _ReturnType; 1763 typedef _Rp (_FnType) (_P0); 1764}; 1765 1766template <class _Rp, class _Class, class _P0, class _P1> 1767struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> 1768{ 1769 typedef _Class const _ClassType; 1770 typedef _Rp _ReturnType; 1771 typedef _Rp (_FnType) (_P0, _P1); 1772}; 1773 1774template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1775struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false> 1776{ 1777 typedef _Class const _ClassType; 1778 typedef _Rp _ReturnType; 1779 typedef _Rp (_FnType) (_P0, _P1, _P2); 1780}; 1781 1782template <class _Rp, class _Class> 1783struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> 1784{ 1785 typedef _Class volatile _ClassType; 1786 typedef _Rp _ReturnType; 1787 typedef _Rp (_FnType) (); 1788}; 1789 1790template <class _Rp, class _Class, class _P0> 1791struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> 1792{ 1793 typedef _Class volatile _ClassType; 1794 typedef _Rp _ReturnType; 1795 typedef _Rp (_FnType) (_P0); 1796}; 1797 1798template <class _Rp, class _Class, class _P0, class _P1> 1799struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false> 1800{ 1801 typedef _Class volatile _ClassType; 1802 typedef _Rp _ReturnType; 1803 typedef _Rp (_FnType) (_P0, _P1); 1804}; 1805 1806template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1807struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false> 1808{ 1809 typedef _Class volatile _ClassType; 1810 typedef _Rp _ReturnType; 1811 typedef _Rp (_FnType) (_P0, _P1, _P2); 1812}; 1813 1814template <class _Rp, class _Class> 1815struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false> 1816{ 1817 typedef _Class const volatile _ClassType; 1818 typedef _Rp _ReturnType; 1819 typedef _Rp (_FnType) (); 1820}; 1821 1822template <class _Rp, class _Class, class _P0> 1823struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false> 1824{ 1825 typedef _Class const volatile _ClassType; 1826 typedef _Rp _ReturnType; 1827 typedef _Rp (_FnType) (_P0); 1828}; 1829 1830template <class _Rp, class _Class, class _P0, class _P1> 1831struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false> 1832{ 1833 typedef _Class const volatile _ClassType; 1834 typedef _Rp _ReturnType; 1835 typedef _Rp (_FnType) (_P0, _P1); 1836}; 1837 1838template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1839struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false> 1840{ 1841 typedef _Class const volatile _ClassType; 1842 typedef _Rp _ReturnType; 1843 typedef _Rp (_FnType) (_P0, _P1, _P2); 1844}; 1845 1846#endif // _LIBCPP_HAS_NO_VARIADICS 1847 1848template <class _Rp, class _Class> 1849struct __member_pointer_traits_imp<_Rp _Class::*, false, true> 1850{ 1851 typedef _Class _ClassType; 1852 typedef _Rp _ReturnType; 1853}; 1854 1855template <class _MP> 1856struct __member_pointer_traits 1857 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type, 1858 is_member_function_pointer<_MP>::value, 1859 is_member_object_pointer<_MP>::value> 1860{ 1861// typedef ... _ClassType; 1862// typedef ... _ReturnType; 1863// typedef ... _FnType; 1864}; 1865 1866// result_of 1867 1868template <class _Callable> class result_of; 1869 1870#ifdef _LIBCPP_HAS_NO_VARIADICS 1871 1872template <class _Fn, bool, bool> 1873class __result_of 1874{ 1875}; 1876 1877template <class _Fn> 1878class __result_of<_Fn(), true, false> 1879{ 1880public: 1881 typedef decltype(declval<_Fn>()()) type; 1882}; 1883 1884template <class _Fn, class _A0> 1885class __result_of<_Fn(_A0), true, false> 1886{ 1887public: 1888 typedef decltype(declval<_Fn>()(declval<_A0>())) type; 1889}; 1890 1891template <class _Fn, class _A0, class _A1> 1892class __result_of<_Fn(_A0, _A1), true, false> 1893{ 1894public: 1895 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; 1896}; 1897 1898template <class _Fn, class _A0, class _A1, class _A2> 1899class __result_of<_Fn(_A0, _A1, _A2), true, false> 1900{ 1901public: 1902 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; 1903}; 1904 1905template <class _MP, class _Tp, bool _IsMemberFunctionPtr> 1906struct __result_of_mp; 1907 1908// member function pointer 1909 1910template <class _MP, class _Tp> 1911struct __result_of_mp<_MP, _Tp, true> 1912 : public common_type<typename __member_pointer_traits<_MP>::_ReturnType> 1913{ 1914}; 1915 1916// member data pointer 1917 1918template <class _MP, class _Tp, bool> 1919struct __result_of_mdp; 1920 1921template <class _Rp, class _Class, class _Tp> 1922struct __result_of_mdp<_Rp _Class::*, _Tp, false> 1923{ 1924 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type; 1925}; 1926 1927template <class _Rp, class _Class, class _Tp> 1928struct __result_of_mdp<_Rp _Class::*, _Tp, true> 1929{ 1930 typedef typename __apply_cv<_Tp, _Rp>::type& type; 1931}; 1932 1933template <class _Rp, class _Class, class _Tp> 1934struct __result_of_mp<_Rp _Class::*, _Tp, false> 1935 : public __result_of_mdp<_Rp _Class::*, _Tp, 1936 is_base_of<_Class, typename remove_reference<_Tp>::type>::value> 1937{ 1938}; 1939 1940 1941 1942template <class _Fn, class _Tp> 1943class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer 1944 : public __result_of_mp<typename remove_reference<_Fn>::type, 1945 _Tp, 1946 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1947{ 1948}; 1949 1950template <class _Fn, class _Tp, class _A0> 1951class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer 1952 : public __result_of_mp<typename remove_reference<_Fn>::type, 1953 _Tp, 1954 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1955{ 1956}; 1957 1958template <class _Fn, class _Tp, class _A0, class _A1> 1959class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer 1960 : public __result_of_mp<typename remove_reference<_Fn>::type, 1961 _Tp, 1962 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1963{ 1964}; 1965 1966template <class _Fn, class _Tp, class _A0, class _A1, class _A2> 1967class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer 1968 : public __result_of_mp<typename remove_reference<_Fn>::type, 1969 _Tp, 1970 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1971{ 1972}; 1973 1974// result_of 1975 1976template <class _Fn> 1977class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()> 1978 : public __result_of<_Fn(), 1979 is_class<typename remove_reference<_Fn>::type>::value || 1980 is_function<typename remove_reference<_Fn>::type>::value, 1981 is_member_pointer<typename remove_reference<_Fn>::type>::value 1982 > 1983{ 1984}; 1985 1986template <class _Fn, class _A0> 1987class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)> 1988 : public __result_of<_Fn(_A0), 1989 is_class<typename remove_reference<_Fn>::type>::value || 1990 is_function<typename remove_reference<_Fn>::type>::value, 1991 is_member_pointer<typename remove_reference<_Fn>::type>::value 1992 > 1993{ 1994}; 1995 1996template <class _Fn, class _A0, class _A1> 1997class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)> 1998 : public __result_of<_Fn(_A0, _A1), 1999 is_class<typename remove_reference<_Fn>::type>::value || 2000 is_function<typename remove_reference<_Fn>::type>::value, 2001 is_member_pointer<typename remove_reference<_Fn>::type>::value 2002 > 2003{ 2004}; 2005 2006template <class _Fn, class _A0, class _A1, class _A2> 2007class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)> 2008 : public __result_of<_Fn(_A0, _A1, _A2), 2009 is_class<typename remove_reference<_Fn>::type>::value || 2010 is_function<typename remove_reference<_Fn>::type>::value, 2011 is_member_pointer<typename remove_reference<_Fn>::type>::value 2012 > 2013{ 2014}; 2015 2016#endif // _LIBCPP_HAS_NO_VARIADICS 2017 2018#ifndef _LIBCPP_HAS_NO_VARIADICS 2019 2020// template <class T, class... Args> struct is_constructible; 2021 2022// main is_constructible test 2023 2024template <class _Tp, class ..._Args> 2025typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type 2026__is_constructible_test(_Tp&&, _Args&& ...); 2027 2028template <class ..._Args> 2029false_type 2030__is_constructible_test(__any, _Args&& ...); 2031 2032template <bool, class _Tp, class... _Args> 2033struct __is_constructible // false, _Tp is not a scalar 2034 : public common_type 2035 < 2036 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...)) 2037 >::type 2038 {}; 2039 2040// function types are not constructible 2041 2042template <class _Rp, class... _A1, class... _A2> 2043struct __is_constructible<false, _Rp(_A1...), _A2...> 2044 : public false_type 2045 {}; 2046 2047// handle scalars and reference types 2048 2049// Scalars are default constructible, references are not 2050 2051template <class _Tp> 2052struct __is_constructible<true, _Tp> 2053 : public is_scalar<_Tp> 2054 {}; 2055 2056// Scalars and references are constructible from one arg if that arg is 2057// implicitly convertible to the scalar or reference. 2058 2059template <class _Tp> 2060struct __is_constructible_ref 2061{ 2062 true_type static __lxx(_Tp); 2063 false_type static __lxx(...); 2064}; 2065 2066template <class _Tp, class _A0> 2067struct __is_constructible<true, _Tp, _A0> 2068 : public common_type 2069 < 2070 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>())) 2071 >::type 2072 {}; 2073 2074// Scalars and references are not constructible from multiple args. 2075 2076template <class _Tp, class _A0, class ..._Args> 2077struct __is_constructible<true, _Tp, _A0, _Args...> 2078 : public false_type 2079 {}; 2080 2081// Treat scalars and reference types separately 2082 2083template <bool, class _Tp, class... _Args> 2084struct __is_constructible_void_check 2085 : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2086 _Tp, _Args...> 2087 {}; 2088 2089// If any of T or Args is void, is_constructible should be false 2090 2091template <class _Tp, class... _Args> 2092struct __is_constructible_void_check<true, _Tp, _Args...> 2093 : public false_type 2094 {}; 2095 2096template <class ..._Args> struct __contains_void; 2097 2098template <> struct __contains_void<> : false_type {}; 2099 2100template <class _A0, class ..._Args> 2101struct __contains_void<_A0, _Args...> 2102{ 2103 static const bool value = is_void<_A0>::value || 2104 __contains_void<_Args...>::value; 2105}; 2106 2107// is_constructible entry point 2108 2109template <class _Tp, class... _Args> 2110struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2111 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value 2112 || is_abstract<_Tp>::value, 2113 _Tp, _Args...> 2114 {}; 2115 2116// Array types are default constructible if their element type 2117// is default constructible 2118 2119template <class _Ap, size_t _Np> 2120struct __is_constructible<false, _Ap[_Np]> 2121 : public is_constructible<typename remove_all_extents<_Ap>::type> 2122 {}; 2123 2124// Otherwise array types are not constructible by this syntax 2125 2126template <class _Ap, size_t _Np, class ..._Args> 2127struct __is_constructible<false, _Ap[_Np], _Args...> 2128 : public false_type 2129 {}; 2130 2131// Incomplete array types are not constructible 2132 2133template <class _Ap, class ..._Args> 2134struct __is_constructible<false, _Ap[], _Args...> 2135 : public false_type 2136 {}; 2137 2138#else // _LIBCPP_HAS_NO_VARIADICS 2139 2140// template <class T> struct is_constructible0; 2141 2142// main is_constructible0 test 2143 2144template <class _Tp> 2145decltype((_Tp(), true_type())) 2146__is_constructible0_test(_Tp&); 2147 2148false_type 2149__is_constructible0_test(__any); 2150 2151template <class _Tp, class _A0> 2152decltype((_Tp(_VSTD::declval<_A0>()), true_type())) 2153__is_constructible1_test(_Tp&, _A0&); 2154 2155template <class _A0> 2156false_type 2157__is_constructible1_test(__any, _A0&); 2158 2159template <class _Tp, class _A0, class _A1> 2160decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) 2161__is_constructible2_test(_Tp&, _A0&, _A1&); 2162 2163template <class _A0, class _A1> 2164false_type 2165__is_constructible2_test(__any, _A0&, _A1&); 2166 2167template <bool, class _Tp> 2168struct __is_constructible0_imp // false, _Tp is not a scalar 2169 : public common_type 2170 < 2171 decltype(__is_constructible0_test(declval<_Tp&>())) 2172 >::type 2173 {}; 2174 2175template <bool, class _Tp, class _A0> 2176struct __is_constructible1_imp // false, _Tp is not a scalar 2177 : public common_type 2178 < 2179 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) 2180 >::type 2181 {}; 2182 2183template <bool, class _Tp, class _A0, class _A1> 2184struct __is_constructible2_imp // false, _Tp is not a scalar 2185 : public common_type 2186 < 2187 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) 2188 >::type 2189 {}; 2190 2191// handle scalars and reference types 2192 2193// Scalars are default constructible, references are not 2194 2195template <class _Tp> 2196struct __is_constructible0_imp<true, _Tp> 2197 : public is_scalar<_Tp> 2198 {}; 2199 2200template <class _Tp, class _A0> 2201struct __is_constructible1_imp<true, _Tp, _A0> 2202 : public is_convertible<_A0, _Tp> 2203 {}; 2204 2205template <class _Tp, class _A0, class _A1> 2206struct __is_constructible2_imp<true, _Tp, _A0, _A1> 2207 : public false_type 2208 {}; 2209 2210// Treat scalars and reference types separately 2211 2212template <bool, class _Tp> 2213struct __is_constructible0_void_check 2214 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2215 _Tp> 2216 {}; 2217 2218template <bool, class _Tp, class _A0> 2219struct __is_constructible1_void_check 2220 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2221 _Tp, _A0> 2222 {}; 2223 2224template <bool, class _Tp, class _A0, class _A1> 2225struct __is_constructible2_void_check 2226 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2227 _Tp, _A0, _A1> 2228 {}; 2229 2230// If any of T or Args is void, is_constructible should be false 2231 2232template <class _Tp> 2233struct __is_constructible0_void_check<true, _Tp> 2234 : public false_type 2235 {}; 2236 2237template <class _Tp, class _A0> 2238struct __is_constructible1_void_check<true, _Tp, _A0> 2239 : public false_type 2240 {}; 2241 2242template <class _Tp, class _A0, class _A1> 2243struct __is_constructible2_void_check<true, _Tp, _A0, _A1> 2244 : public false_type 2245 {}; 2246 2247// is_constructible entry point 2248 2249namespace __is_construct 2250{ 2251 2252struct __nat {}; 2253 2254} 2255 2256template <class _Tp, class _A0 = __is_construct::__nat, 2257 class _A1 = __is_construct::__nat> 2258struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2259 : public __is_constructible2_void_check<is_void<_Tp>::value 2260 || is_abstract<_Tp>::value 2261 || is_function<_Tp>::value 2262 || is_void<_A0>::value 2263 || is_void<_A1>::value, 2264 _Tp, _A0, _A1> 2265 {}; 2266 2267template <class _Tp> 2268struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> 2269 : public __is_constructible0_void_check<is_void<_Tp>::value 2270 || is_abstract<_Tp>::value 2271 || is_function<_Tp>::value, 2272 _Tp> 2273 {}; 2274 2275template <class _Tp, class _A0> 2276struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat> 2277 : public __is_constructible1_void_check<is_void<_Tp>::value 2278 || is_abstract<_Tp>::value 2279 || is_function<_Tp>::value 2280 || is_void<_A0>::value, 2281 _Tp, _A0> 2282 {}; 2283 2284// Array types are default constructible if their element type 2285// is default constructible 2286 2287template <class _Ap, size_t _Np> 2288struct __is_constructible0_imp<false, _Ap[_Np]> 2289 : public is_constructible<typename remove_all_extents<_Ap>::type> 2290 {}; 2291 2292template <class _Ap, size_t _Np, class _A0> 2293struct __is_constructible1_imp<false, _Ap[_Np], _A0> 2294 : public false_type 2295 {}; 2296 2297template <class _Ap, size_t _Np, class _A0, class _A1> 2298struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1> 2299 : public false_type 2300 {}; 2301 2302// Incomplete array types are not constructible 2303 2304template <class _Ap> 2305struct __is_constructible0_imp<false, _Ap[]> 2306 : public false_type 2307 {}; 2308 2309template <class _Ap, class _A0> 2310struct __is_constructible1_imp<false, _Ap[], _A0> 2311 : public false_type 2312 {}; 2313 2314template <class _Ap, class _A0, class _A1> 2315struct __is_constructible2_imp<false, _Ap[], _A0, _A1> 2316 : public false_type 2317 {}; 2318 2319#endif // _LIBCPP_HAS_NO_VARIADICS 2320 2321// is_default_constructible 2322 2323template <class _Tp> 2324struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible 2325 : public is_constructible<_Tp> 2326 {}; 2327 2328// is_copy_constructible 2329 2330template <class _Tp> 2331struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible 2332 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2333 {}; 2334 2335// is_move_constructible 2336 2337template <class _Tp> 2338struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible 2339#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2340 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2341#else 2342 : public is_copy_constructible<_Tp> 2343#endif 2344 {}; 2345 2346// is_trivially_constructible 2347 2348#ifndef _LIBCPP_HAS_NO_VARIADICS 2349 2350#if __has_feature(is_trivially_constructible) 2351 2352template <class _Tp, class... _Args> 2353struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2354 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> 2355{ 2356}; 2357 2358#else // !__has_feature(is_trivially_constructible) 2359 2360template <class _Tp, class... _Args> 2361struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2362 : false_type 2363{ 2364}; 2365 2366template <class _Tp> 2367struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> 2368#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2369 : integral_constant<bool, __has_trivial_constructor(_Tp)> 2370#else 2371 : integral_constant<bool, is_scalar<_Tp>::value> 2372#endif 2373{ 2374}; 2375 2376template <class _Tp> 2377#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2378struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&> 2379#else 2380struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp> 2381#endif 2382 : integral_constant<bool, is_scalar<_Tp>::value> 2383{ 2384}; 2385 2386template <class _Tp> 2387struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&> 2388 : integral_constant<bool, is_scalar<_Tp>::value> 2389{ 2390}; 2391 2392template <class _Tp> 2393struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&> 2394 : integral_constant<bool, is_scalar<_Tp>::value> 2395{ 2396}; 2397 2398#endif // !__has_feature(is_trivially_constructible) 2399 2400#else // _LIBCPP_HAS_NO_VARIADICS 2401 2402template <class _Tp, class _A0 = __is_construct::__nat, 2403 class _A1 = __is_construct::__nat> 2404struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2405 : false_type 2406{ 2407}; 2408 2409#if __has_feature(is_trivially_constructible) 2410 2411template <class _Tp> 2412struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, 2413 __is_construct::__nat> 2414 : integral_constant<bool, __is_trivially_constructible(_Tp)> 2415{ 2416}; 2417 2418template <class _Tp> 2419struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, 2420 __is_construct::__nat> 2421 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)> 2422{ 2423}; 2424 2425template <class _Tp> 2426struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, 2427 __is_construct::__nat> 2428 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)> 2429{ 2430}; 2431 2432template <class _Tp> 2433struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, 2434 __is_construct::__nat> 2435 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)> 2436{ 2437}; 2438 2439#else // !__has_feature(is_trivially_constructible) 2440 2441template <class _Tp> 2442struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, 2443 __is_construct::__nat> 2444 : integral_constant<bool, is_scalar<_Tp>::value> 2445{ 2446}; 2447 2448template <class _Tp> 2449struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, 2450 __is_construct::__nat> 2451 : integral_constant<bool, is_scalar<_Tp>::value> 2452{ 2453}; 2454 2455template <class _Tp> 2456struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, 2457 __is_construct::__nat> 2458 : integral_constant<bool, is_scalar<_Tp>::value> 2459{ 2460}; 2461 2462template <class _Tp> 2463struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, 2464 __is_construct::__nat> 2465 : integral_constant<bool, is_scalar<_Tp>::value> 2466{ 2467}; 2468 2469#endif // !__has_feature(is_trivially_constructible) 2470 2471#endif // _LIBCPP_HAS_NO_VARIADICS 2472 2473// is_trivially_default_constructible 2474 2475template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible 2476 : public is_trivially_constructible<_Tp> 2477 {}; 2478 2479// is_trivially_copy_constructible 2480 2481template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible 2482 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> 2483 {}; 2484 2485// is_trivially_move_constructible 2486 2487template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible 2488#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2489 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2490#else 2491 : public is_trivially_copy_constructible<_Tp> 2492#endif 2493 {}; 2494 2495// is_trivially_assignable 2496 2497#if __has_feature(is_trivially_constructible) 2498 2499template <class _Tp, class _Arg> 2500struct is_trivially_assignable 2501 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> 2502{ 2503}; 2504 2505#else // !__has_feature(is_trivially_constructible) 2506 2507template <class _Tp, class _Arg> 2508struct is_trivially_assignable 2509 : public false_type {}; 2510 2511template <class _Tp> 2512struct is_trivially_assignable<_Tp&, _Tp> 2513 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2514 2515template <class _Tp> 2516struct is_trivially_assignable<_Tp&, _Tp&> 2517 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2518 2519template <class _Tp> 2520struct is_trivially_assignable<_Tp&, const _Tp&> 2521 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2522 2523#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2524 2525template <class _Tp> 2526struct is_trivially_assignable<_Tp&, _Tp&&> 2527 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2528 2529#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2530 2531#endif // !__has_feature(is_trivially_constructible) 2532 2533// is_trivially_copy_assignable 2534 2535template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable 2536 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2537 const typename add_lvalue_reference<_Tp>::type> 2538 {}; 2539 2540// is_trivially_move_assignable 2541 2542template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable 2543 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2544#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2545 typename add_rvalue_reference<_Tp>::type> 2546#else 2547 typename add_lvalue_reference<_Tp>::type> 2548#endif 2549 {}; 2550 2551// is_trivially_destructible 2552 2553#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2554 2555template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible 2556 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {}; 2557 2558#else // _LIBCPP_HAS_TYPE_TRAITS 2559 2560template <class _Tp> struct __libcpp_trivial_destructor 2561 : public integral_constant<bool, is_scalar<_Tp>::value || 2562 is_reference<_Tp>::value> {}; 2563 2564template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible 2565 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; 2566 2567#endif // _LIBCPP_HAS_TYPE_TRAITS 2568 2569// is_nothrow_constructible 2570 2571#if 0 2572template <class _Tp, class... _Args> 2573struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2574 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))> 2575{ 2576}; 2577 2578#else 2579 2580#ifndef _LIBCPP_HAS_NO_VARIADICS 2581 2582#if __has_feature(cxx_noexcept) 2583 2584template <bool, class _Tp, class... _Args> struct __is_nothrow_constructible; 2585 2586template <class _Tp, class... _Args> 2587struct __is_nothrow_constructible<true, _Tp, _Args...> 2588 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 2589{ 2590}; 2591 2592template <class _Tp, class... _Args> 2593struct __is_nothrow_constructible<false, _Tp, _Args...> 2594 : public false_type 2595{ 2596}; 2597 2598template <class _Tp, class... _Args> 2599struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2600 : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...> 2601{ 2602}; 2603 2604template <class _Tp, size_t _Ns> 2605struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> 2606 : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp> 2607{ 2608}; 2609 2610#else // __has_feature(cxx_noexcept) 2611 2612template <class _Tp, class... _Args> 2613struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2614 : false_type 2615{ 2616}; 2617 2618template <class _Tp> 2619struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> 2620#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2621 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2622#else 2623 : integral_constant<bool, is_scalar<_Tp>::value> 2624#endif 2625{ 2626}; 2627 2628template <class _Tp> 2629#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2630struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> 2631#else 2632struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> 2633#endif 2634#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2635 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2636#else 2637 : integral_constant<bool, is_scalar<_Tp>::value> 2638#endif 2639{ 2640}; 2641 2642template <class _Tp> 2643struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> 2644#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2645 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2646#else 2647 : integral_constant<bool, is_scalar<_Tp>::value> 2648#endif 2649{ 2650}; 2651 2652template <class _Tp> 2653struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> 2654#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2655 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2656#else 2657 : integral_constant<bool, is_scalar<_Tp>::value> 2658#endif 2659{ 2660}; 2661 2662#endif // __has_feature(cxx_noexcept) 2663 2664#else // _LIBCPP_HAS_NO_VARIADICS 2665 2666template <class _Tp, class _A0 = __is_construct::__nat, 2667 class _A1 = __is_construct::__nat> 2668struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2669 : false_type 2670{ 2671}; 2672 2673template <class _Tp> 2674struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat, 2675 __is_construct::__nat> 2676#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2677 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2678#else 2679 : integral_constant<bool, is_scalar<_Tp>::value> 2680#endif 2681{ 2682}; 2683 2684template <class _Tp> 2685struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, 2686 __is_construct::__nat> 2687#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2688 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2689#else 2690 : integral_constant<bool, is_scalar<_Tp>::value> 2691#endif 2692{ 2693}; 2694 2695template <class _Tp> 2696struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, 2697 __is_construct::__nat> 2698#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2699 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2700#else 2701 : integral_constant<bool, is_scalar<_Tp>::value> 2702#endif 2703{ 2704}; 2705 2706template <class _Tp> 2707struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, 2708 __is_construct::__nat> 2709#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2710 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2711#else 2712 : integral_constant<bool, is_scalar<_Tp>::value> 2713#endif 2714{ 2715}; 2716 2717#endif // _LIBCPP_HAS_NO_VARIADICS 2718#endif // __has_feature(is_nothrow_constructible) 2719 2720// is_nothrow_default_constructible 2721 2722template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible 2723 : public is_nothrow_constructible<_Tp> 2724 {}; 2725 2726// is_nothrow_copy_constructible 2727 2728template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible 2729 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2730 {}; 2731 2732// is_nothrow_move_constructible 2733 2734template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible 2735#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2736 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2737#else 2738 : public is_nothrow_copy_constructible<_Tp> 2739#endif 2740 {}; 2741 2742// is_nothrow_assignable 2743 2744#if __has_feature(cxx_noexcept) 2745 2746template <bool, class _Tp, class _Arg> struct __is_nothrow_assignable; 2747 2748template <class _Tp, class _Arg> 2749struct __is_nothrow_assignable<false, _Tp, _Arg> 2750 : public false_type 2751{ 2752}; 2753 2754template <class _Tp, class _Arg> 2755struct __is_nothrow_assignable<true, _Tp, _Arg> 2756 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > 2757{ 2758}; 2759 2760template <class _Tp, class _Arg> 2761struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable 2762 : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> 2763{ 2764}; 2765 2766#else // __has_feature(cxx_noexcept) 2767 2768template <class _Tp, class _Arg> 2769struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable 2770 : public false_type {}; 2771 2772template <class _Tp> 2773struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> 2774#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2775 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2776#else 2777 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2778#endif 2779 2780template <class _Tp> 2781struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&> 2782#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2783 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2784#else 2785 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2786#endif 2787 2788template <class _Tp> 2789struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> 2790#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2791 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2792#else 2793 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2794#endif 2795 2796#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2797 2798template <class _Tp> 2799struct is_nothrow_assignable<_Tp&, _Tp&&> 2800#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2801 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2802#else 2803 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2804#endif 2805 2806#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2807 2808#endif // __has_feature(cxx_noexcept) 2809 2810// is_nothrow_copy_assignable 2811 2812template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable 2813 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2814 const typename add_lvalue_reference<_Tp>::type> 2815 {}; 2816 2817// is_nothrow_move_assignable 2818 2819template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable 2820 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2821#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2822 typename add_rvalue_reference<_Tp>::type> 2823#else 2824 typename add_lvalue_reference<_Tp>::type> 2825#endif 2826 {}; 2827 2828// is_nothrow_destructible 2829 2830#if __has_feature(cxx_noexcept) 2831 2832template <bool, class _Tp> struct __is_nothrow_destructible; 2833 2834template <class _Tp> 2835struct __is_nothrow_destructible<false, _Tp> 2836 : public false_type 2837{ 2838}; 2839 2840template <class _Tp> 2841struct __is_nothrow_destructible<true, _Tp> 2842 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > 2843{ 2844}; 2845 2846template <class _Tp> 2847struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible 2848 : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> 2849{ 2850}; 2851 2852template <class _Tp, size_t _Ns> 2853struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]> 2854 : public is_nothrow_destructible<_Tp> 2855{ 2856}; 2857 2858template <class _Tp> 2859struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&> 2860 : public true_type 2861{ 2862}; 2863 2864#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2865 2866template <class _Tp> 2867struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&> 2868 : public true_type 2869{ 2870}; 2871 2872#endif 2873 2874#else 2875 2876template <class _Tp> struct __libcpp_nothrow_destructor 2877 : public integral_constant<bool, is_scalar<_Tp>::value || 2878 is_reference<_Tp>::value> {}; 2879 2880template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible 2881 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; 2882 2883#endif 2884 2885// is_pod 2886 2887#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2888 2889template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod 2890 : public integral_constant<bool, __is_pod(_Tp)> {}; 2891 2892#else // _LIBCPP_HAS_TYPE_TRAITS 2893 2894template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod 2895 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && 2896 is_trivially_copy_constructible<_Tp>::value && 2897 is_trivially_copy_assignable<_Tp>::value && 2898 is_trivially_destructible<_Tp>::value> {}; 2899 2900#endif // _LIBCPP_HAS_TYPE_TRAITS 2901 2902// is_literal_type; 2903 2904template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type 2905#if __has_feature(is_literal) 2906 : public integral_constant<bool, __is_literal(_Tp)> 2907#else 2908 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value || 2909 is_reference<typename remove_all_extents<_Tp>::type>::value> 2910#endif 2911 {}; 2912 2913// is_standard_layout; 2914 2915template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout 2916#if __has_feature(is_standard_layout) 2917 : public integral_constant<bool, __is_standard_layout(_Tp)> 2918#else 2919 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2920#endif 2921 {}; 2922 2923// is_trivially_copyable; 2924 2925template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable 2926#if __has_feature(is_trivially_copyable) 2927 : public integral_constant<bool, __is_trivially_copyable(_Tp)> 2928#else 2929 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2930#endif 2931 {}; 2932 2933// is_trivial; 2934 2935template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial 2936#if __has_feature(is_trivial) 2937 : public integral_constant<bool, __is_trivial(_Tp)> 2938#else 2939 : integral_constant<bool, is_trivially_copyable<_Tp>::value && 2940 is_trivially_default_constructible<_Tp>::value> 2941#endif 2942 {}; 2943 2944#ifndef _LIBCPP_HAS_NO_VARIADICS 2945 2946// Check for complete types 2947 2948template <class ..._Tp> struct __check_complete; 2949 2950template <> 2951struct __check_complete<> 2952{ 2953}; 2954 2955template <class _Hp, class _T0, class ..._Tp> 2956struct __check_complete<_Hp, _T0, _Tp...> 2957 : private __check_complete<_Hp>, 2958 private __check_complete<_T0, _Tp...> 2959{ 2960}; 2961 2962template <class _Hp> 2963struct __check_complete<_Hp, _Hp> 2964 : private __check_complete<_Hp> 2965{ 2966}; 2967 2968template <class _Tp> 2969struct __check_complete<_Tp> 2970{ 2971 static_assert(sizeof(_Tp) > 0, "Type must be complete."); 2972}; 2973 2974template <class _Tp> 2975struct __check_complete<_Tp&> 2976 : private __check_complete<_Tp> 2977{ 2978}; 2979 2980template <class _Tp> 2981struct __check_complete<_Tp&&> 2982 : private __check_complete<_Tp> 2983{ 2984}; 2985 2986template <class _Rp, class ..._Param> 2987struct __check_complete<_Rp (*)(_Param...)> 2988 : private __check_complete<_Rp> 2989{ 2990}; 2991 2992template <class ..._Param> 2993struct __check_complete<void (*)(_Param...)> 2994{ 2995}; 2996 2997template <class _Rp, class ..._Param> 2998struct __check_complete<_Rp (_Param...)> 2999 : private __check_complete<_Rp> 3000{ 3001}; 3002 3003template <class ..._Param> 3004struct __check_complete<void (_Param...)> 3005{ 3006}; 3007 3008template <class _Rp, class _Class, class ..._Param> 3009struct __check_complete<_Rp (_Class::*)(_Param...)> 3010 : private __check_complete<_Class> 3011{ 3012}; 3013 3014template <class _Rp, class _Class, class ..._Param> 3015struct __check_complete<_Rp (_Class::*)(_Param...) const> 3016 : private __check_complete<_Class> 3017{ 3018}; 3019 3020template <class _Rp, class _Class, class ..._Param> 3021struct __check_complete<_Rp (_Class::*)(_Param...) volatile> 3022 : private __check_complete<_Class> 3023{ 3024}; 3025 3026template <class _Rp, class _Class, class ..._Param> 3027struct __check_complete<_Rp (_Class::*)(_Param...) const volatile> 3028 : private __check_complete<_Class> 3029{ 3030}; 3031 3032#if __has_feature(cxx_reference_qualified_functions) 3033 3034template <class _Rp, class _Class, class ..._Param> 3035struct __check_complete<_Rp (_Class::*)(_Param...) &> 3036 : private __check_complete<_Class> 3037{ 3038}; 3039 3040template <class _Rp, class _Class, class ..._Param> 3041struct __check_complete<_Rp (_Class::*)(_Param...) const&> 3042 : private __check_complete<_Class> 3043{ 3044}; 3045 3046template <class _Rp, class _Class, class ..._Param> 3047struct __check_complete<_Rp (_Class::*)(_Param...) volatile&> 3048 : private __check_complete<_Class> 3049{ 3050}; 3051 3052template <class _Rp, class _Class, class ..._Param> 3053struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&> 3054 : private __check_complete<_Class> 3055{ 3056}; 3057 3058template <class _Rp, class _Class, class ..._Param> 3059struct __check_complete<_Rp (_Class::*)(_Param...) &&> 3060 : private __check_complete<_Class> 3061{ 3062}; 3063 3064template <class _Rp, class _Class, class ..._Param> 3065struct __check_complete<_Rp (_Class::*)(_Param...) const&&> 3066 : private __check_complete<_Class> 3067{ 3068}; 3069 3070template <class _Rp, class _Class, class ..._Param> 3071struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&> 3072 : private __check_complete<_Class> 3073{ 3074}; 3075 3076template <class _Rp, class _Class, class ..._Param> 3077struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&> 3078 : private __check_complete<_Class> 3079{ 3080}; 3081 3082#endif 3083 3084template <class _Rp, class _Class> 3085struct __check_complete<_Rp _Class::*> 3086 : private __check_complete<_Class> 3087{ 3088}; 3089 3090// __invoke forward declarations 3091 3092// fall back - none of the bullets 3093 3094template <class ..._Args> 3095auto 3096__invoke(__any, _Args&& ...__args) 3097 -> __nat; 3098 3099// bullets 1 and 2 3100 3101template <class _Fp, class _A0, class ..._Args, 3102 class = typename enable_if 3103 < 3104 is_member_function_pointer<typename remove_reference<_Fp>::type>::value && 3105 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3106 typename remove_reference<_A0>::type>::value 3107 >::type 3108 > 3109_LIBCPP_INLINE_VISIBILITY 3110auto 3111__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3112 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)); 3113 3114template <class _Fp, class _A0, class ..._Args, 3115 class = typename enable_if 3116 < 3117 is_member_function_pointer<typename remove_reference<_Fp>::type>::value && 3118 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3119 typename remove_reference<_A0>::type>::value 3120 >::type 3121 > 3122_LIBCPP_INLINE_VISIBILITY 3123auto 3124__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3125 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)); 3126 3127// bullets 3 and 4 3128 3129template <class _Fp, class _A0, 3130 class = typename enable_if 3131 < 3132 is_member_object_pointer<typename remove_reference<_Fp>::type>::value && 3133 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3134 typename remove_reference<_A0>::type>::value 3135 >::type 3136 > 3137_LIBCPP_INLINE_VISIBILITY 3138auto 3139__invoke(_Fp&& __f, _A0&& __a0) 3140 -> decltype(_VSTD::forward<_A0>(__a0).*__f); 3141 3142template <class _Fp, class _A0, 3143 class = typename enable_if 3144 < 3145 is_member_object_pointer<typename remove_reference<_Fp>::type>::value && 3146 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3147 typename remove_reference<_A0>::type>::value 3148 >::type 3149 > 3150_LIBCPP_INLINE_VISIBILITY 3151auto 3152__invoke(_Fp&& __f, _A0&& __a0) 3153 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f); 3154 3155// bullet 5 3156 3157template <class _Fp, class ..._Args> 3158_LIBCPP_INLINE_VISIBILITY 3159auto 3160__invoke(_Fp&& __f, _Args&& ...__args) 3161 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)); 3162 3163// __invokable 3164 3165template <class _Fp, class ..._Args> 3166struct __invokable_imp 3167 : private __check_complete<_Fp> 3168{ 3169 typedef decltype( 3170 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...) 3171 ) type; 3172 static const bool value = !is_same<type, __nat>::value; 3173}; 3174 3175template <class _Fp, class ..._Args> 3176struct __invokable 3177 : public integral_constant<bool, 3178 __invokable_imp<_Fp, _Args...>::value> 3179{ 3180}; 3181 3182// __invoke_of 3183 3184template <bool _Invokable, class _Fp, class ..._Args> 3185struct __invoke_of_imp // false 3186{ 3187}; 3188 3189template <class _Fp, class ..._Args> 3190struct __invoke_of_imp<true, _Fp, _Args...> 3191{ 3192 typedef typename __invokable_imp<_Fp, _Args...>::type type; 3193}; 3194 3195template <class _Fp, class ..._Args> 3196struct __invoke_of 3197 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...> 3198{ 3199}; 3200 3201template <class _Fp, class ..._Args> 3202class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)> 3203 : public __invoke_of<_Fp, _Args...> 3204{ 3205}; 3206 3207#if _LIBCPP_STD_VER > 11 3208template <class _Tp> using result_of_t = typename result_of<_Tp>::type; 3209#endif 3210 3211#endif // _LIBCPP_HAS_NO_VARIADICS 3212 3213template <class _Tp> 3214inline _LIBCPP_INLINE_VISIBILITY 3215#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 3216typename enable_if 3217< 3218 is_move_constructible<_Tp>::value && 3219 is_move_assignable<_Tp>::value 3220>::type 3221#else 3222void 3223#endif 3224swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && 3225 is_nothrow_move_assignable<_Tp>::value) 3226{ 3227 _Tp __t(_VSTD::move(__x)); 3228 __x = _VSTD::move(__y); 3229 __y = _VSTD::move(__t); 3230} 3231 3232template <class _ForwardIterator1, class _ForwardIterator2> 3233inline _LIBCPP_INLINE_VISIBILITY 3234void 3235iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) 3236 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) 3237 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), 3238 *_VSTD::declval<_ForwardIterator2>()))) 3239{ 3240 swap(*__a, *__b); 3241} 3242 3243// __swappable 3244 3245namespace __detail 3246{ 3247 3248using _VSTD::swap; 3249__nat swap(__any, __any); 3250 3251template <class _Tp> 3252struct __swappable 3253{ 3254 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type; 3255 static const bool value = !is_same<type, __nat>::value; 3256}; 3257 3258} // __detail 3259 3260template <class _Tp> 3261struct __is_swappable 3262 : public integral_constant<bool, __detail::__swappable<_Tp>::value> 3263{ 3264}; 3265 3266#if __has_feature(cxx_noexcept) 3267 3268template <bool, class _Tp> 3269struct __is_nothrow_swappable_imp 3270 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(), 3271 _VSTD::declval<_Tp&>()))> 3272{ 3273}; 3274 3275template <class _Tp> 3276struct __is_nothrow_swappable_imp<false, _Tp> 3277 : public false_type 3278{ 3279}; 3280 3281template <class _Tp> 3282struct __is_nothrow_swappable 3283 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp> 3284{ 3285}; 3286 3287#else // __has_feature(cxx_noexcept) 3288 3289template <class _Tp> 3290struct __is_nothrow_swappable 3291 : public false_type 3292{ 3293}; 3294 3295#endif // __has_feature(cxx_noexcept) 3296 3297#ifdef _LIBCXX_UNDERLYING_TYPE 3298 3299template <class _Tp> 3300struct underlying_type 3301{ 3302 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; 3303}; 3304 3305#if _LIBCPP_STD_VER > 11 3306template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; 3307#endif 3308 3309#else // _LIBCXX_UNDERLYING_TYPE 3310 3311template <class _Tp, bool _Support = false> 3312struct underlying_type 3313{ 3314 static_assert(_Support, "The underyling_type trait requires compiler " 3315 "support. Either no such support exists or " 3316 "libc++ does not know how to use it."); 3317}; 3318 3319#endif // _LIBCXX_UNDERLYING_TYPE 3320 3321#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 3322 3323template <class _Tp> 3324struct __has_operator_addressof_imp 3325{ 3326 template <class> 3327 static auto __test(__any) -> false_type; 3328 template <class _Up> 3329 static auto __test(_Up* __u) 3330 -> typename __select_2nd<decltype(__u->operator&()), true_type>::type; 3331 3332 static const bool value = decltype(__test<_Tp>(nullptr))::value; 3333}; 3334 3335template <class _Tp> 3336struct __has_operator_addressof 3337 : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value> 3338{}; 3339 3340#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 3341 3342_LIBCPP_END_NAMESPACE_STD 3343 3344#endif // _LIBCPP_TYPE_TRAITS 3345