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