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