type_traits revision 276517
1// -*- C++ -*- 2//===------------------------ type_traits ---------------------------------===// 3// 4// The LLVM Compiler Infrastructure 5// 6// This file is dual licensed under the MIT and the University of Illinois Open 7// Source Licenses. See LICENSE.TXT for details. 8// 9//===----------------------------------------------------------------------===// 10 11#ifndef _LIBCPP_TYPE_TRAITS 12#define _LIBCPP_TYPE_TRAITS 13 14/* 15 type_traits synopsis 16 17namespace std 18{ 19 20 // helper class: 21 template <class T, T v> struct integral_constant; 22 typedef integral_constant<bool, true> true_type; 23 typedef integral_constant<bool, false> false_type; 24 25 // helper traits 26 template <bool, class T = void> struct enable_if; 27 template <bool, class T, class F> struct conditional; 28 29 // Primary classification traits: 30 template <class T> struct is_void; 31 template <class T> struct is_null_pointer; // C++14 32 template <class T> struct is_integral; 33 template <class T> struct is_floating_point; 34 template <class T> struct is_array; 35 template <class T> struct is_pointer; 36 template <class T> struct is_lvalue_reference; 37 template <class T> struct is_rvalue_reference; 38 template <class T> struct is_member_object_pointer; 39 template <class T> struct is_member_function_pointer; 40 template <class T> struct is_enum; 41 template <class T> struct is_union; 42 template <class T> struct is_class; 43 template <class T> struct is_function; 44 45 // Secondary classification traits: 46 template <class T> struct is_reference; 47 template <class T> struct is_arithmetic; 48 template <class T> struct is_fundamental; 49 template <class T> struct is_member_pointer; 50 template <class T> struct is_scalar; 51 template <class T> struct is_object; 52 template <class T> struct is_compound; 53 54 // Const-volatile properties and transformations: 55 template <class T> struct is_const; 56 template <class T> struct is_volatile; 57 template <class T> struct remove_const; 58 template <class T> struct remove_volatile; 59 template <class T> struct remove_cv; 60 template <class T> struct add_const; 61 template <class T> struct add_volatile; 62 template <class T> struct add_cv; 63 64 // Reference transformations: 65 template <class T> struct remove_reference; 66 template <class T> struct add_lvalue_reference; 67 template <class T> struct add_rvalue_reference; 68 69 // Pointer transformations: 70 template <class T> struct remove_pointer; 71 template <class T> struct add_pointer; 72 73 // Integral properties: 74 template <class T> struct is_signed; 75 template <class T> struct is_unsigned; 76 template <class T> struct make_signed; 77 template <class T> struct make_unsigned; 78 79 // Array properties and transformations: 80 template <class T> struct rank; 81 template <class T, unsigned I = 0> struct extent; 82 template <class T> struct remove_extent; 83 template <class T> struct remove_all_extents; 84 85 // Member introspection: 86 template <class T> struct is_pod; 87 template <class T> struct is_trivial; 88 template <class T> struct is_trivially_copyable; 89 template <class T> struct is_standard_layout; 90 template <class T> struct is_literal_type; 91 template <class T> struct is_empty; 92 template <class T> struct is_polymorphic; 93 template <class T> struct is_abstract; 94 95 template <class T, class... Args> struct is_constructible; 96 template <class T> struct is_default_constructible; 97 template <class T> struct is_copy_constructible; 98 template <class T> struct is_move_constructible; 99 template <class T, class U> struct is_assignable; 100 template <class T> struct is_copy_assignable; 101 template <class T> struct is_move_assignable; 102 template <class T> struct is_destructible; 103 104 template <class T, class... Args> struct is_trivially_constructible; 105 template <class T> struct is_trivially_default_constructible; 106 template <class T> struct is_trivially_copy_constructible; 107 template <class T> struct is_trivially_move_constructible; 108 template <class T, class U> struct is_trivially_assignable; 109 template <class T> struct is_trivially_copy_assignable; 110 template <class T> struct is_trivially_move_assignable; 111 template <class T> struct is_trivially_destructible; 112 113 template <class T, class... Args> struct is_nothrow_constructible; 114 template <class T> struct is_nothrow_default_constructible; 115 template <class T> struct is_nothrow_copy_constructible; 116 template <class T> struct is_nothrow_move_constructible; 117 template <class T, class U> struct is_nothrow_assignable; 118 template <class T> struct is_nothrow_copy_assignable; 119 template <class T> struct is_nothrow_move_assignable; 120 template <class T> struct is_nothrow_destructible; 121 122 template <class T> struct has_virtual_destructor; 123 124 // Relationships between types: 125 template <class T, class U> struct is_same; 126 template <class Base, class Derived> struct is_base_of; 127 template <class From, class To> struct is_convertible; 128 129 // Alignment properties and transformations: 130 template <class T> struct alignment_of; 131 template <size_t Len, size_t Align = most_stringent_alignment_requirement> 132 struct aligned_storage; 133 template <size_t Len, class... Types> struct aligned_union; 134 135 template <class T> struct decay; 136 template <class... T> struct common_type; 137 template <class T> struct underlying_type; 138 template <class> class result_of; // undefined 139 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; 140 141 // const-volatile modifications: 142 template <class T> 143 using remove_const_t = typename remove_const<T>::type; // C++14 144 template <class T> 145 using remove_volatile_t = typename remove_volatile<T>::type; // C++14 146 template <class T> 147 using remove_cv_t = typename remove_cv<T>::type; // C++14 148 template <class T> 149 using add_const_t = typename add_const<T>::type; // C++14 150 template <class T> 151 using add_volatile_t = typename add_volatile<T>::type; // C++14 152 template <class T> 153 using add_cv_t = typename add_cv<T>::type; // C++14 154 155 // reference modifications: 156 template <class T> 157 using remove_reference_t = typename remove_reference<T>::type; // C++14 158 template <class T> 159 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14 160 template <class T> 161 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14 162 163 // sign modifications: 164 template <class T> 165 using make_signed_t = typename make_signed<T>::type; // C++14 166 template <class T> 167 using make_unsigned_t = typename make_unsigned<T>::type; // C++14 168 169 // array modifications: 170 template <class T> 171 using remove_extent_t = typename remove_extent<T>::type; // C++14 172 template <class T> 173 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14 174 175 // pointer modifications: 176 template <class T> 177 using remove_pointer_t = typename remove_pointer<T>::type; // C++14 178 template <class T> 179 using add_pointer_t = typename add_pointer<T>::type; // C++14 180 181 // other transformations: 182 template <size_t Len, std::size_t Align=default-alignment> 183 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14 184 template <std::size_t Len, class... Types> 185 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14 186 template <class T> 187 using decay_t = typename decay<T>::type; // C++14 188 template <bool b, class T=void> 189 using enable_if_t = typename enable_if<b,T>::type; // C++14 190 template <bool b, class T, class F> 191 using conditional_t = typename conditional<b,T,F>::type; // C++14 192 template <class... T> 193 using common_type_t = typename common_type<T...>::type; // C++14 194 template <class T> 195 using underlying_type_t = typename underlying_type<T>::type; // C++14 196 template <class F, class... ArgTypes> 197 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14 198 199} // std 200 201*/ 202#include <__config> 203#include <cstddef> 204 205#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 206#pragma GCC system_header 207#endif 208 209_LIBCPP_BEGIN_NAMESPACE_STD 210 211template <bool _Bp, class _If, class _Then> 212 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; 213template <class _If, class _Then> 214 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;}; 215 216#if _LIBCPP_STD_VER > 11 217template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; 218#endif 219 220template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {}; 221template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;}; 222 223#if _LIBCPP_STD_VER > 11 224template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; 225#endif 226 227 228struct __two {char __lx[2];}; 229 230// helper class: 231 232template <class _Tp, _Tp __v> 233struct _LIBCPP_TYPE_VIS_ONLY integral_constant 234{ 235 static _LIBCPP_CONSTEXPR const _Tp value = __v; 236 typedef _Tp value_type; 237 typedef integral_constant type; 238 _LIBCPP_INLINE_VISIBILITY 239 _LIBCPP_CONSTEXPR operator value_type() const {return value;} 240#if _LIBCPP_STD_VER > 11 241 _LIBCPP_INLINE_VISIBILITY 242 constexpr value_type operator ()() const {return value;} 243#endif 244}; 245 246template <class _Tp, _Tp __v> 247_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; 248 249typedef integral_constant<bool, true> true_type; 250typedef integral_constant<bool, false> false_type; 251 252// is_const 253 254template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; 255template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; 256 257// is_volatile 258 259template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; 260template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; 261 262// remove_const 263 264template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; 265template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;}; 266#if _LIBCPP_STD_VER > 11 267template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; 268#endif 269 270// remove_volatile 271 272template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; 273template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;}; 274#if _LIBCPP_STD_VER > 11 275template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; 276#endif 277 278// remove_cv 279 280template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv 281{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; 282#if _LIBCPP_STD_VER > 11 283template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; 284#endif 285 286// is_void 287 288template <class _Tp> struct __libcpp_is_void : public false_type {}; 289template <> struct __libcpp_is_void<void> : public true_type {}; 290 291template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void 292 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; 293 294// __is_nullptr_t 295 296template <class _Tp> struct __libcpp___is_nullptr : public false_type {}; 297template <> struct __libcpp___is_nullptr<nullptr_t> : public true_type {}; 298 299template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t 300 : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {}; 301 302#if _LIBCPP_STD_VER > 11 303template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer 304 : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {}; 305#endif 306 307// is_integral 308 309template <class _Tp> struct __libcpp_is_integral : public false_type {}; 310template <> struct __libcpp_is_integral<bool> : public true_type {}; 311template <> struct __libcpp_is_integral<char> : public true_type {}; 312template <> struct __libcpp_is_integral<signed char> : public true_type {}; 313template <> struct __libcpp_is_integral<unsigned char> : public true_type {}; 314template <> struct __libcpp_is_integral<wchar_t> : public true_type {}; 315#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 316template <> struct __libcpp_is_integral<char16_t> : public true_type {}; 317template <> struct __libcpp_is_integral<char32_t> : public true_type {}; 318#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 319template <> struct __libcpp_is_integral<short> : public true_type {}; 320template <> struct __libcpp_is_integral<unsigned short> : public true_type {}; 321template <> struct __libcpp_is_integral<int> : public true_type {}; 322template <> struct __libcpp_is_integral<unsigned int> : public true_type {}; 323template <> struct __libcpp_is_integral<long> : public true_type {}; 324template <> struct __libcpp_is_integral<unsigned long> : public true_type {}; 325template <> struct __libcpp_is_integral<long long> : public true_type {}; 326template <> struct __libcpp_is_integral<unsigned long long> : public true_type {}; 327 328template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral 329 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; 330 331// is_floating_point 332 333template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; 334template <> struct __libcpp_is_floating_point<float> : public true_type {}; 335template <> struct __libcpp_is_floating_point<double> : public true_type {}; 336template <> struct __libcpp_is_floating_point<long double> : public true_type {}; 337 338template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point 339 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; 340 341// is_array 342 343template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array 344 : public false_type {}; 345template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> 346 : public true_type {}; 347template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> 348 : public true_type {}; 349 350// is_pointer 351 352template <class _Tp> struct __libcpp_is_pointer : public false_type {}; 353template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; 354 355template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer 356 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {}; 357 358// is_reference 359 360template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; 361template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {}; 362 363template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {}; 364#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 365template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {}; 366#endif 367 368template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {}; 369template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {}; 370#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 371template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; 372#endif 373 374#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 375#define _LIBCPP_HAS_TYPE_TRAITS 376#endif 377 378// is_union 379 380#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 381 382template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union 383 : public integral_constant<bool, __is_union(_Tp)> {}; 384 385#else 386 387template <class _Tp> struct __libcpp_union : public false_type {}; 388template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union 389 : public __libcpp_union<typename remove_cv<_Tp>::type> {}; 390 391#endif 392 393// is_class 394 395#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 396 397template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class 398 : public integral_constant<bool, __is_class(_Tp)> {}; 399 400#else 401 402namespace __is_class_imp 403{ 404template <class _Tp> char __test(int _Tp::*); 405template <class _Tp> __two __test(...); 406} 407 408template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class 409 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; 410 411#endif 412 413// is_same 414 415template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; 416template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; 417 418// is_function 419 420namespace __is_function_imp 421{ 422template <class _Tp> char __test(_Tp*); 423template <class _Tp> __two __test(...); 424template <class _Tp> _Tp& __source(); 425} 426 427template <class _Tp, bool = is_class<_Tp>::value || 428 is_union<_Tp>::value || 429 is_void<_Tp>::value || 430 is_reference<_Tp>::value || 431 __is_nullptr_t<_Tp>::value > 432struct __libcpp_is_function 433 : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1> 434 {}; 435template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {}; 436 437template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function 438 : public __libcpp_is_function<_Tp> {}; 439 440// is_member_function_pointer 441 442// template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {}; 443// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; 444// 445 446template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr> 447struct __member_pointer_traits_imp 448{ // forward declaration; specializations later 449}; 450 451 452namespace __libcpp_is_member_function_pointer_imp { 453 template <typename _Tp> 454 char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *); 455 456 template <typename> 457 std::__two __test(...); 458}; 459 460template <class _Tp> struct __libcpp_is_member_function_pointer 461 : public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {}; 462 463template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer 464 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {}; 465 466// is_member_pointer 467 468template <class _Tp> struct __libcpp_is_member_pointer : public false_type {}; 469template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; 470 471template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer 472 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {}; 473 474// is_member_object_pointer 475 476template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer 477 : public integral_constant<bool, is_member_pointer<_Tp>::value && 478 !is_member_function_pointer<_Tp>::value> {}; 479 480// is_enum 481 482#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 483 484template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum 485 : public integral_constant<bool, __is_enum(_Tp)> {}; 486 487#else 488 489template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum 490 : public integral_constant<bool, !is_void<_Tp>::value && 491 !is_integral<_Tp>::value && 492 !is_floating_point<_Tp>::value && 493 !is_array<_Tp>::value && 494 !is_pointer<_Tp>::value && 495 !is_reference<_Tp>::value && 496 !is_member_pointer<_Tp>::value && 497 !is_union<_Tp>::value && 498 !is_class<_Tp>::value && 499 !is_function<_Tp>::value > {}; 500 501#endif 502 503// is_arithmetic 504 505template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic 506 : public integral_constant<bool, is_integral<_Tp>::value || 507 is_floating_point<_Tp>::value> {}; 508 509// is_fundamental 510 511template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental 512 : public integral_constant<bool, is_void<_Tp>::value || 513 __is_nullptr_t<_Tp>::value || 514 is_arithmetic<_Tp>::value> {}; 515 516// is_scalar 517 518template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar 519 : public integral_constant<bool, is_arithmetic<_Tp>::value || 520 is_member_pointer<_Tp>::value || 521 is_pointer<_Tp>::value || 522 __is_nullptr_t<_Tp>::value || 523 is_enum<_Tp>::value > {}; 524 525template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {}; 526 527// is_object 528 529template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object 530 : public integral_constant<bool, is_scalar<_Tp>::value || 531 is_array<_Tp>::value || 532 is_union<_Tp>::value || 533 is_class<_Tp>::value > {}; 534 535// is_compound 536 537template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound 538 : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; 539 540// add_const 541 542template <class _Tp, bool = is_reference<_Tp>::value || 543 is_function<_Tp>::value || 544 is_const<_Tp>::value > 545struct __add_const {typedef _Tp type;}; 546 547template <class _Tp> 548struct __add_const<_Tp, false> {typedef const _Tp type;}; 549 550template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const 551 {typedef typename __add_const<_Tp>::type type;}; 552 553#if _LIBCPP_STD_VER > 11 554template <class _Tp> using add_const_t = typename add_const<_Tp>::type; 555#endif 556 557// add_volatile 558 559template <class _Tp, bool = is_reference<_Tp>::value || 560 is_function<_Tp>::value || 561 is_volatile<_Tp>::value > 562struct __add_volatile {typedef _Tp type;}; 563 564template <class _Tp> 565struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; 566 567template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile 568 {typedef typename __add_volatile<_Tp>::type type;}; 569 570#if _LIBCPP_STD_VER > 11 571template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; 572#endif 573 574// add_cv 575 576template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv 577 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;}; 578 579#if _LIBCPP_STD_VER > 11 580template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; 581#endif 582 583// remove_reference 584 585template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;}; 586template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;}; 587#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 588template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;}; 589#endif 590 591#if _LIBCPP_STD_VER > 11 592template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; 593#endif 594 595// add_lvalue_reference 596 597template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;}; 598template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler 599template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;}; 600template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;}; 601template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;}; 602template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;}; 603 604#if _LIBCPP_STD_VER > 11 605template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; 606#endif 607 608#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 609 610template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;}; 611template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;}; 612template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;}; 613template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;}; 614template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;}; 615 616#if _LIBCPP_STD_VER > 11 617template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; 618#endif 619 620#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 621 622#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 623 624template <class _Tp> 625typename add_rvalue_reference<_Tp>::type 626declval() _NOEXCEPT; 627 628#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 629 630template <class _Tp> 631typename add_lvalue_reference<_Tp>::type 632declval(); 633 634#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 635 636struct __any 637{ 638 __any(...); 639}; 640 641// remove_pointer 642 643template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;}; 644template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;}; 645template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;}; 646template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;}; 647template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;}; 648 649#if _LIBCPP_STD_VER > 11 650template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; 651#endif 652 653// add_pointer 654 655template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer 656 {typedef typename remove_reference<_Tp>::type* type;}; 657 658#if _LIBCPP_STD_VER > 11 659template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; 660#endif 661 662// is_signed 663 664template <class _Tp, bool = is_integral<_Tp>::value> 665struct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {}; 666 667template <class _Tp> 668struct ___is_signed<_Tp, false> : public true_type {}; // floating point 669 670template <class _Tp, bool = is_arithmetic<_Tp>::value> 671struct __libcpp_is_signed : public ___is_signed<_Tp> {}; 672 673template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; 674 675template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; 676 677// is_unsigned 678 679template <class _Tp, bool = is_integral<_Tp>::value> 680struct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {}; 681 682template <class _Tp> 683struct ___is_unsigned<_Tp, false> : public false_type {}; // floating point 684 685template <class _Tp, bool = is_arithmetic<_Tp>::value> 686struct __libcpp_is_unsigned : public ___is_unsigned<_Tp> {}; 687 688template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; 689 690template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; 691 692// rank 693 694template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank 695 : public integral_constant<size_t, 0> {}; 696template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> 697 : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 698template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> 699 : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 700 701// extent 702 703template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent 704 : public integral_constant<size_t, 0> {}; 705template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0> 706 : public integral_constant<size_t, 0> {}; 707template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip> 708 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 709template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0> 710 : public integral_constant<size_t, _Np> {}; 711template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> 712 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 713 714// remove_extent 715 716template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent 717 {typedef _Tp type;}; 718template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]> 719 {typedef _Tp type;}; 720template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]> 721 {typedef _Tp type;}; 722 723#if _LIBCPP_STD_VER > 11 724template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; 725#endif 726 727// remove_all_extents 728 729template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents 730 {typedef _Tp type;}; 731template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]> 732 {typedef typename remove_all_extents<_Tp>::type type;}; 733template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]> 734 {typedef typename remove_all_extents<_Tp>::type type;}; 735 736#if _LIBCPP_STD_VER > 11 737template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; 738#endif 739 740// decay 741 742template <class _Tp> 743struct _LIBCPP_TYPE_VIS_ONLY decay 744{ 745private: 746 typedef typename remove_reference<_Tp>::type _Up; 747public: 748 typedef typename conditional 749 < 750 is_array<_Up>::value, 751 typename remove_extent<_Up>::type*, 752 typename conditional 753 < 754 is_function<_Up>::value, 755 typename add_pointer<_Up>::type, 756 typename remove_cv<_Up>::type 757 >::type 758 >::type type; 759}; 760 761#if _LIBCPP_STD_VER > 11 762template <class _Tp> using decay_t = typename decay<_Tp>::type; 763#endif 764 765// is_abstract 766 767namespace __is_abstract_imp 768{ 769template <class _Tp> char __test(_Tp (*)[1]); 770template <class _Tp> __two __test(...); 771} 772 773template <class _Tp, bool = is_class<_Tp>::value> 774struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {}; 775 776template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}; 777 778template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; 779 780// is_base_of 781 782#ifdef _LIBCPP_HAS_IS_BASE_OF 783 784template <class _Bp, class _Dp> 785struct _LIBCPP_TYPE_VIS_ONLY is_base_of 786 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; 787 788#else // __has_feature(is_base_of) 789 790namespace __is_base_of_imp 791{ 792template <class _Tp> 793struct _Dst 794{ 795 _Dst(const volatile _Tp &); 796}; 797template <class _Tp> 798struct _Src 799{ 800 operator const volatile _Tp &(); 801 template <class _Up> operator const _Dst<_Up> &(); 802}; 803template <size_t> struct __one { typedef char type; }; 804template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int); 805template <class _Bp, class _Dp> __two __test(...); 806} 807 808template <class _Bp, class _Dp> 809struct _LIBCPP_TYPE_VIS_ONLY is_base_of 810 : public integral_constant<bool, is_class<_Bp>::value && 811 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; 812 813#endif // __has_feature(is_base_of) 814 815// is_convertible 816 817#if __has_feature(is_convertible_to) 818 819template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible 820 : public integral_constant<bool, __is_convertible_to(_T1, _T2) && 821 !is_abstract<_T2>::value> {}; 822 823#else // __has_feature(is_convertible_to) 824 825namespace __is_convertible_imp 826{ 827template <class _Tp> char __test(_Tp); 828template <class _Tp> __two __test(...); 829#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 830template <class _Tp> _Tp&& __source(); 831#else 832template <class _Tp> typename remove_reference<_Tp>::type& __source(); 833#endif 834 835template <class _Tp, bool _IsArray = is_array<_Tp>::value, 836 bool _IsFunction = is_function<_Tp>::value, 837 bool _IsVoid = is_void<_Tp>::value> 838 struct __is_array_function_or_void {enum {value = 0};}; 839template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; 840template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; 841template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; 842} 843 844template <class _Tp, 845 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> 846struct __is_convertible_check 847{ 848 static const size_t __v = 0; 849}; 850 851template <class _Tp> 852struct __is_convertible_check<_Tp, 0> 853{ 854 static const size_t __v = sizeof(_Tp); 855}; 856 857template <class _T1, class _T2, 858 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, 859 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> 860struct __is_convertible 861 : public integral_constant<bool, 862#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 863 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 864#else 865 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 866 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value 867 && (!is_const<typename remove_reference<_T2>::type>::value 868 || is_volatile<typename remove_reference<_T2>::type>::value) 869 && (is_same<typename remove_cv<_T1>::type, 870 typename remove_cv<typename remove_reference<_T2>::type>::type>::value 871 || is_base_of<typename remove_reference<_T2>::type, _T1>::value)) 872#endif 873 > 874{}; 875 876template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {}; 877 878template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {}; 879#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 880template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {}; 881template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {}; 882template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {}; 883template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {}; 884#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 885 886template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0> 887 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {}; 888 889template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0> 890 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {}; 891 892template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0> 893 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {}; 894 895template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0> 896 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {}; 897 898template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {}; 899#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 900template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {}; 901#endif 902template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {}; 903template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {}; 904template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {}; 905template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {}; 906template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {}; 907 908template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {}; 909 910template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; 911template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; 912template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; 913template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; 914 915template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; 916template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; 917template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; 918template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; 919 920template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; 921template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; 922template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; 923template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; 924 925template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible 926 : public __is_convertible<_T1, _T2> 927{ 928 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; 929 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; 930}; 931 932#endif // __has_feature(is_convertible_to) 933 934// is_empty 935 936#if __has_feature(is_empty) 937 938template <class _Tp> 939struct _LIBCPP_TYPE_VIS_ONLY is_empty 940 : public integral_constant<bool, __is_empty(_Tp)> {}; 941 942#else // __has_feature(is_empty) 943 944template <class _Tp> 945struct __is_empty1 946 : public _Tp 947{ 948 double __lx; 949}; 950 951struct __is_empty2 952{ 953 double __lx; 954}; 955 956template <class _Tp, bool = is_class<_Tp>::value> 957struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; 958 959template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; 960 961template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {}; 962 963#endif // __has_feature(is_empty) 964 965// is_polymorphic 966 967#if __has_feature(is_polymorphic) 968 969template <class _Tp> 970struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic 971 : public integral_constant<bool, __is_polymorphic(_Tp)> {}; 972 973#else 974 975template<typename _Tp> char &__is_polymorphic_impl( 976 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0, 977 int>::type); 978template<typename _Tp> __two &__is_polymorphic_impl(...); 979 980template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic 981 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; 982 983#endif // __has_feature(is_polymorphic) 984 985// has_virtual_destructor 986 987#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 988 989template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor 990 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; 991 992#else // _LIBCPP_HAS_TYPE_TRAITS 993 994template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor 995 : public false_type {}; 996 997#endif // _LIBCPP_HAS_TYPE_TRAITS 998 999// alignment_of 1000 1001template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of 1002 : public integral_constant<size_t, __alignof__(_Tp)> {}; 1003 1004// aligned_storage 1005 1006template <class _Hp, class _Tp> 1007struct __type_list 1008{ 1009 typedef _Hp _Head; 1010 typedef _Tp _Tail; 1011}; 1012 1013struct __nat 1014{ 1015#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1016 __nat() = delete; 1017 __nat(const __nat&) = delete; 1018 __nat& operator=(const __nat&) = delete; 1019 ~__nat() = delete; 1020#endif 1021}; 1022 1023template <class _Tp> 1024struct __align_type 1025{ 1026 static const size_t value = alignment_of<_Tp>::value; 1027 typedef _Tp type; 1028}; 1029 1030struct __struct_double {long double __lx;}; 1031struct __struct_double4 {double __lx[4];}; 1032 1033typedef 1034 __type_list<__align_type<unsigned char>, 1035 __type_list<__align_type<unsigned short>, 1036 __type_list<__align_type<unsigned int>, 1037 __type_list<__align_type<unsigned long>, 1038 __type_list<__align_type<unsigned long long>, 1039 __type_list<__align_type<double>, 1040 __type_list<__align_type<long double>, 1041 __type_list<__align_type<__struct_double>, 1042 __type_list<__align_type<__struct_double4>, 1043 __type_list<__align_type<int*>, 1044 __nat 1045 > > > > > > > > > > __all_types; 1046 1047template <class _TL, size_t _Align> struct __find_pod; 1048 1049template <class _Hp, size_t _Align> 1050struct __find_pod<__type_list<_Hp, __nat>, _Align> 1051{ 1052 typedef typename conditional< 1053 _Align == _Hp::value, 1054 typename _Hp::type, 1055 void 1056 >::type type; 1057}; 1058 1059template <class _Hp, class _Tp, size_t _Align> 1060struct __find_pod<__type_list<_Hp, _Tp>, _Align> 1061{ 1062 typedef typename conditional< 1063 _Align == _Hp::value, 1064 typename _Hp::type, 1065 typename __find_pod<_Tp, _Align>::type 1066 >::type type; 1067}; 1068 1069template <class _TL, size_t _Len> struct __find_max_align; 1070 1071template <class _Hp, size_t _Len> 1072struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; 1073 1074template <size_t _Len, size_t _A1, size_t _A2> 1075struct __select_align 1076{ 1077private: 1078 static const size_t __min = _A2 < _A1 ? _A2 : _A1; 1079 static const size_t __max = _A1 < _A2 ? _A2 : _A1; 1080public: 1081 static const size_t value = _Len < __max ? __min : __max; 1082}; 1083 1084template <class _Hp, class _Tp, size_t _Len> 1085struct __find_max_align<__type_list<_Hp, _Tp>, _Len> 1086 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; 1087 1088template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1089struct _LIBCPP_TYPE_VIS_ONLY aligned_storage 1090{ 1091 typedef typename __find_pod<__all_types, _Align>::type _Aligner; 1092 static_assert(!is_void<_Aligner>::value, ""); 1093 union type 1094 { 1095 _Aligner __align; 1096 unsigned char __data[_Len]; 1097 }; 1098}; 1099 1100#if _LIBCPP_STD_VER > 11 1101template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1102 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; 1103#endif 1104 1105#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ 1106template <size_t _Len>\ 1107struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ 1108{\ 1109 struct _ALIGNAS(n) type\ 1110 {\ 1111 unsigned char __lx[_Len];\ 1112 };\ 1113} 1114 1115_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); 1116_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); 1117_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); 1118_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); 1119_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); 1120_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); 1121_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); 1122_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); 1123_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); 1124_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); 1125_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); 1126_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); 1127_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); 1128_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); 1129// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000) 1130#if !defined(_LIBCPP_MSVC) 1131_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); 1132#endif // !_LIBCPP_MSVC 1133 1134#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION 1135 1136#ifndef _LIBCPP_HAS_NO_VARIADICS 1137 1138// aligned_union 1139 1140template <size_t _I0, size_t ..._In> 1141struct __static_max; 1142 1143template <size_t _I0> 1144struct __static_max<_I0> 1145{ 1146 static const size_t value = _I0; 1147}; 1148 1149template <size_t _I0, size_t _I1, size_t ..._In> 1150struct __static_max<_I0, _I1, _In...> 1151{ 1152 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : 1153 __static_max<_I1, _In...>::value; 1154}; 1155 1156template <size_t _Len, class _Type0, class ..._Types> 1157struct aligned_union 1158{ 1159 static const size_t alignment_value = __static_max<__alignof__(_Type0), 1160 __alignof__(_Types)...>::value; 1161 static const size_t __len = __static_max<_Len, sizeof(_Type0), 1162 sizeof(_Types)...>::value; 1163 typedef typename aligned_storage<__len, alignment_value>::type type; 1164}; 1165 1166#if _LIBCPP_STD_VER > 11 1167template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; 1168#endif 1169 1170#endif // _LIBCPP_HAS_NO_VARIADICS 1171 1172// __promote 1173 1174template <class _A1, class _A2 = void, class _A3 = void, 1175 bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) && 1176 (is_arithmetic<_A2>::value || is_void<_A2>::value) && 1177 (is_arithmetic<_A3>::value || is_void<_A3>::value)> 1178class __promote {}; 1179 1180template <class _A1, class _A2, class _A3> 1181class __promote<_A1, _A2, _A3, true> 1182{ 1183private: 1184 typedef typename __promote<_A1>::type __type1; 1185 typedef typename __promote<_A2>::type __type2; 1186 typedef typename __promote<_A3>::type __type3; 1187public: 1188 typedef decltype(__type1() + __type2() + __type3()) type; 1189}; 1190 1191template <class _A1, class _A2> 1192class __promote<_A1, _A2, void, true> 1193{ 1194private: 1195 typedef typename __promote<_A1>::type __type1; 1196 typedef typename __promote<_A2>::type __type2; 1197public: 1198 typedef decltype(__type1() + __type2()) type; 1199}; 1200 1201template <class _A1> 1202class __promote<_A1, void, void, true> 1203{ 1204public: 1205 typedef typename conditional<is_arithmetic<_A1>::value, 1206 typename conditional<is_integral<_A1>::value, double, _A1>::type, 1207 void 1208 >::type type; 1209}; 1210 1211#ifdef _LIBCPP_STORE_AS_OPTIMIZATION 1212 1213// __transform 1214 1215template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;}; 1216template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;}; 1217template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;}; 1218template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;}; 1219template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; 1220 1221#endif // _LIBCPP_STORE_AS_OPTIMIZATION 1222 1223// make_signed / make_unsigned 1224 1225typedef 1226 __type_list<signed char, 1227 __type_list<signed short, 1228 __type_list<signed int, 1229 __type_list<signed long, 1230 __type_list<signed long long, 1231 __nat 1232 > > > > > __signed_types; 1233 1234typedef 1235 __type_list<unsigned char, 1236 __type_list<unsigned short, 1237 __type_list<unsigned int, 1238 __type_list<unsigned long, 1239 __type_list<unsigned long long, 1240 __nat 1241 > > > > > __unsigned_types; 1242 1243template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; 1244 1245template <class _Hp, class _Tp, size_t _Size> 1246struct __find_first<__type_list<_Hp, _Tp>, _Size, true> 1247{ 1248 typedef _Hp type; 1249}; 1250 1251template <class _Hp, class _Tp, size_t _Size> 1252struct __find_first<__type_list<_Hp, _Tp>, _Size, false> 1253{ 1254 typedef typename __find_first<_Tp, _Size>::type type; 1255}; 1256 1257template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, 1258 bool = is_volatile<typename remove_reference<_Tp>::type>::value> 1259struct __apply_cv 1260{ 1261 typedef _Up type; 1262}; 1263 1264template <class _Tp, class _Up> 1265struct __apply_cv<_Tp, _Up, true, false> 1266{ 1267 typedef const _Up type; 1268}; 1269 1270template <class _Tp, class _Up> 1271struct __apply_cv<_Tp, _Up, false, true> 1272{ 1273 typedef volatile _Up type; 1274}; 1275 1276template <class _Tp, class _Up> 1277struct __apply_cv<_Tp, _Up, true, true> 1278{ 1279 typedef const volatile _Up type; 1280}; 1281 1282template <class _Tp, class _Up> 1283struct __apply_cv<_Tp&, _Up, false, false> 1284{ 1285 typedef _Up& type; 1286}; 1287 1288template <class _Tp, class _Up> 1289struct __apply_cv<_Tp&, _Up, true, false> 1290{ 1291 typedef const _Up& type; 1292}; 1293 1294template <class _Tp, class _Up> 1295struct __apply_cv<_Tp&, _Up, false, true> 1296{ 1297 typedef volatile _Up& type; 1298}; 1299 1300template <class _Tp, class _Up> 1301struct __apply_cv<_Tp&, _Up, true, true> 1302{ 1303 typedef const volatile _Up& type; 1304}; 1305 1306template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 1307struct __make_signed {}; 1308 1309template <class _Tp> 1310struct __make_signed<_Tp, true> 1311{ 1312 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; 1313}; 1314 1315template <> struct __make_signed<bool, true> {}; 1316template <> struct __make_signed< signed short, true> {typedef short type;}; 1317template <> struct __make_signed<unsigned short, true> {typedef short type;}; 1318template <> struct __make_signed< signed int, true> {typedef int type;}; 1319template <> struct __make_signed<unsigned int, true> {typedef int type;}; 1320template <> struct __make_signed< signed long, true> {typedef long type;}; 1321template <> struct __make_signed<unsigned long, true> {typedef long type;}; 1322template <> struct __make_signed< signed long long, true> {typedef long long type;}; 1323template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; 1324 1325template <class _Tp> 1326struct _LIBCPP_TYPE_VIS_ONLY make_signed 1327{ 1328 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; 1329}; 1330 1331#if _LIBCPP_STD_VER > 11 1332template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; 1333#endif 1334 1335template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 1336struct __make_unsigned {}; 1337 1338template <class _Tp> 1339struct __make_unsigned<_Tp, true> 1340{ 1341 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; 1342}; 1343 1344template <> struct __make_unsigned<bool, true> {}; 1345template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; 1346template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; 1347template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; 1348template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; 1349template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; 1350template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; 1351template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; 1352template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; 1353 1354template <class _Tp> 1355struct _LIBCPP_TYPE_VIS_ONLY make_unsigned 1356{ 1357 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; 1358}; 1359 1360#if _LIBCPP_STD_VER > 11 1361template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; 1362#endif 1363 1364#ifdef _LIBCPP_HAS_NO_VARIADICS 1365 1366template <class _Tp, class _Up = void, class V = void> 1367struct _LIBCPP_TYPE_VIS_ONLY common_type 1368{ 1369public: 1370 typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type; 1371}; 1372 1373template <class _Tp> 1374struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void> 1375{ 1376public: 1377 typedef _Tp type; 1378}; 1379 1380template <class _Tp, class _Up> 1381struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> 1382{ 1383private: 1384#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1385 static _Tp&& __t(); 1386 static _Up&& __u(); 1387#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1388 static _Tp __t(); 1389 static _Up __u(); 1390#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1391public: 1392 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type; 1393}; 1394 1395#else // _LIBCPP_HAS_NO_VARIADICS 1396 1397template <class ..._Tp> struct common_type; 1398 1399template <class _Tp> 1400struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> 1401{ 1402 typedef typename decay<_Tp>::type type; 1403}; 1404 1405template <class _Tp, class _Up> 1406struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> 1407{ 1408private: 1409 static _Tp&& __t(); 1410 static _Up&& __u(); 1411 static bool __f(); 1412public: 1413 typedef typename decay<decltype(__f() ? __t() : __u())>::type type; 1414}; 1415 1416template <class _Tp, class _Up, class ..._Vp> 1417struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> 1418{ 1419 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; 1420}; 1421 1422#if _LIBCPP_STD_VER > 11 1423template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; 1424#endif 1425 1426#endif // _LIBCPP_HAS_NO_VARIADICS 1427 1428// is_assignable 1429 1430template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; }; 1431 1432template <class _Tp, class _Arg> 1433typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type 1434#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1435__is_assignable_test(_Tp&&, _Arg&&); 1436#else 1437__is_assignable_test(_Tp, _Arg&); 1438#endif 1439 1440template <class _Arg> 1441false_type 1442#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1443__is_assignable_test(__any, _Arg&&); 1444#else 1445__is_assignable_test(__any, _Arg&); 1446#endif 1447 1448template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> 1449struct __is_assignable_imp 1450 : public common_type 1451 < 1452 decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>())) 1453 >::type {}; 1454 1455template <class _Tp, class _Arg> 1456struct __is_assignable_imp<_Tp, _Arg, true> 1457 : public false_type 1458{ 1459}; 1460 1461template <class _Tp, class _Arg> 1462struct is_assignable 1463 : public __is_assignable_imp<_Tp, _Arg> {}; 1464 1465// is_copy_assignable 1466 1467template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable 1468 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 1469 const typename add_lvalue_reference<_Tp>::type> {}; 1470 1471// is_move_assignable 1472 1473template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable 1474#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1475 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 1476 const typename add_rvalue_reference<_Tp>::type> {}; 1477#else 1478 : public is_copy_assignable<_Tp> {}; 1479#endif 1480 1481// is_destructible 1482 1483template <class _Tp> 1484struct __destructible_test 1485{ 1486 _Tp __t; 1487}; 1488 1489template <class _Tp> 1490decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type())) 1491#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1492__is_destructible_test(_Tp&&); 1493#else 1494__is_destructible_test(_Tp&); 1495#endif 1496 1497false_type 1498__is_destructible_test(__any); 1499 1500template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value 1501 || is_function<_Tp>::value> 1502struct __destructible_imp 1503 : public common_type 1504 < 1505 decltype(__is_destructible_test(declval<_Tp>())) 1506 >::type {}; 1507 1508template <class _Tp> 1509struct __destructible_imp<_Tp, true> 1510 : public false_type {}; 1511 1512template <class _Tp> 1513struct is_destructible 1514 : public __destructible_imp<_Tp> {}; 1515 1516template <class _Tp> 1517struct is_destructible<_Tp[]> 1518 : public false_type {}; 1519 1520// move 1521 1522#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1523 1524template <class _Tp> 1525inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1526typename remove_reference<_Tp>::type&& 1527move(_Tp&& __t) _NOEXCEPT 1528{ 1529 typedef typename remove_reference<_Tp>::type _Up; 1530 return static_cast<_Up&&>(__t); 1531} 1532 1533template <class _Tp> 1534inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1535_Tp&& 1536forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT 1537{ 1538 return static_cast<_Tp&&>(__t); 1539} 1540 1541template <class _Tp> 1542inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1543_Tp&& 1544forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT 1545{ 1546 static_assert(!std::is_lvalue_reference<_Tp>::value, 1547 "Can not forward an rvalue as an lvalue."); 1548 return static_cast<_Tp&&>(__t); 1549} 1550 1551#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1552 1553template <class _Tp> 1554inline _LIBCPP_INLINE_VISIBILITY 1555_Tp& 1556move(_Tp& __t) 1557{ 1558 return __t; 1559} 1560 1561template <class _Tp> 1562inline _LIBCPP_INLINE_VISIBILITY 1563const _Tp& 1564move(const _Tp& __t) 1565{ 1566 return __t; 1567} 1568 1569template <class _Tp> 1570inline _LIBCPP_INLINE_VISIBILITY 1571_Tp& 1572forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT 1573{ 1574 return __t; 1575} 1576 1577 1578template <class _Tp> 1579class __rv 1580{ 1581 typedef typename remove_reference<_Tp>::type _Trr; 1582 _Trr& t_; 1583public: 1584 _LIBCPP_INLINE_VISIBILITY 1585 _Trr* operator->() {return &t_;} 1586 _LIBCPP_INLINE_VISIBILITY 1587 explicit __rv(_Trr& __t) : t_(__t) {} 1588}; 1589 1590#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1591 1592#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1593 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// template <class T, class... Args> struct is_constructible; 2019 2020namespace __is_construct 2021{ 2022struct __nat {}; 2023} 2024 2025#if __has_feature(is_constructible) 2026 2027template <class _Tp, class ..._Args> 2028struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2029 : public integral_constant<bool, __is_constructible(_Tp, _Args...)> 2030 {}; 2031 2032#else 2033 2034#ifndef _LIBCPP_HAS_NO_VARIADICS 2035 2036// main is_constructible test 2037 2038template <class _Tp, class ..._Args> 2039typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type 2040__is_constructible_test(_Tp&&, _Args&& ...); 2041 2042template <class ..._Args> 2043false_type 2044__is_constructible_test(__any, _Args&& ...); 2045 2046template <bool, class _Tp, class... _Args> 2047struct __libcpp_is_constructible // false, _Tp is not a scalar 2048 : public common_type 2049 < 2050 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...)) 2051 >::type 2052 {}; 2053 2054// function types are not constructible 2055 2056template <class _Rp, class... _A1, class... _A2> 2057struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...> 2058 : public false_type 2059 {}; 2060 2061// handle scalars and reference types 2062 2063// Scalars are default constructible, references are not 2064 2065template <class _Tp> 2066struct __libcpp_is_constructible<true, _Tp> 2067 : public is_scalar<_Tp> 2068 {}; 2069 2070// Scalars and references are constructible from one arg if that arg is 2071// implicitly convertible to the scalar or reference. 2072 2073template <class _Tp> 2074struct __is_constructible_ref 2075{ 2076 true_type static __lxx(_Tp); 2077 false_type static __lxx(...); 2078}; 2079 2080template <class _Tp, class _A0> 2081struct __libcpp_is_constructible<true, _Tp, _A0> 2082 : public common_type 2083 < 2084 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>())) 2085 >::type 2086 {}; 2087 2088// Scalars and references are not constructible from multiple args. 2089 2090template <class _Tp, class _A0, class ..._Args> 2091struct __libcpp_is_constructible<true, _Tp, _A0, _Args...> 2092 : public false_type 2093 {}; 2094 2095// Treat scalars and reference types separately 2096 2097template <bool, class _Tp, class... _Args> 2098struct __is_constructible_void_check 2099 : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2100 _Tp, _Args...> 2101 {}; 2102 2103// If any of T or Args is void, is_constructible should be false 2104 2105template <class _Tp, class... _Args> 2106struct __is_constructible_void_check<true, _Tp, _Args...> 2107 : public false_type 2108 {}; 2109 2110template <class ..._Args> struct __contains_void; 2111 2112template <> struct __contains_void<> : false_type {}; 2113 2114template <class _A0, class ..._Args> 2115struct __contains_void<_A0, _Args...> 2116{ 2117 static const bool value = is_void<_A0>::value || 2118 __contains_void<_Args...>::value; 2119}; 2120 2121// is_constructible entry point 2122 2123template <class _Tp, class... _Args> 2124struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2125 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value 2126 || is_abstract<_Tp>::value, 2127 _Tp, _Args...> 2128 {}; 2129 2130// Array types are default constructible if their element type 2131// is default constructible 2132 2133template <class _Ap, size_t _Np> 2134struct __libcpp_is_constructible<false, _Ap[_Np]> 2135 : public is_constructible<typename remove_all_extents<_Ap>::type> 2136 {}; 2137 2138// Otherwise array types are not constructible by this syntax 2139 2140template <class _Ap, size_t _Np, class ..._Args> 2141struct __libcpp_is_constructible<false, _Ap[_Np], _Args...> 2142 : public false_type 2143 {}; 2144 2145// Incomplete array types are not constructible 2146 2147template <class _Ap, class ..._Args> 2148struct __libcpp_is_constructible<false, _Ap[], _Args...> 2149 : public false_type 2150 {}; 2151 2152#else // _LIBCPP_HAS_NO_VARIADICS 2153 2154// template <class T> struct is_constructible0; 2155 2156// main is_constructible0 test 2157 2158template <class _Tp> 2159decltype((_Tp(), true_type())) 2160__is_constructible0_test(_Tp&); 2161 2162false_type 2163__is_constructible0_test(__any); 2164 2165template <class _Tp, class _A0> 2166decltype((_Tp(_VSTD::declval<_A0>()), true_type())) 2167__is_constructible1_test(_Tp&, _A0&); 2168 2169template <class _A0> 2170false_type 2171__is_constructible1_test(__any, _A0&); 2172 2173template <class _Tp, class _A0, class _A1> 2174decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) 2175__is_constructible2_test(_Tp&, _A0&, _A1&); 2176 2177template <class _A0, class _A1> 2178false_type 2179__is_constructible2_test(__any, _A0&, _A1&); 2180 2181template <bool, class _Tp> 2182struct __is_constructible0_imp // false, _Tp is not a scalar 2183 : public common_type 2184 < 2185 decltype(__is_constructible0_test(declval<_Tp&>())) 2186 >::type 2187 {}; 2188 2189template <bool, class _Tp, class _A0> 2190struct __is_constructible1_imp // false, _Tp is not a scalar 2191 : public common_type 2192 < 2193 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) 2194 >::type 2195 {}; 2196 2197template <bool, class _Tp, class _A0, class _A1> 2198struct __is_constructible2_imp // false, _Tp is not a scalar 2199 : public common_type 2200 < 2201 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) 2202 >::type 2203 {}; 2204 2205// handle scalars and reference types 2206 2207// Scalars are default constructible, references are not 2208 2209template <class _Tp> 2210struct __is_constructible0_imp<true, _Tp> 2211 : public is_scalar<_Tp> 2212 {}; 2213 2214template <class _Tp, class _A0> 2215struct __is_constructible1_imp<true, _Tp, _A0> 2216 : public is_convertible<_A0, _Tp> 2217 {}; 2218 2219template <class _Tp, class _A0, class _A1> 2220struct __is_constructible2_imp<true, _Tp, _A0, _A1> 2221 : public false_type 2222 {}; 2223 2224// Treat scalars and reference types separately 2225 2226template <bool, class _Tp> 2227struct __is_constructible0_void_check 2228 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2229 _Tp> 2230 {}; 2231 2232template <bool, class _Tp, class _A0> 2233struct __is_constructible1_void_check 2234 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2235 _Tp, _A0> 2236 {}; 2237 2238template <bool, class _Tp, class _A0, class _A1> 2239struct __is_constructible2_void_check 2240 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2241 _Tp, _A0, _A1> 2242 {}; 2243 2244// If any of T or Args is void, is_constructible should be false 2245 2246template <class _Tp> 2247struct __is_constructible0_void_check<true, _Tp> 2248 : public false_type 2249 {}; 2250 2251template <class _Tp, class _A0> 2252struct __is_constructible1_void_check<true, _Tp, _A0> 2253 : public false_type 2254 {}; 2255 2256template <class _Tp, class _A0, class _A1> 2257struct __is_constructible2_void_check<true, _Tp, _A0, _A1> 2258 : public false_type 2259 {}; 2260 2261// is_constructible entry point 2262 2263template <class _Tp, class _A0 = __is_construct::__nat, 2264 class _A1 = __is_construct::__nat> 2265struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2266 : public __is_constructible2_void_check<is_void<_Tp>::value 2267 || is_abstract<_Tp>::value 2268 || is_function<_Tp>::value 2269 || is_void<_A0>::value 2270 || is_void<_A1>::value, 2271 _Tp, _A0, _A1> 2272 {}; 2273 2274template <class _Tp> 2275struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> 2276 : public __is_constructible0_void_check<is_void<_Tp>::value 2277 || is_abstract<_Tp>::value 2278 || is_function<_Tp>::value, 2279 _Tp> 2280 {}; 2281 2282template <class _Tp, class _A0> 2283struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat> 2284 : public __is_constructible1_void_check<is_void<_Tp>::value 2285 || is_abstract<_Tp>::value 2286 || is_function<_Tp>::value 2287 || is_void<_A0>::value, 2288 _Tp, _A0> 2289 {}; 2290 2291// Array types are default constructible if their element type 2292// is default constructible 2293 2294template <class _Ap, size_t _Np> 2295struct __is_constructible0_imp<false, _Ap[_Np]> 2296 : public is_constructible<typename remove_all_extents<_Ap>::type> 2297 {}; 2298 2299template <class _Ap, size_t _Np, class _A0> 2300struct __is_constructible1_imp<false, _Ap[_Np], _A0> 2301 : public false_type 2302 {}; 2303 2304template <class _Ap, size_t _Np, class _A0, class _A1> 2305struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1> 2306 : public false_type 2307 {}; 2308 2309// Incomplete array types are not constructible 2310 2311template <class _Ap> 2312struct __is_constructible0_imp<false, _Ap[]> 2313 : public false_type 2314 {}; 2315 2316template <class _Ap, class _A0> 2317struct __is_constructible1_imp<false, _Ap[], _A0> 2318 : public false_type 2319 {}; 2320 2321template <class _Ap, class _A0, class _A1> 2322struct __is_constructible2_imp<false, _Ap[], _A0, _A1> 2323 : public false_type 2324 {}; 2325 2326#endif // _LIBCPP_HAS_NO_VARIADICS 2327#endif // __has_feature(is_constructible) 2328 2329// is_default_constructible 2330 2331template <class _Tp> 2332struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible 2333 : public is_constructible<_Tp> 2334 {}; 2335 2336// is_copy_constructible 2337 2338template <class _Tp> 2339struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible 2340 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2341 {}; 2342 2343// is_move_constructible 2344 2345template <class _Tp> 2346struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible 2347#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2348 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2349#else 2350 : public is_copy_constructible<_Tp> 2351#endif 2352 {}; 2353 2354// is_trivially_constructible 2355 2356#ifndef _LIBCPP_HAS_NO_VARIADICS 2357 2358#if __has_feature(is_trivially_constructible) 2359 2360template <class _Tp, class... _Args> 2361struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2362 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> 2363{ 2364}; 2365 2366#else // !__has_feature(is_trivially_constructible) 2367 2368template <class _Tp, class... _Args> 2369struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2370 : false_type 2371{ 2372}; 2373 2374template <class _Tp> 2375struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> 2376#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2377 : integral_constant<bool, __has_trivial_constructor(_Tp)> 2378#else 2379 : integral_constant<bool, is_scalar<_Tp>::value> 2380#endif 2381{ 2382}; 2383 2384template <class _Tp> 2385#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2386struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&> 2387#else 2388struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp> 2389#endif 2390 : integral_constant<bool, is_scalar<_Tp>::value> 2391{ 2392}; 2393 2394template <class _Tp> 2395struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&> 2396 : integral_constant<bool, is_scalar<_Tp>::value> 2397{ 2398}; 2399 2400template <class _Tp> 2401struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&> 2402 : integral_constant<bool, is_scalar<_Tp>::value> 2403{ 2404}; 2405 2406#endif // !__has_feature(is_trivially_constructible) 2407 2408#else // _LIBCPP_HAS_NO_VARIADICS 2409 2410template <class _Tp, class _A0 = __is_construct::__nat, 2411 class _A1 = __is_construct::__nat> 2412struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2413 : false_type 2414{ 2415}; 2416 2417#if __has_feature(is_trivially_constructible) 2418 2419template <class _Tp> 2420struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, 2421 __is_construct::__nat> 2422 : integral_constant<bool, __is_trivially_constructible(_Tp)> 2423{ 2424}; 2425 2426template <class _Tp> 2427struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, 2428 __is_construct::__nat> 2429 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)> 2430{ 2431}; 2432 2433template <class _Tp> 2434struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, 2435 __is_construct::__nat> 2436 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)> 2437{ 2438}; 2439 2440template <class _Tp> 2441struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, 2442 __is_construct::__nat> 2443 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)> 2444{ 2445}; 2446 2447#else // !__has_feature(is_trivially_constructible) 2448 2449template <class _Tp> 2450struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, 2451 __is_construct::__nat> 2452 : integral_constant<bool, is_scalar<_Tp>::value> 2453{ 2454}; 2455 2456template <class _Tp> 2457struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, 2458 __is_construct::__nat> 2459 : integral_constant<bool, is_scalar<_Tp>::value> 2460{ 2461}; 2462 2463template <class _Tp> 2464struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, 2465 __is_construct::__nat> 2466 : integral_constant<bool, is_scalar<_Tp>::value> 2467{ 2468}; 2469 2470template <class _Tp> 2471struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, 2472 __is_construct::__nat> 2473 : integral_constant<bool, is_scalar<_Tp>::value> 2474{ 2475}; 2476 2477#endif // !__has_feature(is_trivially_constructible) 2478 2479#endif // _LIBCPP_HAS_NO_VARIADICS 2480 2481// is_trivially_default_constructible 2482 2483template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible 2484 : public is_trivially_constructible<_Tp> 2485 {}; 2486 2487// is_trivially_copy_constructible 2488 2489template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible 2490 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> 2491 {}; 2492 2493// is_trivially_move_constructible 2494 2495template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible 2496#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2497 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2498#else 2499 : public is_trivially_copy_constructible<_Tp> 2500#endif 2501 {}; 2502 2503// is_trivially_assignable 2504 2505#if __has_feature(is_trivially_constructible) 2506 2507template <class _Tp, class _Arg> 2508struct is_trivially_assignable 2509 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> 2510{ 2511}; 2512 2513#else // !__has_feature(is_trivially_constructible) 2514 2515template <class _Tp, class _Arg> 2516struct is_trivially_assignable 2517 : public false_type {}; 2518 2519template <class _Tp> 2520struct is_trivially_assignable<_Tp&, _Tp> 2521 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2522 2523template <class _Tp> 2524struct is_trivially_assignable<_Tp&, _Tp&> 2525 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2526 2527template <class _Tp> 2528struct is_trivially_assignable<_Tp&, const _Tp&> 2529 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2530 2531#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2532 2533template <class _Tp> 2534struct is_trivially_assignable<_Tp&, _Tp&&> 2535 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2536 2537#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2538 2539#endif // !__has_feature(is_trivially_constructible) 2540 2541// is_trivially_copy_assignable 2542 2543template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable 2544 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2545 const typename add_lvalue_reference<_Tp>::type> 2546 {}; 2547 2548// is_trivially_move_assignable 2549 2550template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable 2551 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2552#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2553 typename add_rvalue_reference<_Tp>::type> 2554#else 2555 typename add_lvalue_reference<_Tp>::type> 2556#endif 2557 {}; 2558 2559// is_trivially_destructible 2560 2561#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2562 2563template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible 2564 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {}; 2565 2566#else // _LIBCPP_HAS_TYPE_TRAITS 2567 2568template <class _Tp> struct __libcpp_trivial_destructor 2569 : public integral_constant<bool, is_scalar<_Tp>::value || 2570 is_reference<_Tp>::value> {}; 2571 2572template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible 2573 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; 2574 2575#endif // _LIBCPP_HAS_TYPE_TRAITS 2576 2577// is_nothrow_constructible 2578 2579#if 0 2580template <class _Tp, class... _Args> 2581struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2582 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))> 2583{ 2584}; 2585 2586#else 2587 2588#ifndef _LIBCPP_HAS_NO_VARIADICS 2589 2590#if __has_feature(cxx_noexcept) 2591 2592template <bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible; 2593 2594template <class _Tp, class... _Args> 2595struct __libcpp_is_nothrow_constructible<true, _Tp, _Args...> 2596 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 2597{ 2598}; 2599 2600template <class _Tp, class... _Args> 2601struct __libcpp_is_nothrow_constructible<false, _Tp, _Args...> 2602 : public false_type 2603{ 2604}; 2605 2606template <class _Tp, class... _Args> 2607struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2608 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...> 2609{ 2610}; 2611 2612template <class _Tp, size_t _Ns> 2613struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> 2614 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, _Tp> 2615{ 2616}; 2617 2618#else // __has_feature(cxx_noexcept) 2619 2620template <class _Tp, class... _Args> 2621struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2622 : false_type 2623{ 2624}; 2625 2626template <class _Tp> 2627struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> 2628#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2629 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2630#else 2631 : integral_constant<bool, is_scalar<_Tp>::value> 2632#endif 2633{ 2634}; 2635 2636template <class _Tp> 2637#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2638struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> 2639#else 2640struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> 2641#endif 2642#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2643 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2644#else 2645 : integral_constant<bool, is_scalar<_Tp>::value> 2646#endif 2647{ 2648}; 2649 2650template <class _Tp> 2651struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> 2652#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2653 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2654#else 2655 : integral_constant<bool, is_scalar<_Tp>::value> 2656#endif 2657{ 2658}; 2659 2660template <class _Tp> 2661struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> 2662#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2663 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2664#else 2665 : integral_constant<bool, is_scalar<_Tp>::value> 2666#endif 2667{ 2668}; 2669 2670#endif // __has_feature(cxx_noexcept) 2671 2672#else // _LIBCPP_HAS_NO_VARIADICS 2673 2674template <class _Tp, class _A0 = __is_construct::__nat, 2675 class _A1 = __is_construct::__nat> 2676struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2677 : false_type 2678{ 2679}; 2680 2681template <class _Tp> 2682struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat, 2683 __is_construct::__nat> 2684#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2685 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2686#else 2687 : integral_constant<bool, is_scalar<_Tp>::value> 2688#endif 2689{ 2690}; 2691 2692template <class _Tp> 2693struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, 2694 __is_construct::__nat> 2695#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2696 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2697#else 2698 : integral_constant<bool, is_scalar<_Tp>::value> 2699#endif 2700{ 2701}; 2702 2703template <class _Tp> 2704struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, 2705 __is_construct::__nat> 2706#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2707 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2708#else 2709 : integral_constant<bool, is_scalar<_Tp>::value> 2710#endif 2711{ 2712}; 2713 2714template <class _Tp> 2715struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, 2716 __is_construct::__nat> 2717#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2718 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2719#else 2720 : integral_constant<bool, is_scalar<_Tp>::value> 2721#endif 2722{ 2723}; 2724 2725#endif // _LIBCPP_HAS_NO_VARIADICS 2726#endif // __has_feature(is_nothrow_constructible) 2727 2728// is_nothrow_default_constructible 2729 2730template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible 2731 : public is_nothrow_constructible<_Tp> 2732 {}; 2733 2734// is_nothrow_copy_constructible 2735 2736template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible 2737 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2738 {}; 2739 2740// is_nothrow_move_constructible 2741 2742template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible 2743#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2744 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2745#else 2746 : public is_nothrow_copy_constructible<_Tp> 2747#endif 2748 {}; 2749 2750// is_nothrow_assignable 2751 2752#if __has_feature(cxx_noexcept) 2753 2754template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; 2755 2756template <class _Tp, class _Arg> 2757struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> 2758 : public false_type 2759{ 2760}; 2761 2762template <class _Tp, class _Arg> 2763struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> 2764 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > 2765{ 2766}; 2767 2768template <class _Tp, class _Arg> 2769struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable 2770 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> 2771{ 2772}; 2773 2774#else // __has_feature(cxx_noexcept) 2775 2776template <class _Tp, class _Arg> 2777struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable 2778 : public false_type {}; 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&, _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 2796template <class _Tp> 2797struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> 2798#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2799 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2800#else 2801 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2802#endif 2803 2804#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2805 2806template <class _Tp> 2807struct is_nothrow_assignable<_Tp&, _Tp&&> 2808#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2809 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2810#else 2811 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2812#endif 2813 2814#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2815 2816#endif // __has_feature(cxx_noexcept) 2817 2818// is_nothrow_copy_assignable 2819 2820template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable 2821 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2822 const typename add_lvalue_reference<_Tp>::type> 2823 {}; 2824 2825// is_nothrow_move_assignable 2826 2827template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable 2828 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2829#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2830 typename add_rvalue_reference<_Tp>::type> 2831#else 2832 typename add_lvalue_reference<_Tp>::type> 2833#endif 2834 {}; 2835 2836// is_nothrow_destructible 2837 2838#if __has_feature(cxx_noexcept) 2839 2840template <bool, class _Tp> struct __libcpp_is_nothrow_destructible; 2841 2842template <class _Tp> 2843struct __libcpp_is_nothrow_destructible<false, _Tp> 2844 : public false_type 2845{ 2846}; 2847 2848template <class _Tp> 2849struct __libcpp_is_nothrow_destructible<true, _Tp> 2850 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > 2851{ 2852}; 2853 2854template <class _Tp> 2855struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible 2856 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> 2857{ 2858}; 2859 2860template <class _Tp, size_t _Ns> 2861struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]> 2862 : public is_nothrow_destructible<_Tp> 2863{ 2864}; 2865 2866template <class _Tp> 2867struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&> 2868 : public true_type 2869{ 2870}; 2871 2872#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2873 2874template <class _Tp> 2875struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&> 2876 : public true_type 2877{ 2878}; 2879 2880#endif 2881 2882#else 2883 2884template <class _Tp> struct __libcpp_nothrow_destructor 2885 : public integral_constant<bool, is_scalar<_Tp>::value || 2886 is_reference<_Tp>::value> {}; 2887 2888template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible 2889 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; 2890 2891#endif 2892 2893// is_pod 2894 2895#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2896 2897template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod 2898 : public integral_constant<bool, __is_pod(_Tp)> {}; 2899 2900#else // _LIBCPP_HAS_TYPE_TRAITS 2901 2902template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod 2903 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && 2904 is_trivially_copy_constructible<_Tp>::value && 2905 is_trivially_copy_assignable<_Tp>::value && 2906 is_trivially_destructible<_Tp>::value> {}; 2907 2908#endif // _LIBCPP_HAS_TYPE_TRAITS 2909 2910// is_literal_type; 2911 2912template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type 2913#if __has_feature(is_literal) 2914 : public integral_constant<bool, __is_literal(_Tp)> 2915#else 2916 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value || 2917 is_reference<typename remove_all_extents<_Tp>::type>::value> 2918#endif 2919 {}; 2920 2921// is_standard_layout; 2922 2923template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout 2924#if __has_feature(is_standard_layout) 2925 : public integral_constant<bool, __is_standard_layout(_Tp)> 2926#else 2927 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2928#endif 2929 {}; 2930 2931// is_trivially_copyable; 2932 2933template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable 2934#if __has_feature(is_trivially_copyable) 2935 : public integral_constant<bool, __is_trivially_copyable(_Tp)> 2936#else 2937 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2938#endif 2939 {}; 2940 2941// is_trivial; 2942 2943template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial 2944#if __has_feature(is_trivial) 2945 : public integral_constant<bool, __is_trivial(_Tp)> 2946#else 2947 : integral_constant<bool, is_trivially_copyable<_Tp>::value && 2948 is_trivially_default_constructible<_Tp>::value> 2949#endif 2950 {}; 2951 2952#ifndef _LIBCPP_HAS_NO_VARIADICS 2953 2954// Check for complete types 2955 2956template <class ..._Tp> struct __check_complete; 2957 2958template <> 2959struct __check_complete<> 2960{ 2961}; 2962 2963template <class _Hp, class _T0, class ..._Tp> 2964struct __check_complete<_Hp, _T0, _Tp...> 2965 : private __check_complete<_Hp>, 2966 private __check_complete<_T0, _Tp...> 2967{ 2968}; 2969 2970template <class _Hp> 2971struct __check_complete<_Hp, _Hp> 2972 : private __check_complete<_Hp> 2973{ 2974}; 2975 2976template <class _Tp> 2977struct __check_complete<_Tp> 2978{ 2979 static_assert(sizeof(_Tp) > 0, "Type must be complete."); 2980}; 2981 2982template <class _Tp> 2983struct __check_complete<_Tp&> 2984 : private __check_complete<_Tp> 2985{ 2986}; 2987 2988template <class _Tp> 2989struct __check_complete<_Tp&&> 2990 : private __check_complete<_Tp> 2991{ 2992}; 2993 2994template <class _Rp, class ..._Param> 2995struct __check_complete<_Rp (*)(_Param...)> 2996 : private __check_complete<_Rp> 2997{ 2998}; 2999 3000template <class ..._Param> 3001struct __check_complete<void (*)(_Param...)> 3002{ 3003}; 3004 3005template <class _Rp, class ..._Param> 3006struct __check_complete<_Rp (_Param...)> 3007 : private __check_complete<_Rp> 3008{ 3009}; 3010 3011template <class ..._Param> 3012struct __check_complete<void (_Param...)> 3013{ 3014}; 3015 3016template <class _Rp, class _Class, class ..._Param> 3017struct __check_complete<_Rp (_Class::*)(_Param...)> 3018 : private __check_complete<_Class> 3019{ 3020}; 3021 3022template <class _Rp, class _Class, class ..._Param> 3023struct __check_complete<_Rp (_Class::*)(_Param...) const> 3024 : private __check_complete<_Class> 3025{ 3026}; 3027 3028template <class _Rp, class _Class, class ..._Param> 3029struct __check_complete<_Rp (_Class::*)(_Param...) volatile> 3030 : private __check_complete<_Class> 3031{ 3032}; 3033 3034template <class _Rp, class _Class, class ..._Param> 3035struct __check_complete<_Rp (_Class::*)(_Param...) const volatile> 3036 : private __check_complete<_Class> 3037{ 3038}; 3039 3040#if __has_feature(cxx_reference_qualified_functions) 3041 3042template <class _Rp, class _Class, class ..._Param> 3043struct __check_complete<_Rp (_Class::*)(_Param...) &> 3044 : private __check_complete<_Class> 3045{ 3046}; 3047 3048template <class _Rp, class _Class, class ..._Param> 3049struct __check_complete<_Rp (_Class::*)(_Param...) const&> 3050 : private __check_complete<_Class> 3051{ 3052}; 3053 3054template <class _Rp, class _Class, class ..._Param> 3055struct __check_complete<_Rp (_Class::*)(_Param...) volatile&> 3056 : private __check_complete<_Class> 3057{ 3058}; 3059 3060template <class _Rp, class _Class, class ..._Param> 3061struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&> 3062 : private __check_complete<_Class> 3063{ 3064}; 3065 3066template <class _Rp, class _Class, class ..._Param> 3067struct __check_complete<_Rp (_Class::*)(_Param...) &&> 3068 : private __check_complete<_Class> 3069{ 3070}; 3071 3072template <class _Rp, class _Class, class ..._Param> 3073struct __check_complete<_Rp (_Class::*)(_Param...) const&&> 3074 : private __check_complete<_Class> 3075{ 3076}; 3077 3078template <class _Rp, class _Class, class ..._Param> 3079struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&> 3080 : private __check_complete<_Class> 3081{ 3082}; 3083 3084template <class _Rp, class _Class, class ..._Param> 3085struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&> 3086 : private __check_complete<_Class> 3087{ 3088}; 3089 3090#endif 3091 3092template <class _Rp, class _Class> 3093struct __check_complete<_Rp _Class::*> 3094 : private __check_complete<_Class> 3095{ 3096}; 3097 3098// __invoke forward declarations 3099 3100// fall back - none of the bullets 3101 3102template <class ..._Args> 3103auto 3104__invoke(__any, _Args&& ...__args) 3105 -> __nat; 3106 3107// bullets 1 and 2 3108 3109template <class _Fp, class _A0, class ..._Args, 3110 class = typename enable_if 3111 < 3112 is_member_function_pointer<typename remove_reference<_Fp>::type>::value && 3113 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3114 typename remove_reference<_A0>::type>::value 3115 >::type 3116 > 3117_LIBCPP_INLINE_VISIBILITY 3118auto 3119__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3120 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)); 3121 3122template <class _Fp, class _A0, class ..._Args, 3123 class = typename enable_if 3124 < 3125 is_member_function_pointer<typename remove_reference<_Fp>::type>::value && 3126 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3127 typename remove_reference<_A0>::type>::value 3128 >::type 3129 > 3130_LIBCPP_INLINE_VISIBILITY 3131auto 3132__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3133 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)); 3134 3135// bullets 3 and 4 3136 3137template <class _Fp, class _A0, 3138 class = typename enable_if 3139 < 3140 is_member_object_pointer<typename remove_reference<_Fp>::type>::value && 3141 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3142 typename remove_reference<_A0>::type>::value 3143 >::type 3144 > 3145_LIBCPP_INLINE_VISIBILITY 3146auto 3147__invoke(_Fp&& __f, _A0&& __a0) 3148 -> decltype(_VSTD::forward<_A0>(__a0).*__f); 3149 3150template <class _Fp, class _A0, 3151 class = typename enable_if 3152 < 3153 is_member_object_pointer<typename remove_reference<_Fp>::type>::value && 3154 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3155 typename remove_reference<_A0>::type>::value 3156 >::type 3157 > 3158_LIBCPP_INLINE_VISIBILITY 3159auto 3160__invoke(_Fp&& __f, _A0&& __a0) 3161 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f); 3162 3163// bullet 5 3164 3165template <class _Fp, class ..._Args> 3166_LIBCPP_INLINE_VISIBILITY 3167auto 3168__invoke(_Fp&& __f, _Args&& ...__args) 3169 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)); 3170 3171// __invokable 3172 3173template <class _Fp, class ..._Args> 3174struct __invokable_imp 3175 : private __check_complete<_Fp> 3176{ 3177 typedef decltype( 3178 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...) 3179 ) type; 3180 static const bool value = !is_same<type, __nat>::value; 3181}; 3182 3183template <class _Fp, class ..._Args> 3184struct __invokable 3185 : public integral_constant<bool, 3186 __invokable_imp<_Fp, _Args...>::value> 3187{ 3188}; 3189 3190// __invoke_of 3191 3192template <bool _Invokable, class _Fp, class ..._Args> 3193struct __invoke_of_imp // false 3194{ 3195}; 3196 3197template <class _Fp, class ..._Args> 3198struct __invoke_of_imp<true, _Fp, _Args...> 3199{ 3200 typedef typename __invokable_imp<_Fp, _Args...>::type type; 3201}; 3202 3203template <class _Fp, class ..._Args> 3204struct __invoke_of 3205 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...> 3206{ 3207}; 3208 3209template <class _Fp, class ..._Args> 3210class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)> 3211 : public __invoke_of<_Fp, _Args...> 3212{ 3213}; 3214 3215#if _LIBCPP_STD_VER > 11 3216template <class _Tp> using result_of_t = typename result_of<_Tp>::type; 3217#endif 3218 3219#endif // _LIBCPP_HAS_NO_VARIADICS 3220 3221template <class _Tp> 3222inline _LIBCPP_INLINE_VISIBILITY 3223#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 3224typename enable_if 3225< 3226 is_move_constructible<_Tp>::value && 3227 is_move_assignable<_Tp>::value 3228>::type 3229#else 3230void 3231#endif 3232swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && 3233 is_nothrow_move_assignable<_Tp>::value) 3234{ 3235 _Tp __t(_VSTD::move(__x)); 3236 __x = _VSTD::move(__y); 3237 __y = _VSTD::move(__t); 3238} 3239 3240template <class _ForwardIterator1, class _ForwardIterator2> 3241inline _LIBCPP_INLINE_VISIBILITY 3242void 3243iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) 3244 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) 3245 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), 3246 *_VSTD::declval<_ForwardIterator2>()))) 3247{ 3248 swap(*__a, *__b); 3249} 3250 3251// __swappable 3252 3253namespace __detail 3254{ 3255 3256using _VSTD::swap; 3257__nat swap(__any, __any); 3258 3259template <class _Tp> 3260struct __swappable 3261{ 3262 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type; 3263 static const bool value = !is_same<type, __nat>::value; 3264}; 3265 3266} // __detail 3267 3268template <class _Tp> 3269struct __is_swappable 3270 : public integral_constant<bool, __detail::__swappable<_Tp>::value> 3271{ 3272}; 3273 3274#if __has_feature(cxx_noexcept) 3275 3276template <bool, class _Tp> 3277struct __is_nothrow_swappable_imp 3278 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(), 3279 _VSTD::declval<_Tp&>()))> 3280{ 3281}; 3282 3283template <class _Tp> 3284struct __is_nothrow_swappable_imp<false, _Tp> 3285 : public false_type 3286{ 3287}; 3288 3289template <class _Tp> 3290struct __is_nothrow_swappable 3291 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp> 3292{ 3293}; 3294 3295#else // __has_feature(cxx_noexcept) 3296 3297template <class _Tp> 3298struct __is_nothrow_swappable 3299 : public false_type 3300{ 3301}; 3302 3303#endif // __has_feature(cxx_noexcept) 3304 3305#ifdef _LIBCXX_UNDERLYING_TYPE 3306 3307template <class _Tp> 3308struct underlying_type 3309{ 3310 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; 3311}; 3312 3313#if _LIBCPP_STD_VER > 11 3314template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; 3315#endif 3316 3317#else // _LIBCXX_UNDERLYING_TYPE 3318 3319template <class _Tp, bool _Support = false> 3320struct underlying_type 3321{ 3322 static_assert(_Support, "The underyling_type trait requires compiler " 3323 "support. Either no such support exists or " 3324 "libc++ does not know how to use it."); 3325}; 3326 3327#endif // _LIBCXX_UNDERLYING_TYPE 3328 3329#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 3330 3331template <class _Tp> 3332struct __has_operator_addressof_imp 3333{ 3334 template <class> 3335 static auto __test(__any) -> false_type; 3336 template <class _Up> 3337 static auto __test(_Up* __u) 3338 -> typename __select_2nd<decltype(__u->operator&()), true_type>::type; 3339 3340 static const bool value = decltype(__test<_Tp>(nullptr))::value; 3341}; 3342 3343template <class _Tp> 3344struct __has_operator_addressof 3345 : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value> 3346{}; 3347 3348#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 3349 3350_LIBCPP_END_NAMESPACE_STD 3351 3352#endif // _LIBCPP_TYPE_TRAITS 3353