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