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