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