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