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#ifndef _LIBCPP_HAS_NO_VARIADICS 2080 2081// template <class T, class... Args> struct is_constructible; 2082 2083// main is_constructible test 2084 2085template <class _Tp, class ..._Args> 2086typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type 2087__is_constructible_test(_Tp&&, _Args&& ...); 2088 2089template <class ..._Args> 2090false_type 2091__is_constructible_test(__any, _Args&& ...); 2092 2093template <bool, class _Tp, class... _Args> 2094struct __libcpp_is_constructible // false, _Tp is not a scalar 2095 : public common_type 2096 < 2097 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...)) 2098 >::type 2099 {}; 2100 2101// function types are not constructible 2102 2103template <class _Rp, class... _A1, class... _A2> 2104struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...> 2105 : public false_type 2106 {}; 2107 2108// handle scalars and reference types 2109 2110// Scalars are default constructible, references are not 2111 2112template <class _Tp> 2113struct __libcpp_is_constructible<true, _Tp> 2114 : public is_scalar<_Tp> 2115 {}; 2116 2117// Scalars and references are constructible from one arg if that arg is 2118// implicitly convertible to the scalar or reference. 2119 2120template <class _Tp> 2121struct __is_constructible_ref 2122{ 2123 true_type static __lxx(_Tp); 2124 false_type static __lxx(...); 2125}; 2126 2127template <class _Tp, class _A0> 2128struct __libcpp_is_constructible<true, _Tp, _A0> 2129 : public common_type 2130 < 2131 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>())) 2132 >::type 2133 {}; 2134 2135// Scalars and references are not constructible from multiple args. 2136 2137template <class _Tp, class _A0, class ..._Args> 2138struct __libcpp_is_constructible<true, _Tp, _A0, _Args...> 2139 : public false_type 2140 {}; 2141 2142// Treat scalars and reference types separately 2143 2144template <bool, class _Tp, class... _Args> 2145struct __is_constructible_void_check 2146 : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2147 _Tp, _Args...> 2148 {}; 2149 2150// If any of T or Args is void, is_constructible should be false 2151 2152template <class _Tp, class... _Args> 2153struct __is_constructible_void_check<true, _Tp, _Args...> 2154 : public false_type 2155 {}; 2156 2157template <class ..._Args> struct __contains_void; 2158 2159template <> struct __contains_void<> : false_type {}; 2160 2161template <class _A0, class ..._Args> 2162struct __contains_void<_A0, _Args...> 2163{ 2164 static const bool value = is_void<_A0>::value || 2165 __contains_void<_Args...>::value; 2166}; 2167 2168// is_constructible entry point 2169 2170template <class _Tp, class... _Args> 2171struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2172 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value 2173 || is_abstract<_Tp>::value, 2174 _Tp, _Args...> 2175 {}; 2176 2177// Array types are default constructible if their element type 2178// is default constructible 2179 2180template <class _Ap, size_t _Np> 2181struct __libcpp_is_constructible<false, _Ap[_Np]> 2182 : public is_constructible<typename remove_all_extents<_Ap>::type> 2183 {}; 2184 2185// Otherwise array types are not constructible by this syntax 2186 2187template <class _Ap, size_t _Np, class ..._Args> 2188struct __libcpp_is_constructible<false, _Ap[_Np], _Args...> 2189 : public false_type 2190 {}; 2191 2192// Incomplete array types are not constructible 2193 2194template <class _Ap, class ..._Args> 2195struct __libcpp_is_constructible<false, _Ap[], _Args...> 2196 : public false_type 2197 {}; 2198 2199#else // _LIBCPP_HAS_NO_VARIADICS 2200 2201// template <class T> struct is_constructible0; 2202 2203// main is_constructible0 test 2204 2205template <class _Tp> 2206decltype((_Tp(), true_type())) 2207__is_constructible0_test(_Tp&); 2208 2209false_type 2210__is_constructible0_test(__any); 2211 2212template <class _Tp, class _A0> 2213decltype((_Tp(_VSTD::declval<_A0>()), true_type())) 2214__is_constructible1_test(_Tp&, _A0&); 2215 2216template <class _A0> 2217false_type 2218__is_constructible1_test(__any, _A0&); 2219 2220template <class _Tp, class _A0, class _A1> 2221decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) 2222__is_constructible2_test(_Tp&, _A0&, _A1&); 2223 2224template <class _A0, class _A1> 2225false_type 2226__is_constructible2_test(__any, _A0&, _A1&); 2227 2228template <bool, class _Tp> 2229struct __is_constructible0_imp // false, _Tp is not a scalar 2230 : public common_type 2231 < 2232 decltype(__is_constructible0_test(declval<_Tp&>())) 2233 >::type 2234 {}; 2235 2236template <bool, class _Tp, class _A0> 2237struct __is_constructible1_imp // false, _Tp is not a scalar 2238 : public common_type 2239 < 2240 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) 2241 >::type 2242 {}; 2243 2244template <bool, class _Tp, class _A0, class _A1> 2245struct __is_constructible2_imp // false, _Tp is not a scalar 2246 : public common_type 2247 < 2248 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) 2249 >::type 2250 {}; 2251 2252// handle scalars and reference types 2253 2254// Scalars are default constructible, references are not 2255 2256template <class _Tp> 2257struct __is_constructible0_imp<true, _Tp> 2258 : public is_scalar<_Tp> 2259 {}; 2260 2261template <class _Tp, class _A0> 2262struct __is_constructible1_imp<true, _Tp, _A0> 2263 : public is_convertible<_A0, _Tp> 2264 {}; 2265 2266template <class _Tp, class _A0, class _A1> 2267struct __is_constructible2_imp<true, _Tp, _A0, _A1> 2268 : public false_type 2269 {}; 2270 2271// Treat scalars and reference types separately 2272 2273template <bool, class _Tp> 2274struct __is_constructible0_void_check 2275 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2276 _Tp> 2277 {}; 2278 2279template <bool, class _Tp, class _A0> 2280struct __is_constructible1_void_check 2281 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2282 _Tp, _A0> 2283 {}; 2284 2285template <bool, class _Tp, class _A0, class _A1> 2286struct __is_constructible2_void_check 2287 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2288 _Tp, _A0, _A1> 2289 {}; 2290 2291// If any of T or Args is void, is_constructible should be false 2292 2293template <class _Tp> 2294struct __is_constructible0_void_check<true, _Tp> 2295 : public false_type 2296 {}; 2297 2298template <class _Tp, class _A0> 2299struct __is_constructible1_void_check<true, _Tp, _A0> 2300 : public false_type 2301 {}; 2302 2303template <class _Tp, class _A0, class _A1> 2304struct __is_constructible2_void_check<true, _Tp, _A0, _A1> 2305 : public false_type 2306 {}; 2307 2308// is_constructible entry point 2309 2310namespace __is_construct 2311{ 2312 2313struct __nat {}; 2314 2315} 2316 2317template <class _Tp, class _A0 = __is_construct::__nat, 2318 class _A1 = __is_construct::__nat> 2319struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2320 : public __is_constructible2_void_check<is_void<_Tp>::value 2321 || is_abstract<_Tp>::value 2322 || is_function<_Tp>::value 2323 || is_void<_A0>::value 2324 || is_void<_A1>::value, 2325 _Tp, _A0, _A1> 2326 {}; 2327 2328template <class _Tp> 2329struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> 2330 : public __is_constructible0_void_check<is_void<_Tp>::value 2331 || is_abstract<_Tp>::value 2332 || is_function<_Tp>::value, 2333 _Tp> 2334 {}; 2335 2336template <class _Tp, class _A0> 2337struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat> 2338 : public __is_constructible1_void_check<is_void<_Tp>::value 2339 || is_abstract<_Tp>::value 2340 || is_function<_Tp>::value 2341 || is_void<_A0>::value, 2342 _Tp, _A0> 2343 {}; 2344 2345// Array types are default constructible if their element type 2346// is default constructible 2347 2348template <class _Ap, size_t _Np> 2349struct __is_constructible0_imp<false, _Ap[_Np]> 2350 : public is_constructible<typename remove_all_extents<_Ap>::type> 2351 {}; 2352 2353template <class _Ap, size_t _Np, class _A0> 2354struct __is_constructible1_imp<false, _Ap[_Np], _A0> 2355 : public false_type 2356 {}; 2357 2358template <class _Ap, size_t _Np, class _A0, class _A1> 2359struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1> 2360 : public false_type 2361 {}; 2362 2363// Incomplete array types are not constructible 2364 2365template <class _Ap> 2366struct __is_constructible0_imp<false, _Ap[]> 2367 : public false_type 2368 {}; 2369 2370template <class _Ap, class _A0> 2371struct __is_constructible1_imp<false, _Ap[], _A0> 2372 : public false_type 2373 {}; 2374 2375template <class _Ap, class _A0, class _A1> 2376struct __is_constructible2_imp<false, _Ap[], _A0, _A1> 2377 : public false_type 2378 {}; 2379 2380#endif // _LIBCPP_HAS_NO_VARIADICS 2381 2382// is_default_constructible 2383 2384template <class _Tp> 2385struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible 2386 : public is_constructible<_Tp> 2387 {}; 2388 2389// is_copy_constructible 2390 2391template <class _Tp> 2392struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible 2393 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2394 {}; 2395 2396// is_move_constructible 2397 2398template <class _Tp> 2399struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible 2400#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2401 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2402#else 2403 : public is_copy_constructible<_Tp> 2404#endif 2405 {}; 2406 2407// is_trivially_constructible 2408 2409#ifndef _LIBCPP_HAS_NO_VARIADICS 2410 2411#if __has_feature(is_trivially_constructible) 2412 2413template <class _Tp, class... _Args> 2414struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2415 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> 2416{ 2417}; 2418 2419#else // !__has_feature(is_trivially_constructible) 2420 2421template <class _Tp, class... _Args> 2422struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2423 : false_type 2424{ 2425}; 2426 2427template <class _Tp> 2428struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> 2429#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2430 : integral_constant<bool, __has_trivial_constructor(_Tp)> 2431#else 2432 : integral_constant<bool, is_scalar<_Tp>::value> 2433#endif 2434{ 2435}; 2436 2437template <class _Tp> 2438#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2439struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&> 2440#else 2441struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp> 2442#endif 2443 : integral_constant<bool, is_scalar<_Tp>::value> 2444{ 2445}; 2446 2447template <class _Tp> 2448struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&> 2449 : integral_constant<bool, is_scalar<_Tp>::value> 2450{ 2451}; 2452 2453template <class _Tp> 2454struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&> 2455 : integral_constant<bool, is_scalar<_Tp>::value> 2456{ 2457}; 2458 2459#endif // !__has_feature(is_trivially_constructible) 2460 2461#else // _LIBCPP_HAS_NO_VARIADICS 2462 2463template <class _Tp, class _A0 = __is_construct::__nat, 2464 class _A1 = __is_construct::__nat> 2465struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2466 : false_type 2467{ 2468}; 2469 2470#if __has_feature(is_trivially_constructible) 2471 2472template <class _Tp> 2473struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, 2474 __is_construct::__nat> 2475 : integral_constant<bool, __is_trivially_constructible(_Tp)> 2476{ 2477}; 2478 2479template <class _Tp> 2480struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, 2481 __is_construct::__nat> 2482 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)> 2483{ 2484}; 2485 2486template <class _Tp> 2487struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, 2488 __is_construct::__nat> 2489 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)> 2490{ 2491}; 2492 2493template <class _Tp> 2494struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, 2495 __is_construct::__nat> 2496 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)> 2497{ 2498}; 2499 2500#else // !__has_feature(is_trivially_constructible) 2501 2502template <class _Tp> 2503struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, 2504 __is_construct::__nat> 2505 : integral_constant<bool, is_scalar<_Tp>::value> 2506{ 2507}; 2508 2509template <class _Tp> 2510struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, 2511 __is_construct::__nat> 2512 : integral_constant<bool, is_scalar<_Tp>::value> 2513{ 2514}; 2515 2516template <class _Tp> 2517struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, 2518 __is_construct::__nat> 2519 : integral_constant<bool, is_scalar<_Tp>::value> 2520{ 2521}; 2522 2523template <class _Tp> 2524struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, 2525 __is_construct::__nat> 2526 : integral_constant<bool, is_scalar<_Tp>::value> 2527{ 2528}; 2529 2530#endif // !__has_feature(is_trivially_constructible) 2531 2532#endif // _LIBCPP_HAS_NO_VARIADICS 2533 2534// is_trivially_default_constructible 2535 2536template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible 2537 : public is_trivially_constructible<_Tp> 2538 {}; 2539 2540// is_trivially_copy_constructible 2541 2542template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible 2543 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> 2544 {}; 2545 2546// is_trivially_move_constructible 2547 2548template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible 2549#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2550 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2551#else 2552 : public is_trivially_copy_constructible<_Tp> 2553#endif 2554 {}; 2555 2556// is_trivially_assignable 2557 2558#if __has_feature(is_trivially_constructible) 2559 2560template <class _Tp, class _Arg> 2561struct is_trivially_assignable 2562 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> 2563{ 2564}; 2565 2566#else // !__has_feature(is_trivially_constructible) 2567 2568template <class _Tp, class _Arg> 2569struct is_trivially_assignable 2570 : public false_type {}; 2571 2572template <class _Tp> 2573struct is_trivially_assignable<_Tp&, _Tp> 2574 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2575 2576template <class _Tp> 2577struct is_trivially_assignable<_Tp&, _Tp&> 2578 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2579 2580template <class _Tp> 2581struct is_trivially_assignable<_Tp&, const _Tp&> 2582 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2583 2584#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2585 2586template <class _Tp> 2587struct is_trivially_assignable<_Tp&, _Tp&&> 2588 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2589 2590#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2591 2592#endif // !__has_feature(is_trivially_constructible) 2593 2594// is_trivially_copy_assignable 2595 2596template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable 2597 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2598 const typename add_lvalue_reference<_Tp>::type> 2599 {}; 2600 2601// is_trivially_move_assignable 2602 2603template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable 2604 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2605#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2606 typename add_rvalue_reference<_Tp>::type> 2607#else 2608 typename add_lvalue_reference<_Tp>::type> 2609#endif 2610 {}; 2611 2612// is_trivially_destructible 2613 2614#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2615 2616template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible 2617 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {}; 2618 2619#else // _LIBCPP_HAS_TYPE_TRAITS 2620 2621template <class _Tp> struct __libcpp_trivial_destructor 2622 : public integral_constant<bool, is_scalar<_Tp>::value || 2623 is_reference<_Tp>::value> {}; 2624 2625template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible 2626 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; 2627 2628#endif // _LIBCPP_HAS_TYPE_TRAITS 2629 2630// is_nothrow_constructible 2631 2632#if 0 2633template <class _Tp, class... _Args> 2634struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2635 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))> 2636{ 2637}; 2638 2639#else 2640 2641#ifndef _LIBCPP_HAS_NO_VARIADICS 2642 2643#if __has_feature(cxx_noexcept) 2644 2645template <bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible; 2646 2647template <class _Tp, class... _Args> 2648struct __libcpp_is_nothrow_constructible<true, _Tp, _Args...> 2649 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 2650{ 2651}; 2652 2653template <class _Tp, class... _Args> 2654struct __libcpp_is_nothrow_constructible<false, _Tp, _Args...> 2655 : public false_type 2656{ 2657}; 2658 2659template <class _Tp, class... _Args> 2660struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2661 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...> 2662{ 2663}; 2664 2665template <class _Tp, size_t _Ns> 2666struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> 2667 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, _Tp> 2668{ 2669}; 2670 2671#else // __has_feature(cxx_noexcept) 2672 2673template <class _Tp, class... _Args> 2674struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2675 : false_type 2676{ 2677}; 2678 2679template <class _Tp> 2680struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> 2681#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2682 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2683#else 2684 : integral_constant<bool, is_scalar<_Tp>::value> 2685#endif 2686{ 2687}; 2688 2689template <class _Tp> 2690#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2691struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> 2692#else 2693struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> 2694#endif 2695#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2696 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2697#else 2698 : integral_constant<bool, is_scalar<_Tp>::value> 2699#endif 2700{ 2701}; 2702 2703template <class _Tp> 2704struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> 2705#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2706 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2707#else 2708 : integral_constant<bool, is_scalar<_Tp>::value> 2709#endif 2710{ 2711}; 2712 2713template <class _Tp> 2714struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> 2715#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2716 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2717#else 2718 : integral_constant<bool, is_scalar<_Tp>::value> 2719#endif 2720{ 2721}; 2722 2723#endif // __has_feature(cxx_noexcept) 2724 2725#else // _LIBCPP_HAS_NO_VARIADICS 2726 2727template <class _Tp, class _A0 = __is_construct::__nat, 2728 class _A1 = __is_construct::__nat> 2729struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2730 : false_type 2731{ 2732}; 2733 2734template <class _Tp> 2735struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat, 2736 __is_construct::__nat> 2737#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2738 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2739#else 2740 : integral_constant<bool, is_scalar<_Tp>::value> 2741#endif 2742{ 2743}; 2744 2745template <class _Tp> 2746struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, 2747 __is_construct::__nat> 2748#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2749 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2750#else 2751 : integral_constant<bool, is_scalar<_Tp>::value> 2752#endif 2753{ 2754}; 2755 2756template <class _Tp> 2757struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, 2758 __is_construct::__nat> 2759#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2760 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2761#else 2762 : integral_constant<bool, is_scalar<_Tp>::value> 2763#endif 2764{ 2765}; 2766 2767template <class _Tp> 2768struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, 2769 __is_construct::__nat> 2770#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2771 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2772#else 2773 : integral_constant<bool, is_scalar<_Tp>::value> 2774#endif 2775{ 2776}; 2777 2778#endif // _LIBCPP_HAS_NO_VARIADICS 2779#endif // __has_feature(is_nothrow_constructible) 2780 2781// is_nothrow_default_constructible 2782 2783template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible 2784 : public is_nothrow_constructible<_Tp> 2785 {}; 2786 2787// is_nothrow_copy_constructible 2788 2789template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible 2790 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2791 {}; 2792 2793// is_nothrow_move_constructible 2794 2795template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible 2796#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2797 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2798#else 2799 : public is_nothrow_copy_constructible<_Tp> 2800#endif 2801 {}; 2802 2803// is_nothrow_assignable 2804 2805#if __has_feature(cxx_noexcept) 2806 2807template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; 2808 2809template <class _Tp, class _Arg> 2810struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> 2811 : public false_type 2812{ 2813}; 2814 2815template <class _Tp, class _Arg> 2816struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> 2817 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > 2818{ 2819}; 2820 2821template <class _Tp, class _Arg> 2822struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable 2823 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> 2824{ 2825}; 2826 2827#else // __has_feature(cxx_noexcept) 2828 2829template <class _Tp, class _Arg> 2830struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable 2831 : public false_type {}; 2832 2833template <class _Tp> 2834struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> 2835#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2836 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2837#else 2838 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2839#endif 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&, const _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 2857#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2858 2859template <class _Tp> 2860struct is_nothrow_assignable<_Tp&, _Tp&&> 2861#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2862 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2863#else 2864 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2865#endif 2866 2867#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2868 2869#endif // __has_feature(cxx_noexcept) 2870 2871// is_nothrow_copy_assignable 2872 2873template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable 2874 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2875 const typename add_lvalue_reference<_Tp>::type> 2876 {}; 2877 2878// is_nothrow_move_assignable 2879 2880template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable 2881 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2882#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2883 typename add_rvalue_reference<_Tp>::type> 2884#else 2885 typename add_lvalue_reference<_Tp>::type> 2886#endif 2887 {}; 2888 2889// is_nothrow_destructible 2890 2891#if __has_feature(cxx_noexcept) 2892 2893template <bool, class _Tp> struct __libcpp_is_nothrow_destructible; 2894 2895template <class _Tp> 2896struct __libcpp_is_nothrow_destructible<false, _Tp> 2897 : public false_type 2898{ 2899}; 2900 2901template <class _Tp> 2902struct __libcpp_is_nothrow_destructible<true, _Tp> 2903 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > 2904{ 2905}; 2906 2907template <class _Tp> 2908struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible 2909 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> 2910{ 2911}; 2912 2913template <class _Tp, size_t _Ns> 2914struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]> 2915 : public is_nothrow_destructible<_Tp> 2916{ 2917}; 2918 2919template <class _Tp> 2920struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&> 2921 : public true_type 2922{ 2923}; 2924 2925#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2926 2927template <class _Tp> 2928struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&> 2929 : public true_type 2930{ 2931}; 2932 2933#endif 2934 2935#else 2936 2937template <class _Tp> struct __libcpp_nothrow_destructor 2938 : public integral_constant<bool, is_scalar<_Tp>::value || 2939 is_reference<_Tp>::value> {}; 2940 2941template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible 2942 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; 2943 2944#endif 2945 2946// is_pod 2947 2948#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2949 2950template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod 2951 : public integral_constant<bool, __is_pod(_Tp)> {}; 2952 2953#else // _LIBCPP_HAS_TYPE_TRAITS 2954 2955template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod 2956 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && 2957 is_trivially_copy_constructible<_Tp>::value && 2958 is_trivially_copy_assignable<_Tp>::value && 2959 is_trivially_destructible<_Tp>::value> {}; 2960 2961#endif // _LIBCPP_HAS_TYPE_TRAITS 2962 2963// is_literal_type; 2964 2965template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type 2966#if __has_feature(is_literal) 2967 : public integral_constant<bool, __is_literal(_Tp)> 2968#else 2969 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value || 2970 is_reference<typename remove_all_extents<_Tp>::type>::value> 2971#endif 2972 {}; 2973 2974// is_standard_layout; 2975 2976template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout 2977#if __has_feature(is_standard_layout) 2978 : public integral_constant<bool, __is_standard_layout(_Tp)> 2979#else 2980 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2981#endif 2982 {}; 2983 2984// is_trivially_copyable; 2985 2986template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable 2987#if __has_feature(is_trivially_copyable) 2988 : public integral_constant<bool, __is_trivially_copyable(_Tp)> 2989#else 2990 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2991#endif 2992 {}; 2993 2994// is_trivial; 2995 2996template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial 2997#if __has_feature(is_trivial) 2998 : public integral_constant<bool, __is_trivial(_Tp)> 2999#else 3000 : integral_constant<bool, is_trivially_copyable<_Tp>::value && 3001 is_trivially_default_constructible<_Tp>::value> 3002#endif 3003 {}; 3004 3005#ifndef _LIBCPP_HAS_NO_VARIADICS 3006 3007// Check for complete types 3008 3009template <class ..._Tp> struct __check_complete; 3010 3011template <> 3012struct __check_complete<> 3013{ 3014}; 3015 3016template <class _Hp, class _T0, class ..._Tp> 3017struct __check_complete<_Hp, _T0, _Tp...> 3018 : private __check_complete<_Hp>, 3019 private __check_complete<_T0, _Tp...> 3020{ 3021}; 3022 3023template <class _Hp> 3024struct __check_complete<_Hp, _Hp> 3025 : private __check_complete<_Hp> 3026{ 3027}; 3028 3029template <class _Tp> 3030struct __check_complete<_Tp> 3031{ 3032 static_assert(sizeof(_Tp) > 0, "Type must be complete."); 3033}; 3034 3035template <class _Tp> 3036struct __check_complete<_Tp&> 3037 : private __check_complete<_Tp> 3038{ 3039}; 3040 3041template <class _Tp> 3042struct __check_complete<_Tp&&> 3043 : private __check_complete<_Tp> 3044{ 3045}; 3046 3047template <class _Rp, class ..._Param> 3048struct __check_complete<_Rp (*)(_Param...)> 3049 : private __check_complete<_Rp> 3050{ 3051}; 3052 3053template <class ..._Param> 3054struct __check_complete<void (*)(_Param...)> 3055{ 3056}; 3057 3058template <class _Rp, class ..._Param> 3059struct __check_complete<_Rp (_Param...)> 3060 : private __check_complete<_Rp> 3061{ 3062}; 3063 3064template <class ..._Param> 3065struct __check_complete<void (_Param...)> 3066{ 3067}; 3068 3069template <class _Rp, class _Class, class ..._Param> 3070struct __check_complete<_Rp (_Class::*)(_Param...)> 3071 : private __check_complete<_Class> 3072{ 3073}; 3074 3075template <class _Rp, class _Class, class ..._Param> 3076struct __check_complete<_Rp (_Class::*)(_Param...) const> 3077 : private __check_complete<_Class> 3078{ 3079}; 3080 3081template <class _Rp, class _Class, class ..._Param> 3082struct __check_complete<_Rp (_Class::*)(_Param...) volatile> 3083 : private __check_complete<_Class> 3084{ 3085}; 3086 3087template <class _Rp, class _Class, class ..._Param> 3088struct __check_complete<_Rp (_Class::*)(_Param...) const volatile> 3089 : private __check_complete<_Class> 3090{ 3091}; 3092 3093#if __has_feature(cxx_reference_qualified_functions) 3094 3095template <class _Rp, class _Class, class ..._Param> 3096struct __check_complete<_Rp (_Class::*)(_Param...) &> 3097 : private __check_complete<_Class> 3098{ 3099}; 3100 3101template <class _Rp, class _Class, class ..._Param> 3102struct __check_complete<_Rp (_Class::*)(_Param...) const&> 3103 : private __check_complete<_Class> 3104{ 3105}; 3106 3107template <class _Rp, class _Class, class ..._Param> 3108struct __check_complete<_Rp (_Class::*)(_Param...) volatile&> 3109 : private __check_complete<_Class> 3110{ 3111}; 3112 3113template <class _Rp, class _Class, class ..._Param> 3114struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&> 3115 : private __check_complete<_Class> 3116{ 3117}; 3118 3119template <class _Rp, class _Class, class ..._Param> 3120struct __check_complete<_Rp (_Class::*)(_Param...) &&> 3121 : private __check_complete<_Class> 3122{ 3123}; 3124 3125template <class _Rp, class _Class, class ..._Param> 3126struct __check_complete<_Rp (_Class::*)(_Param...) const&&> 3127 : private __check_complete<_Class> 3128{ 3129}; 3130 3131template <class _Rp, class _Class, class ..._Param> 3132struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&> 3133 : private __check_complete<_Class> 3134{ 3135}; 3136 3137template <class _Rp, class _Class, class ..._Param> 3138struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&> 3139 : private __check_complete<_Class> 3140{ 3141}; 3142 3143#endif 3144 3145template <class _Rp, class _Class> 3146struct __check_complete<_Rp _Class::*> 3147 : private __check_complete<_Class> 3148{ 3149}; 3150 3151// __invoke forward declarations 3152 3153// fall back - none of the bullets 3154 3155template <class ..._Args> 3156auto 3157__invoke(__any, _Args&& ...__args) 3158 -> __nat; 3159 3160// bullets 1 and 2 3161 3162template <class _Fp, class _A0, class ..._Args, 3163 class = typename enable_if 3164 < 3165 is_member_function_pointer<typename remove_reference<_Fp>::type>::value && 3166 is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type, 3167 typename remove_reference<_A0>::type>::value 3168 >::type 3169 > 3170_LIBCPP_INLINE_VISIBILITY 3171auto 3172__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3173 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)); 3174 3175template <class _Fp, class _A0, class ..._Args, 3176 class = typename enable_if 3177 < 3178 is_member_function_pointer<typename remove_reference<_Fp>::type>::value && 3179 !is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type, 3180 typename remove_reference<_A0>::type>::value 3181 >::type 3182 > 3183_LIBCPP_INLINE_VISIBILITY 3184auto 3185__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3186 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)); 3187 3188// bullets 3 and 4 3189 3190template <class _Fp, class _A0, 3191 class = typename enable_if 3192 < 3193 is_member_object_pointer<typename remove_reference<_Fp>::type>::value && 3194 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3195 typename remove_reference<_A0>::type>::value 3196 >::type 3197 > 3198_LIBCPP_INLINE_VISIBILITY 3199auto 3200__invoke(_Fp&& __f, _A0&& __a0) 3201 -> decltype(_VSTD::forward<_A0>(__a0).*__f); 3202 3203template <class _Fp, class _A0, 3204 class = typename enable_if 3205 < 3206 is_member_object_pointer<typename remove_reference<_Fp>::type>::value && 3207 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3208 typename remove_reference<_A0>::type>::value 3209 >::type 3210 > 3211_LIBCPP_INLINE_VISIBILITY 3212auto 3213__invoke(_Fp&& __f, _A0&& __a0) 3214 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f); 3215 3216// bullet 5 3217 3218template <class _Fp, class ..._Args> 3219_LIBCPP_INLINE_VISIBILITY 3220auto 3221__invoke(_Fp&& __f, _Args&& ...__args) 3222 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)); 3223 3224// __invokable 3225 3226template <class _Fp, class ..._Args> 3227struct __invokable_imp 3228 : private __check_complete<_Fp> 3229{ 3230 typedef decltype( 3231 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...) 3232 ) type; 3233 static const bool value = !is_same<type, __nat>::value; 3234}; 3235 3236template <class _Fp, class ..._Args> 3237struct __invokable 3238 : public integral_constant<bool, 3239 __invokable_imp<_Fp, _Args...>::value> 3240{ 3241}; 3242 3243// __invoke_of 3244 3245template <bool _Invokable, class _Fp, class ..._Args> 3246struct __invoke_of_imp // false 3247{ 3248}; 3249 3250template <class _Fp, class ..._Args> 3251struct __invoke_of_imp<true, _Fp, _Args...> 3252{ 3253 typedef typename __invokable_imp<_Fp, _Args...>::type type; 3254}; 3255 3256template <class _Fp, class ..._Args> 3257struct __invoke_of 3258 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...> 3259{ 3260}; 3261 3262template <class _Fp, class ..._Args> 3263class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)> 3264 : public __invoke_of<_Fp, _Args...> 3265{ 3266}; 3267 3268#if _LIBCPP_STD_VER > 11 3269template <class _Tp> using result_of_t = typename result_of<_Tp>::type; 3270#endif 3271 3272#endif // _LIBCPP_HAS_NO_VARIADICS 3273 3274template <class _Tp> 3275inline _LIBCPP_INLINE_VISIBILITY 3276#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 3277typename enable_if 3278< 3279 is_move_constructible<_Tp>::value && 3280 is_move_assignable<_Tp>::value 3281>::type 3282#else 3283void 3284#endif 3285swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && 3286 is_nothrow_move_assignable<_Tp>::value) 3287{ 3288 _Tp __t(_VSTD::move(__x)); 3289 __x = _VSTD::move(__y); 3290 __y = _VSTD::move(__t); 3291} 3292 3293template <class _ForwardIterator1, class _ForwardIterator2> 3294inline _LIBCPP_INLINE_VISIBILITY 3295void 3296iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) 3297 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) 3298 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), 3299 *_VSTD::declval<_ForwardIterator2>()))) 3300{ 3301 swap(*__a, *__b); 3302} 3303 3304// __swappable 3305 3306namespace __detail 3307{ 3308 3309using _VSTD::swap; 3310__nat swap(__any, __any); 3311 3312template <class _Tp> 3313struct __swappable 3314{ 3315 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type; 3316 static const bool value = !is_same<type, __nat>::value; 3317}; 3318 3319} // __detail 3320 3321template <class _Tp> 3322struct __is_swappable 3323 : public integral_constant<bool, __detail::__swappable<_Tp>::value> 3324{ 3325}; 3326 3327#if __has_feature(cxx_noexcept) 3328 3329template <bool, class _Tp> 3330struct __is_nothrow_swappable_imp 3331 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(), 3332 _VSTD::declval<_Tp&>()))> 3333{ 3334}; 3335 3336template <class _Tp> 3337struct __is_nothrow_swappable_imp<false, _Tp> 3338 : public false_type 3339{ 3340}; 3341 3342template <class _Tp> 3343struct __is_nothrow_swappable 3344 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp> 3345{ 3346}; 3347 3348#else // __has_feature(cxx_noexcept) 3349 3350template <class _Tp> 3351struct __is_nothrow_swappable 3352 : public false_type 3353{ 3354}; 3355 3356#endif // __has_feature(cxx_noexcept) 3357 3358#ifdef _LIBCXX_UNDERLYING_TYPE 3359 3360template <class _Tp> 3361struct underlying_type 3362{ 3363 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; 3364}; 3365 3366#if _LIBCPP_STD_VER > 11 3367template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; 3368#endif 3369 3370#else // _LIBCXX_UNDERLYING_TYPE 3371 3372template <class _Tp, bool _Support = false> 3373struct underlying_type 3374{ 3375 static_assert(_Support, "The underyling_type trait requires compiler " 3376 "support. Either no such support exists or " 3377 "libc++ does not know how to use it."); 3378}; 3379 3380#endif // _LIBCXX_UNDERLYING_TYPE 3381 3382#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 3383 3384template <class _Tp> 3385struct __has_operator_addressof_imp 3386{ 3387 template <class> 3388 static auto __test(__any) -> false_type; 3389 template <class _Up> 3390 static auto __test(_Up* __u) 3391 -> typename __select_2nd<decltype(__u->operator&()), true_type>::type; 3392 3393 static const bool value = decltype(__test<_Tp>(nullptr))::value; 3394}; 3395 3396template <class _Tp> 3397struct __has_operator_addressof 3398 : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value> 3399{}; 3400 3401#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 3402 3403_LIBCPP_END_NAMESPACE_STD 3404 3405#endif // _LIBCPP_TYPE_TRAITS 3406