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