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; // C++11 23 typedef integral_constant<bool, false> false_type; // C++11 24 25 template <bool B> // C++14 26 using bool_constant = integral_constant<bool, B>; // C++14 27 typedef bool_constant<true> true_type; // C++14 28 typedef bool_constant<false> false_type; // C++14 29 30 // helper traits 31 template <bool, class T = void> struct enable_if; 32 template <bool, class T, class F> struct conditional; 33 34 // Primary classification traits: 35 template <class T> struct is_void; 36 template <class T> struct is_null_pointer; // C++14 37 template <class T> struct is_integral; 38 template <class T> struct is_floating_point; 39 template <class T> struct is_array; 40 template <class T> struct is_pointer; 41 template <class T> struct is_lvalue_reference; 42 template <class T> struct is_rvalue_reference; 43 template <class T> struct is_member_object_pointer; 44 template <class T> struct is_member_function_pointer; 45 template <class T> struct is_enum; 46 template <class T> struct is_union; 47 template <class T> struct is_class; 48 template <class T> struct is_function; 49 50 // Secondary classification traits: 51 template <class T> struct is_reference; 52 template <class T> struct is_arithmetic; 53 template <class T> struct is_fundamental; 54 template <class T> struct is_member_pointer; 55 template <class T> struct is_scalar; 56 template <class T> struct is_object; 57 template <class T> struct is_compound; 58 59 // Const-volatile properties and transformations: 60 template <class T> struct is_const; 61 template <class T> struct is_volatile; 62 template <class T> struct remove_const; 63 template <class T> struct remove_volatile; 64 template <class T> struct remove_cv; 65 template <class T> struct add_const; 66 template <class T> struct add_volatile; 67 template <class T> struct add_cv; 68 69 // Reference transformations: 70 template <class T> struct remove_reference; 71 template <class T> struct add_lvalue_reference; 72 template <class T> struct add_rvalue_reference; 73 74 // Pointer transformations: 75 template <class T> struct remove_pointer; 76 template <class T> struct add_pointer; 77 78 template<class T> struct type_identity; // C++20 79 template<class T> 80 using type_identity_t = typename type_identity<T>::type; // C++20 81 82 // Integral properties: 83 template <class T> struct is_signed; 84 template <class T> struct is_unsigned; 85 template <class T> struct make_signed; 86 template <class T> struct make_unsigned; 87 88 // Array properties and transformations: 89 template <class T> struct rank; 90 template <class T, unsigned I = 0> struct extent; 91 template <class T> struct remove_extent; 92 template <class T> struct remove_all_extents; 93 94 // Member introspection: 95 template <class T> struct is_pod; 96 template <class T> struct is_trivial; 97 template <class T> struct is_trivially_copyable; 98 template <class T> struct is_standard_layout; 99 template <class T> struct is_literal_type; 100 template <class T> struct is_empty; 101 template <class T> struct is_polymorphic; 102 template <class T> struct is_abstract; 103 template <class T> struct is_final; // C++14 104 template <class T> struct is_aggregate; // C++17 105 106 template <class T, class... Args> struct is_constructible; 107 template <class T> struct is_default_constructible; 108 template <class T> struct is_copy_constructible; 109 template <class T> struct is_move_constructible; 110 template <class T, class U> struct is_assignable; 111 template <class T> struct is_copy_assignable; 112 template <class T> struct is_move_assignable; 113 template <class T, class U> struct is_swappable_with; // C++17 114 template <class T> struct is_swappable; // C++17 115 template <class T> struct is_destructible; 116 117 template <class T, class... Args> struct is_trivially_constructible; 118 template <class T> struct is_trivially_default_constructible; 119 template <class T> struct is_trivially_copy_constructible; 120 template <class T> struct is_trivially_move_constructible; 121 template <class T, class U> struct is_trivially_assignable; 122 template <class T> struct is_trivially_copy_assignable; 123 template <class T> struct is_trivially_move_assignable; 124 template <class T> struct is_trivially_destructible; 125 126 template <class T, class... Args> struct is_nothrow_constructible; 127 template <class T> struct is_nothrow_default_constructible; 128 template <class T> struct is_nothrow_copy_constructible; 129 template <class T> struct is_nothrow_move_constructible; 130 template <class T, class U> struct is_nothrow_assignable; 131 template <class T> struct is_nothrow_copy_assignable; 132 template <class T> struct is_nothrow_move_assignable; 133 template <class T, class U> struct is_nothrow_swappable_with; // C++17 134 template <class T> struct is_nothrow_swappable; // C++17 135 template <class T> struct is_nothrow_destructible; 136 137 template <class T> struct has_virtual_destructor; 138 139 template<class T> struct has_unique_object_representations; // C++17 140 141 // Relationships between types: 142 template <class T, class U> struct is_same; 143 template <class Base, class Derived> struct is_base_of; 144 template <class From, class To> struct is_convertible; 145 146 template <class Fn, class... ArgTypes> struct is_invocable; 147 template <class R, class Fn, class... ArgTypes> struct is_invocable_r; 148 149 template <class Fn, class... ArgTypes> struct is_nothrow_invocable; 150 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r; 151 152 // Alignment properties and transformations: 153 template <class T> struct alignment_of; 154 template <size_t Len, size_t Align = most_stringent_alignment_requirement> 155 struct aligned_storage; 156 template <size_t Len, class... Types> struct aligned_union; 157 template <class T> struct remove_cvref; // C++20 158 159 template <class T> struct decay; 160 template <class... T> struct common_type; 161 template <class T> struct underlying_type; 162 template <class> class result_of; // undefined 163 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; 164 template <class Fn, class... ArgTypes> struct invoke_result; // C++17 165 166 // const-volatile modifications: 167 template <class T> 168 using remove_const_t = typename remove_const<T>::type; // C++14 169 template <class T> 170 using remove_volatile_t = typename remove_volatile<T>::type; // C++14 171 template <class T> 172 using remove_cv_t = typename remove_cv<T>::type; // C++14 173 template <class T> 174 using add_const_t = typename add_const<T>::type; // C++14 175 template <class T> 176 using add_volatile_t = typename add_volatile<T>::type; // C++14 177 template <class T> 178 using add_cv_t = typename add_cv<T>::type; // C++14 179 180 // reference modifications: 181 template <class T> 182 using remove_reference_t = typename remove_reference<T>::type; // C++14 183 template <class T> 184 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14 185 template <class T> 186 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14 187 188 // sign modifications: 189 template <class T> 190 using make_signed_t = typename make_signed<T>::type; // C++14 191 template <class T> 192 using make_unsigned_t = typename make_unsigned<T>::type; // C++14 193 194 // array modifications: 195 template <class T> 196 using remove_extent_t = typename remove_extent<T>::type; // C++14 197 template <class T> 198 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14 199 200 // pointer modifications: 201 template <class T> 202 using remove_pointer_t = typename remove_pointer<T>::type; // C++14 203 template <class T> 204 using add_pointer_t = typename add_pointer<T>::type; // C++14 205 206 // other transformations: 207 template <size_t Len, std::size_t Align=default-alignment> 208 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14 209 template <std::size_t Len, class... Types> 210 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14 211 template <class T> 212 using remove_cvref_t = typename remove_cvref<T>::type; // C++20 213 template <class T> 214 using decay_t = typename decay<T>::type; // C++14 215 template <bool b, class T=void> 216 using enable_if_t = typename enable_if<b,T>::type; // C++14 217 template <bool b, class T, class F> 218 using conditional_t = typename conditional<b,T,F>::type; // C++14 219 template <class... T> 220 using common_type_t = typename common_type<T...>::type; // C++14 221 template <class T> 222 using underlying_type_t = typename underlying_type<T>::type; // C++14 223 template <class T> 224 using result_of_t = typename result_of<T>::type; // C++14 225 template <class Fn, class... ArgTypes> 226 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17 227 228 template <class...> 229 using void_t = void; // C++17 230 231 // See C++14 20.10.4.1, primary type categories 232 template <class T> inline constexpr bool is_void_v 233 = is_void<T>::value; // C++17 234 template <class T> inline constexpr bool is_null_pointer_v 235 = is_null_pointer<T>::value; // C++17 236 template <class T> inline constexpr bool is_integral_v 237 = is_integral<T>::value; // C++17 238 template <class T> inline constexpr bool is_floating_point_v 239 = is_floating_point<T>::value; // C++17 240 template <class T> inline constexpr bool is_array_v 241 = is_array<T>::value; // C++17 242 template <class T> inline constexpr bool is_pointer_v 243 = is_pointer<T>::value; // C++17 244 template <class T> inline constexpr bool is_lvalue_reference_v 245 = is_lvalue_reference<T>::value; // C++17 246 template <class T> inline constexpr bool is_rvalue_reference_v 247 = is_rvalue_reference<T>::value; // C++17 248 template <class T> inline constexpr bool is_member_object_pointer_v 249 = is_member_object_pointer<T>::value; // C++17 250 template <class T> inline constexpr bool is_member_function_pointer_v 251 = is_member_function_pointer<T>::value; // C++17 252 template <class T> inline constexpr bool is_enum_v 253 = is_enum<T>::value; // C++17 254 template <class T> inline constexpr bool is_union_v 255 = is_union<T>::value; // C++17 256 template <class T> inline constexpr bool is_class_v 257 = is_class<T>::value; // C++17 258 template <class T> inline constexpr bool is_function_v 259 = is_function<T>::value; // C++17 260 261 // See C++14 20.10.4.2, composite type categories 262 template <class T> inline constexpr bool is_reference_v 263 = is_reference<T>::value; // C++17 264 template <class T> inline constexpr bool is_arithmetic_v 265 = is_arithmetic<T>::value; // C++17 266 template <class T> inline constexpr bool is_fundamental_v 267 = is_fundamental<T>::value; // C++17 268 template <class T> inline constexpr bool is_object_v 269 = is_object<T>::value; // C++17 270 template <class T> inline constexpr bool is_scalar_v 271 = is_scalar<T>::value; // C++17 272 template <class T> inline constexpr bool is_compound_v 273 = is_compound<T>::value; // C++17 274 template <class T> inline constexpr bool is_member_pointer_v 275 = is_member_pointer<T>::value; // C++17 276 277 // See C++14 20.10.4.3, type properties 278 template <class T> inline constexpr bool is_const_v 279 = is_const<T>::value; // C++17 280 template <class T> inline constexpr bool is_volatile_v 281 = is_volatile<T>::value; // C++17 282 template <class T> inline constexpr bool is_trivial_v 283 = is_trivial<T>::value; // C++17 284 template <class T> inline constexpr bool is_trivially_copyable_v 285 = is_trivially_copyable<T>::value; // C++17 286 template <class T> inline constexpr bool is_standard_layout_v 287 = is_standard_layout<T>::value; // C++17 288 template <class T> inline constexpr bool is_pod_v 289 = is_pod<T>::value; // C++17 290 template <class T> inline constexpr bool is_literal_type_v 291 = is_literal_type<T>::value; // C++17 292 template <class T> inline constexpr bool is_empty_v 293 = is_empty<T>::value; // C++17 294 template <class T> inline constexpr bool is_polymorphic_v 295 = is_polymorphic<T>::value; // C++17 296 template <class T> inline constexpr bool is_abstract_v 297 = is_abstract<T>::value; // C++17 298 template <class T> inline constexpr bool is_final_v 299 = is_final<T>::value; // C++17 300 template <class T> inline constexpr bool is_aggregate_v 301 = is_aggregate<T>::value; // C++17 302 template <class T> inline constexpr bool is_signed_v 303 = is_signed<T>::value; // C++17 304 template <class T> inline constexpr bool is_unsigned_v 305 = is_unsigned<T>::value; // C++17 306 template <class T, class... Args> inline constexpr bool is_constructible_v 307 = is_constructible<T, Args...>::value; // C++17 308 template <class T> inline constexpr bool is_default_constructible_v 309 = is_default_constructible<T>::value; // C++17 310 template <class T> inline constexpr bool is_copy_constructible_v 311 = is_copy_constructible<T>::value; // C++17 312 template <class T> inline constexpr bool is_move_constructible_v 313 = is_move_constructible<T>::value; // C++17 314 template <class T, class U> inline constexpr bool is_assignable_v 315 = is_assignable<T, U>::value; // C++17 316 template <class T> inline constexpr bool is_copy_assignable_v 317 = is_copy_assignable<T>::value; // C++17 318 template <class T> inline constexpr bool is_move_assignable_v 319 = is_move_assignable<T>::value; // C++17 320 template <class T, class U> inline constexpr bool is_swappable_with_v 321 = is_swappable_with<T, U>::value; // C++17 322 template <class T> inline constexpr bool is_swappable_v 323 = is_swappable<T>::value; // C++17 324 template <class T> inline constexpr bool is_destructible_v 325 = is_destructible<T>::value; // C++17 326 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v 327 = is_trivially_constructible<T, Args...>::value; // C++17 328 template <class T> inline constexpr bool is_trivially_default_constructible_v 329 = is_trivially_default_constructible<T>::value; // C++17 330 template <class T> inline constexpr bool is_trivially_copy_constructible_v 331 = is_trivially_copy_constructible<T>::value; // C++17 332 template <class T> inline constexpr bool is_trivially_move_constructible_v 333 = is_trivially_move_constructible<T>::value; // C++17 334 template <class T, class U> inline constexpr bool is_trivially_assignable_v 335 = is_trivially_assignable<T, U>::value; // C++17 336 template <class T> inline constexpr bool is_trivially_copy_assignable_v 337 = is_trivially_copy_assignable<T>::value; // C++17 338 template <class T> inline constexpr bool is_trivially_move_assignable_v 339 = is_trivially_move_assignable<T>::value; // C++17 340 template <class T> inline constexpr bool is_trivially_destructible_v 341 = is_trivially_destructible<T>::value; // C++17 342 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v 343 = is_nothrow_constructible<T, Args...>::value; // C++17 344 template <class T> inline constexpr bool is_nothrow_default_constructible_v 345 = is_nothrow_default_constructible<T>::value; // C++17 346 template <class T> inline constexpr bool is_nothrow_copy_constructible_v 347 = is_nothrow_copy_constructible<T>::value; // C++17 348 template <class T> inline constexpr bool is_nothrow_move_constructible_v 349 = is_nothrow_move_constructible<T>::value; // C++17 350 template <class T, class U> inline constexpr bool is_nothrow_assignable_v 351 = is_nothrow_assignable<T, U>::value; // C++17 352 template <class T> inline constexpr bool is_nothrow_copy_assignable_v 353 = is_nothrow_copy_assignable<T>::value; // C++17 354 template <class T> inline constexpr bool is_nothrow_move_assignable_v 355 = is_nothrow_move_assignable<T>::value; // C++17 356 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v 357 = is_nothrow_swappable_with<T, U>::value; // C++17 358 template <class T> inline constexpr bool is_nothrow_swappable_v 359 = is_nothrow_swappable<T>::value; // C++17 360 template <class T> inline constexpr bool is_nothrow_destructible_v 361 = is_nothrow_destructible<T>::value; // C++17 362 template <class T> inline constexpr bool has_virtual_destructor_v 363 = has_virtual_destructor<T>::value; // C++17 364 template<class T> inline constexpr bool has_unique_object_representations_v // C++17 365 = has_unique_object_representations<T>::value; 366 367 // See C++14 20.10.5, type property queries 368 template <class T> inline constexpr size_t alignment_of_v 369 = alignment_of<T>::value; // C++17 370 template <class T> inline constexpr size_t rank_v 371 = rank<T>::value; // C++17 372 template <class T, unsigned I = 0> inline constexpr size_t extent_v 373 = extent<T, I>::value; // C++17 374 375 // See C++14 20.10.6, type relations 376 template <class T, class U> inline constexpr bool is_same_v 377 = is_same<T, U>::value; // C++17 378 template <class Base, class Derived> inline constexpr bool is_base_of_v 379 = is_base_of<Base, Derived>::value; // C++17 380 template <class From, class To> inline constexpr bool is_convertible_v 381 = is_convertible<From, To>::value; // C++17 382 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v 383 = is_invocable<Fn, ArgTypes...>::value; // C++17 384 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v 385 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17 386 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v 387 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17 388 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v 389 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17 390 391 // [meta.logical], logical operator traits: 392 template<class... B> struct conjunction; // C++17 393 template<class... B> 394 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17 395 template<class... B> struct disjunction; // C++17 396 template<class... B> 397 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17 398 template<class B> struct negation; // C++17 399 template<class B> 400 inline constexpr bool negation_v = negation<B>::value; // C++17 401 402 } 403 404 */ 405 #include <__config> 406 #include <cstddef> 407 #include <version> 408 409 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 410 #pragma GCC system_header 411 #endif 412 413 _LIBCPP_BEGIN_NAMESPACE_STD 414 415 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair; 416 template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper; 417 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; 418 419 template <class> 420 struct __void_t { typedef void type; }; 421 422 template <class _Tp> 423 struct __identity { typedef _Tp type; }; 424 425 template <class _Tp, bool> 426 struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; 427 428 template <bool _Bp, class _If, class _Then> 429 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;}; 430 template <class _If, class _Then> 431 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;}; 432 433 #if _LIBCPP_STD_VER > 11 434 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; 435 #endif 436 437 template <bool, class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if {}; 438 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;}; 439 440 template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {}; 441 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;}; 442 443 #if _LIBCPP_STD_VER > 11 444 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; 445 #endif 446 447 // addressof 448 #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF 449 450 template <class _Tp> 451 inline _LIBCPP_CONSTEXPR_AFTER_CXX14 452 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY 453 _Tp* 454 addressof(_Tp& __x) _NOEXCEPT 455 { 456 return __builtin_addressof(__x); 457 } 458 459 #else 460 461 template <class _Tp> 462 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY 463 _Tp* 464 addressof(_Tp& __x) _NOEXCEPT 465 { 466 return reinterpret_cast<_Tp *>( 467 const_cast<char *>(&reinterpret_cast<const volatile char &>(__x))); 468 } 469 470 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF 471 472 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) 473 // Objective-C++ Automatic Reference Counting uses qualified pointers 474 // that require special addressof() signatures. When 475 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler 476 // itself is providing these definitions. Otherwise, we provide them. 477 template <class _Tp> 478 inline _LIBCPP_INLINE_VISIBILITY 479 __strong _Tp* 480 addressof(__strong _Tp& __x) _NOEXCEPT 481 { 482 return &__x; 483 } 484 485 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK 486 template <class _Tp> 487 inline _LIBCPP_INLINE_VISIBILITY 488 __weak _Tp* 489 addressof(__weak _Tp& __x) _NOEXCEPT 490 { 491 return &__x; 492 } 493 #endif 494 495 template <class _Tp> 496 inline _LIBCPP_INLINE_VISIBILITY 497 __autoreleasing _Tp* 498 addressof(__autoreleasing _Tp& __x) _NOEXCEPT 499 { 500 return &__x; 501 } 502 503 template <class _Tp> 504 inline _LIBCPP_INLINE_VISIBILITY 505 __unsafe_unretained _Tp* 506 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT 507 { 508 return &__x; 509 } 510 #endif 511 512 #if !defined(_LIBCPP_CXX03_LANG) 513 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete; 514 #endif 515 516 struct __two {char __lx[2];}; 517 518 // helper class: 519 520 template <class _Tp, _Tp __v> 521 struct _LIBCPP_TEMPLATE_VIS integral_constant 522 { 523 static _LIBCPP_CONSTEXPR const _Tp value = __v; 524 typedef _Tp value_type; 525 typedef integral_constant type; 526 _LIBCPP_INLINE_VISIBILITY 527 _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} 528 #if _LIBCPP_STD_VER > 11 529 _LIBCPP_INLINE_VISIBILITY 530 constexpr value_type operator ()() const _NOEXCEPT {return value;} 531 #endif 532 }; 533 534 template <class _Tp, _Tp __v> 535 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; 536 537 #if _LIBCPP_STD_VER > 14 538 template <bool __b> 539 using bool_constant = integral_constant<bool, __b>; 540 #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> 541 #else 542 #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)> 543 #endif 544 545 typedef _LIBCPP_BOOL_CONSTANT(true) true_type; 546 typedef _LIBCPP_BOOL_CONSTANT(false) false_type; 547 548 #if !defined(_LIBCPP_CXX03_LANG) 549 550 // __lazy_and 551 552 template <bool _Last, class ..._Preds> 553 struct __lazy_and_impl; 554 555 template <class ..._Preds> 556 struct __lazy_and_impl<false, _Preds...> : false_type {}; 557 558 template <> 559 struct __lazy_and_impl<true> : true_type {}; 560 561 template <class _Pred> 562 struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {}; 563 564 template <class _Hp, class ..._Tp> 565 struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {}; 566 567 template <class _P1, class ..._Pr> 568 struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; 569 570 // __lazy_or 571 572 template <bool _List, class ..._Preds> 573 struct __lazy_or_impl; 574 575 template <class ..._Preds> 576 struct __lazy_or_impl<true, _Preds...> : true_type {}; 577 578 template <> 579 struct __lazy_or_impl<false> : false_type {}; 580 581 template <class _Hp, class ..._Tp> 582 struct __lazy_or_impl<false, _Hp, _Tp...> 583 : __lazy_or_impl<_Hp::type::value, _Tp...> {}; 584 585 template <class _P1, class ..._Pr> 586 struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {}; 587 588 // __lazy_not 589 590 template <class _Pred> 591 struct __lazy_not : integral_constant<bool, !_Pred::type::value> {}; 592 593 // __and_ 594 template<class...> struct __and_; 595 template<> struct __and_<> : true_type {}; 596 597 template<class _B0> struct __and_<_B0> : _B0 {}; 598 599 template<class _B0, class _B1> 600 struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {}; 601 602 template<class _B0, class _B1, class _B2, class... _Bn> 603 struct __and_<_B0, _B1, _B2, _Bn...> 604 : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {}; 605 606 // __or_ 607 template<class...> struct __or_; 608 template<> struct __or_<> : false_type {}; 609 610 template<class _B0> struct __or_<_B0> : _B0 {}; 611 612 template<class _B0, class _B1> 613 struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {}; 614 615 template<class _B0, class _B1, class _B2, class... _Bn> 616 struct __or_<_B0, _B1, _B2, _Bn...> 617 : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {}; 618 619 // __not_ 620 template<class _Tp> 621 struct __not_ : conditional<_Tp::value, false_type, true_type>::type {}; 622 623 #endif // !defined(_LIBCPP_CXX03_LANG) 624 625 // is_const 626 627 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; 628 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; 629 630 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 631 template <class _Tp> 632 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v 633 = is_const<_Tp>::value; 634 #endif 635 636 // is_volatile 637 638 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; 639 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; 640 641 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 642 template <class _Tp> 643 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v 644 = is_volatile<_Tp>::value; 645 #endif 646 647 // remove_const 648 649 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; 650 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;}; 651 #if _LIBCPP_STD_VER > 11 652 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; 653 #endif 654 655 // remove_volatile 656 657 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; 658 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; 659 #if _LIBCPP_STD_VER > 11 660 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; 661 #endif 662 663 // remove_cv 664 665 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv 666 {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; 667 #if _LIBCPP_STD_VER > 11 668 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; 669 #endif 670 671 // is_void 672 673 template <class _Tp> struct __libcpp_is_void : public false_type {}; 674 template <> struct __libcpp_is_void<void> : public true_type {}; 675 676 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void 677 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; 678 679 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 680 template <class _Tp> 681 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v 682 = is_void<_Tp>::value; 683 #endif 684 685 // __is_nullptr_t 686 687 template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; 688 template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {}; 689 690 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t 691 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; 692 693 #if _LIBCPP_STD_VER > 11 694 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer 695 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; 696 697 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 698 template <class _Tp> 699 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v 700 = is_null_pointer<_Tp>::value; 701 #endif 702 #endif 703 704 // is_integral 705 706 template <class _Tp> struct __libcpp_is_integral : public false_type {}; 707 template <> struct __libcpp_is_integral<bool> : public true_type {}; 708 template <> struct __libcpp_is_integral<char> : public true_type {}; 709 template <> struct __libcpp_is_integral<signed char> : public true_type {}; 710 template <> struct __libcpp_is_integral<unsigned char> : public true_type {}; 711 template <> struct __libcpp_is_integral<wchar_t> : public true_type {}; 712 #ifndef _LIBCPP_NO_HAS_CHAR8_T 713 template <> struct __libcpp_is_integral<char8_t> : public true_type {}; 714 #endif 715 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 716 template <> struct __libcpp_is_integral<char16_t> : public true_type {}; 717 template <> struct __libcpp_is_integral<char32_t> : public true_type {}; 718 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS 719 template <> struct __libcpp_is_integral<short> : public true_type {}; 720 template <> struct __libcpp_is_integral<unsigned short> : public true_type {}; 721 template <> struct __libcpp_is_integral<int> : public true_type {}; 722 template <> struct __libcpp_is_integral<unsigned int> : public true_type {}; 723 template <> struct __libcpp_is_integral<long> : public true_type {}; 724 template <> struct __libcpp_is_integral<unsigned long> : public true_type {}; 725 template <> struct __libcpp_is_integral<long long> : public true_type {}; 726 template <> struct __libcpp_is_integral<unsigned long long> : public true_type {}; 727 #ifndef _LIBCPP_HAS_NO_INT128 728 template <> struct __libcpp_is_integral<__int128_t> : public true_type {}; 729 template <> struct __libcpp_is_integral<__uint128_t> : public true_type {}; 730 #endif 731 732 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral 733 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; 734 735 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 736 template <class _Tp> 737 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v 738 = is_integral<_Tp>::value; 739 #endif 740 741 // is_floating_point 742 743 template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; 744 template <> struct __libcpp_is_floating_point<float> : public true_type {}; 745 template <> struct __libcpp_is_floating_point<double> : public true_type {}; 746 template <> struct __libcpp_is_floating_point<long double> : public true_type {}; 747 748 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point 749 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; 750 751 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 752 template <class _Tp> 753 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v 754 = is_floating_point<_Tp>::value; 755 #endif 756 757 // is_array 758 759 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array 760 : public false_type {}; 761 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> 762 : public true_type {}; 763 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> 764 : public true_type {}; 765 766 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 767 template <class _Tp> 768 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v 769 = is_array<_Tp>::value; 770 #endif 771 772 // is_pointer 773 774 template <class _Tp> struct __libcpp_is_pointer : public false_type {}; 775 template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; 776 777 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer 778 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {}; 779 780 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 781 template <class _Tp> 782 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v 783 = is_pointer<_Tp>::value; 784 #endif 785 786 // is_reference 787 788 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; 789 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; 790 791 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; 792 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 793 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; 794 #endif 795 796 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; 797 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; 798 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 799 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; 800 #endif 801 802 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 803 template <class _Tp> 804 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v 805 = is_reference<_Tp>::value; 806 807 template <class _Tp> 808 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v 809 = is_lvalue_reference<_Tp>::value; 810 811 template <class _Tp> 812 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v 813 = is_rvalue_reference<_Tp>::value; 814 #endif 815 // is_union 816 817 #if __has_feature(is_union) || (_GNUC_VER >= 403) 818 819 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union 820 : public integral_constant<bool, __is_union(_Tp)> {}; 821 822 #else 823 824 template <class _Tp> struct __libcpp_union : public false_type {}; 825 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union 826 : public __libcpp_union<typename remove_cv<_Tp>::type> {}; 827 828 #endif 829 830 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 831 template <class _Tp> 832 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v 833 = is_union<_Tp>::value; 834 #endif 835 836 // is_class 837 838 #if __has_feature(is_class) || (_GNUC_VER >= 403) 839 840 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class 841 : public integral_constant<bool, __is_class(_Tp)> {}; 842 843 #else 844 845 namespace __is_class_imp 846 { 847 template <class _Tp> char __test(int _Tp::*); 848 template <class _Tp> __two __test(...); 849 } 850 851 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class 852 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; 853 854 #endif 855 856 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 857 template <class _Tp> 858 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v 859 = is_class<_Tp>::value; 860 #endif 861 862 // is_same 863 864 template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; 865 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; 866 867 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 868 template <class _Tp, class _Up> 869 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v 870 = is_same<_Tp, _Up>::value; 871 #endif 872 873 // is_function 874 875 namespace __libcpp_is_function_imp 876 { 877 struct __dummy_type {}; 878 template <class _Tp> char __test(_Tp*); 879 template <class _Tp> char __test(__dummy_type); 880 template <class _Tp> __two __test(...); 881 template <class _Tp> _Tp& __source(int); 882 template <class _Tp> __dummy_type __source(...); 883 } 884 885 template <class _Tp, bool = is_class<_Tp>::value || 886 is_union<_Tp>::value || 887 is_void<_Tp>::value || 888 is_reference<_Tp>::value || 889 __is_nullptr_t<_Tp>::value > 890 struct __libcpp_is_function 891 : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1> 892 {}; 893 template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {}; 894 895 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function 896 : public __libcpp_is_function<_Tp> {}; 897 898 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 899 template <class _Tp> 900 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v 901 = is_function<_Tp>::value; 902 #endif 903 904 // is_member_function_pointer 905 906 // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {}; 907 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; 908 // 909 910 template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> 911 struct __member_pointer_traits_imp 912 { // forward declaration; specializations later 913 }; 914 915 916 template <class _Tp> struct __libcpp_is_member_function_pointer 917 : public false_type {}; 918 919 template <class _Ret, class _Class> 920 struct __libcpp_is_member_function_pointer<_Ret _Class::*> 921 : public is_function<_Ret> {}; 922 923 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer 924 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {}; 925 926 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 927 template <class _Tp> 928 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v 929 = is_member_function_pointer<_Tp>::value; 930 #endif 931 932 // is_member_pointer 933 934 template <class _Tp> struct __libcpp_is_member_pointer : public false_type {}; 935 template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; 936 937 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer 938 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {}; 939 940 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 941 template <class _Tp> 942 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v 943 = is_member_pointer<_Tp>::value; 944 #endif 945 946 // is_member_object_pointer 947 948 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer 949 : public integral_constant<bool, is_member_pointer<_Tp>::value && 950 !is_member_function_pointer<_Tp>::value> {}; 951 952 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 953 template <class _Tp> 954 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v 955 = is_member_object_pointer<_Tp>::value; 956 #endif 957 958 // is_enum 959 960 #if __has_feature(is_enum) || (_GNUC_VER >= 403) 961 962 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum 963 : public integral_constant<bool, __is_enum(_Tp)> {}; 964 965 #else 966 967 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum 968 : public integral_constant<bool, !is_void<_Tp>::value && 969 !is_integral<_Tp>::value && 970 !is_floating_point<_Tp>::value && 971 !is_array<_Tp>::value && 972 !is_pointer<_Tp>::value && 973 !is_reference<_Tp>::value && 974 !is_member_pointer<_Tp>::value && 975 !is_union<_Tp>::value && 976 !is_class<_Tp>::value && 977 !is_function<_Tp>::value > {}; 978 979 #endif 980 981 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 982 template <class _Tp> 983 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v 984 = is_enum<_Tp>::value; 985 #endif 986 987 // is_arithmetic 988 989 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic 990 : public integral_constant<bool, is_integral<_Tp>::value || 991 is_floating_point<_Tp>::value> {}; 992 993 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 994 template <class _Tp> 995 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v 996 = is_arithmetic<_Tp>::value; 997 #endif 998 999 // is_fundamental 1000 1001 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental 1002 : public integral_constant<bool, is_void<_Tp>::value || 1003 __is_nullptr_t<_Tp>::value || 1004 is_arithmetic<_Tp>::value> {}; 1005 1006 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1007 template <class _Tp> 1008 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v 1009 = is_fundamental<_Tp>::value; 1010 #endif 1011 1012 // is_scalar 1013 1014 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar 1015 : public integral_constant<bool, is_arithmetic<_Tp>::value || 1016 is_member_pointer<_Tp>::value || 1017 is_pointer<_Tp>::value || 1018 __is_nullptr_t<_Tp>::value || 1019 is_enum<_Tp>::value > {}; 1020 1021 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; 1022 1023 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1024 template <class _Tp> 1025 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v 1026 = is_scalar<_Tp>::value; 1027 #endif 1028 1029 // is_object 1030 1031 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object 1032 : public integral_constant<bool, is_scalar<_Tp>::value || 1033 is_array<_Tp>::value || 1034 is_union<_Tp>::value || 1035 is_class<_Tp>::value > {}; 1036 1037 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1038 template <class _Tp> 1039 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v 1040 = is_object<_Tp>::value; 1041 #endif 1042 1043 // is_compound 1044 1045 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound 1046 : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; 1047 1048 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1049 template <class _Tp> 1050 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v 1051 = is_compound<_Tp>::value; 1052 #endif 1053 1054 1055 // __is_referenceable [defns.referenceable] 1056 1057 struct __is_referenceable_impl { 1058 template <class _Tp> static _Tp& __test(int); 1059 template <class _Tp> static __two __test(...); 1060 }; 1061 1062 template <class _Tp> 1063 struct __is_referenceable : integral_constant<bool, 1064 !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {}; 1065 1066 1067 // add_const 1068 1069 template <class _Tp, bool = is_reference<_Tp>::value || 1070 is_function<_Tp>::value || 1071 is_const<_Tp>::value > 1072 struct __add_const {typedef _Tp type;}; 1073 1074 template <class _Tp> 1075 struct __add_const<_Tp, false> {typedef const _Tp type;}; 1076 1077 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const 1078 {typedef typename __add_const<_Tp>::type type;}; 1079 1080 #if _LIBCPP_STD_VER > 11 1081 template <class _Tp> using add_const_t = typename add_const<_Tp>::type; 1082 #endif 1083 1084 // add_volatile 1085 1086 template <class _Tp, bool = is_reference<_Tp>::value || 1087 is_function<_Tp>::value || 1088 is_volatile<_Tp>::value > 1089 struct __add_volatile {typedef _Tp type;}; 1090 1091 template <class _Tp> 1092 struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; 1093 1094 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile 1095 {typedef typename __add_volatile<_Tp>::type type;}; 1096 1097 #if _LIBCPP_STD_VER > 11 1098 template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; 1099 #endif 1100 1101 // add_cv 1102 1103 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv 1104 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;}; 1105 1106 #if _LIBCPP_STD_VER > 11 1107 template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; 1108 #endif 1109 1110 // remove_reference 1111 1112 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _Tp type;}; 1113 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _Tp type;}; 1114 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1115 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _Tp type;}; 1116 #endif 1117 1118 #if _LIBCPP_STD_VER > 11 1119 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; 1120 #endif 1121 1122 // add_lvalue_reference 1123 1124 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; }; 1125 template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; }; 1126 1127 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference 1128 {typedef typename __add_lvalue_reference_impl<_Tp>::type type;}; 1129 1130 #if _LIBCPP_STD_VER > 11 1131 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; 1132 #endif 1133 1134 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1135 1136 template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; }; 1137 template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; }; 1138 1139 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference 1140 {typedef typename __add_rvalue_reference_impl<_Tp>::type type;}; 1141 1142 #if _LIBCPP_STD_VER > 11 1143 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; 1144 #endif 1145 1146 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1147 1148 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1149 1150 template <class _Tp> _Tp&& __declval(int); 1151 template <class _Tp> _Tp __declval(long); 1152 1153 template <class _Tp> 1154 decltype(_VSTD::__declval<_Tp>(0)) 1155 declval() _NOEXCEPT; 1156 1157 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1158 1159 template <class _Tp> 1160 typename add_lvalue_reference<_Tp>::type 1161 declval(); 1162 1163 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1164 1165 // __uncvref 1166 1167 template <class _Tp> 1168 struct __uncvref { 1169 typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type; 1170 }; 1171 1172 template <class _Tp> 1173 struct __unconstref { 1174 typedef typename remove_const<typename remove_reference<_Tp>::type>::type type; 1175 }; 1176 1177 #ifndef _LIBCPP_CXX03_LANG 1178 template <class _Tp> 1179 using __uncvref_t = typename __uncvref<_Tp>::type; 1180 #endif 1181 1182 // __is_same_uncvref 1183 1184 template <class _Tp, class _Up> 1185 struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type, 1186 typename __uncvref<_Up>::type> {}; 1187 1188 #if _LIBCPP_STD_VER > 17 1189 // remove_cvref - same as __uncvref 1190 template <class _Tp> 1191 struct remove_cvref : public __uncvref<_Tp> {}; 1192 1193 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; 1194 #endif 1195 1196 1197 struct __any 1198 { 1199 __any(...); 1200 }; 1201 1202 // remove_pointer 1203 1204 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _Tp type;}; 1205 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _Tp type;}; 1206 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _Tp type;}; 1207 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;}; 1208 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;}; 1209 1210 #if _LIBCPP_STD_VER > 11 1211 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; 1212 #endif 1213 1214 // add_pointer 1215 1216 template <class _Tp, 1217 bool = __is_referenceable<_Tp>::value || 1218 is_same<typename remove_cv<_Tp>::type, void>::value> 1219 struct __add_pointer_impl 1220 {typedef typename remove_reference<_Tp>::type* type;}; 1221 template <class _Tp> struct __add_pointer_impl<_Tp, false> 1222 {typedef _Tp type;}; 1223 1224 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer 1225 {typedef typename __add_pointer_impl<_Tp>::type type;}; 1226 1227 #if _LIBCPP_STD_VER > 11 1228 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; 1229 #endif 1230 1231 // type_identity 1232 #if _LIBCPP_STD_VER > 17 1233 template<class _Tp> struct type_identity { typedef _Tp type; }; 1234 template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; 1235 #endif 1236 1237 // is_signed 1238 1239 template <class _Tp, bool = is_integral<_Tp>::value> 1240 struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {}; 1241 1242 template <class _Tp> 1243 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point 1244 1245 template <class _Tp, bool = is_arithmetic<_Tp>::value> 1246 struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; 1247 1248 template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; 1249 1250 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; 1251 1252 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1253 template <class _Tp> 1254 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v 1255 = is_signed<_Tp>::value; 1256 #endif 1257 1258 // is_unsigned 1259 1260 template <class _Tp, bool = is_integral<_Tp>::value> 1261 struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {}; 1262 1263 template <class _Tp> 1264 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point 1265 1266 template <class _Tp, bool = is_arithmetic<_Tp>::value> 1267 struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; 1268 1269 template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; 1270 1271 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; 1272 1273 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1274 template <class _Tp> 1275 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v 1276 = is_unsigned<_Tp>::value; 1277 #endif 1278 1279 // rank 1280 1281 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank 1282 : public integral_constant<size_t, 0> {}; 1283 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> 1284 : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 1285 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> 1286 : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 1287 1288 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1289 template <class _Tp> 1290 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v 1291 = rank<_Tp>::value; 1292 #endif 1293 1294 // extent 1295 1296 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent 1297 : public integral_constant<size_t, 0> {}; 1298 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> 1299 : public integral_constant<size_t, 0> {}; 1300 template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> 1301 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 1302 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> 1303 : public integral_constant<size_t, _Np> {}; 1304 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> 1305 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 1306 1307 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1308 template <class _Tp, unsigned _Ip = 0> 1309 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v 1310 = extent<_Tp, _Ip>::value; 1311 #endif 1312 1313 // remove_extent 1314 1315 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent 1316 {typedef _Tp type;}; 1317 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> 1318 {typedef _Tp type;}; 1319 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> 1320 {typedef _Tp type;}; 1321 1322 #if _LIBCPP_STD_VER > 11 1323 template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; 1324 #endif 1325 1326 // remove_all_extents 1327 1328 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents 1329 {typedef _Tp type;}; 1330 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> 1331 {typedef typename remove_all_extents<_Tp>::type type;}; 1332 template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> 1333 {typedef typename remove_all_extents<_Tp>::type type;}; 1334 1335 #if _LIBCPP_STD_VER > 11 1336 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; 1337 #endif 1338 1339 // decay 1340 1341 template <class _Up, bool> 1342 struct __decay { 1343 typedef typename remove_cv<_Up>::type type; 1344 }; 1345 1346 template <class _Up> 1347 struct __decay<_Up, true> { 1348 public: 1349 typedef typename conditional 1350 < 1351 is_array<_Up>::value, 1352 typename remove_extent<_Up>::type*, 1353 typename conditional 1354 < 1355 is_function<_Up>::value, 1356 typename add_pointer<_Up>::type, 1357 typename remove_cv<_Up>::type 1358 >::type 1359 >::type type; 1360 }; 1361 1362 template <class _Tp> 1363 struct _LIBCPP_TEMPLATE_VIS decay 1364 { 1365 private: 1366 typedef typename remove_reference<_Tp>::type _Up; 1367 public: 1368 typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type; 1369 }; 1370 1371 #if _LIBCPP_STD_VER > 11 1372 template <class _Tp> using decay_t = typename decay<_Tp>::type; 1373 #endif 1374 1375 // is_abstract 1376 1377 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract 1378 : public integral_constant<bool, __is_abstract(_Tp)> {}; 1379 1380 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1381 template <class _Tp> 1382 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v 1383 = is_abstract<_Tp>::value; 1384 #endif 1385 1386 // is_final 1387 1388 #if defined(_LIBCPP_HAS_IS_FINAL) 1389 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS 1390 __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {}; 1391 #else 1392 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS 1393 __libcpp_is_final : public false_type {}; 1394 #endif 1395 1396 #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11 1397 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS 1398 is_final : public integral_constant<bool, __is_final(_Tp)> {}; 1399 #endif 1400 1401 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1402 template <class _Tp> 1403 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v 1404 = is_final<_Tp>::value; 1405 #endif 1406 1407 // is_aggregate 1408 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) 1409 1410 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS 1411 is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; 1412 1413 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1414 template <class _Tp> 1415 _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v 1416 = is_aggregate<_Tp>::value; 1417 #endif 1418 1419 #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) 1420 1421 // is_base_of 1422 1423 #ifdef _LIBCPP_HAS_IS_BASE_OF 1424 1425 template <class _Bp, class _Dp> 1426 struct _LIBCPP_TEMPLATE_VIS is_base_of 1427 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; 1428 1429 #else // _LIBCPP_HAS_IS_BASE_OF 1430 1431 namespace __is_base_of_imp 1432 { 1433 template <class _Tp> 1434 struct _Dst 1435 { 1436 _Dst(const volatile _Tp &); 1437 }; 1438 template <class _Tp> 1439 struct _Src 1440 { 1441 operator const volatile _Tp &(); 1442 template <class _Up> operator const _Dst<_Up> &(); 1443 }; 1444 template <size_t> struct __one { typedef char type; }; 1445 template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int); 1446 template <class _Bp, class _Dp> __two __test(...); 1447 } 1448 1449 template <class _Bp, class _Dp> 1450 struct _LIBCPP_TEMPLATE_VIS is_base_of 1451 : public integral_constant<bool, is_class<_Bp>::value && 1452 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; 1453 1454 #endif // _LIBCPP_HAS_IS_BASE_OF 1455 1456 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1457 template <class _Bp, class _Dp> 1458 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v 1459 = is_base_of<_Bp, _Dp>::value; 1460 #endif 1461 1462 // is_convertible 1463 1464 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) 1465 1466 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible 1467 : public integral_constant<bool, __is_convertible_to(_T1, _T2) && 1468 !is_abstract<_T2>::value> {}; 1469 1470 #else // __has_feature(is_convertible_to) 1471 1472 namespace __is_convertible_imp 1473 { 1474 template <class _Tp> void __test_convert(_Tp); 1475 1476 template <class _From, class _To, class = void> 1477 struct __is_convertible_test : public false_type {}; 1478 1479 template <class _From, class _To> 1480 struct __is_convertible_test<_From, _To, 1481 decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type 1482 {}; 1483 1484 template <class _Tp, bool _IsArray = is_array<_Tp>::value, 1485 bool _IsFunction = is_function<_Tp>::value, 1486 bool _IsVoid = is_void<_Tp>::value> 1487 struct __is_array_function_or_void {enum {value = 0};}; 1488 template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; 1489 template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; 1490 template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; 1491 } 1492 1493 template <class _Tp, 1494 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> 1495 struct __is_convertible_check 1496 { 1497 static const size_t __v = 0; 1498 }; 1499 1500 template <class _Tp> 1501 struct __is_convertible_check<_Tp, 0> 1502 { 1503 static const size_t __v = sizeof(_Tp); 1504 }; 1505 1506 template <class _T1, class _T2, 1507 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, 1508 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> 1509 struct __is_convertible 1510 : public integral_constant<bool, 1511 __is_convertible_imp::__is_convertible_test<_T1, _T2>::value 1512 #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1513 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value 1514 && (!is_const<typename remove_reference<_T2>::type>::value 1515 || is_volatile<typename remove_reference<_T2>::type>::value) 1516 && (is_same<typename remove_cv<_T1>::type, 1517 typename remove_cv<typename remove_reference<_T2>::type>::type>::value 1518 || is_base_of<typename remove_reference<_T2>::type, _T1>::value)) 1519 #endif 1520 > 1521 {}; 1522 1523 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; 1524 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; 1525 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; 1526 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; 1527 1528 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; 1529 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; 1530 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; 1531 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; 1532 1533 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; 1534 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; 1535 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; 1536 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; 1537 1538 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible 1539 : public __is_convertible<_T1, _T2> 1540 { 1541 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; 1542 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; 1543 }; 1544 1545 #endif // __has_feature(is_convertible_to) 1546 1547 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1548 template <class _From, class _To> 1549 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v 1550 = is_convertible<_From, _To>::value; 1551 #endif 1552 1553 // is_empty 1554 1555 #if __has_feature(is_empty) || (_GNUC_VER >= 407) 1556 1557 template <class _Tp> 1558 struct _LIBCPP_TEMPLATE_VIS is_empty 1559 : public integral_constant<bool, __is_empty(_Tp)> {}; 1560 1561 #else // __has_feature(is_empty) 1562 1563 template <class _Tp> 1564 struct __is_empty1 1565 : public _Tp 1566 { 1567 double __lx; 1568 }; 1569 1570 struct __is_empty2 1571 { 1572 double __lx; 1573 }; 1574 1575 template <class _Tp, bool = is_class<_Tp>::value> 1576 struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; 1577 1578 template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; 1579 1580 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {}; 1581 1582 #endif // __has_feature(is_empty) 1583 1584 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1585 template <class _Tp> 1586 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v 1587 = is_empty<_Tp>::value; 1588 #endif 1589 1590 // is_polymorphic 1591 1592 #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC) 1593 1594 template <class _Tp> 1595 struct _LIBCPP_TEMPLATE_VIS is_polymorphic 1596 : public integral_constant<bool, __is_polymorphic(_Tp)> {}; 1597 1598 #else 1599 1600 template<typename _Tp> char &__is_polymorphic_impl( 1601 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0, 1602 int>::type); 1603 template<typename _Tp> __two &__is_polymorphic_impl(...); 1604 1605 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic 1606 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; 1607 1608 #endif // __has_feature(is_polymorphic) 1609 1610 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1611 template <class _Tp> 1612 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v 1613 = is_polymorphic<_Tp>::value; 1614 #endif 1615 1616 // has_virtual_destructor 1617 1618 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403) 1619 1620 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor 1621 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; 1622 1623 #else 1624 1625 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor 1626 : public false_type {}; 1627 1628 #endif 1629 1630 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1631 template <class _Tp> 1632 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v 1633 = has_virtual_destructor<_Tp>::value; 1634 #endif 1635 1636 // has_unique_object_representations 1637 1638 #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) 1639 1640 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations 1641 : public integral_constant<bool, 1642 __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {}; 1643 1644 #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1645 template <class _Tp> 1646 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v 1647 = has_unique_object_representations<_Tp>::value; 1648 #endif 1649 1650 #endif 1651 1652 // alignment_of 1653 1654 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of 1655 : public integral_constant<size_t, __alignof__(_Tp)> {}; 1656 1657 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 1658 template <class _Tp> 1659 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v 1660 = alignment_of<_Tp>::value; 1661 #endif 1662 1663 // aligned_storage 1664 1665 template <class _Hp, class _Tp> 1666 struct __type_list 1667 { 1668 typedef _Hp _Head; 1669 typedef _Tp _Tail; 1670 }; 1671 1672 struct __nat 1673 { 1674 #ifndef _LIBCPP_CXX03_LANG 1675 __nat() = delete; 1676 __nat(const __nat&) = delete; 1677 __nat& operator=(const __nat&) = delete; 1678 ~__nat() = delete; 1679 #endif 1680 }; 1681 1682 template <class _Tp> 1683 struct __align_type 1684 { 1685 static const size_t value = alignment_of<_Tp>::value; 1686 typedef _Tp type; 1687 }; 1688 1689 struct __struct_double {long double __lx;}; 1690 struct __struct_double4 {double __lx[4];}; 1691 1692 typedef 1693 __type_list<__align_type<unsigned char>, 1694 __type_list<__align_type<unsigned short>, 1695 __type_list<__align_type<unsigned int>, 1696 __type_list<__align_type<unsigned long>, 1697 __type_list<__align_type<unsigned long long>, 1698 __type_list<__align_type<double>, 1699 __type_list<__align_type<long double>, 1700 __type_list<__align_type<__struct_double>, 1701 __type_list<__align_type<__struct_double4>, 1702 __type_list<__align_type<int*>, 1703 __nat 1704 > > > > > > > > > > __all_types; 1705 1706 template <class _TL, size_t _Align> struct __find_pod; 1707 1708 template <class _Hp, size_t _Align> 1709 struct __find_pod<__type_list<_Hp, __nat>, _Align> 1710 { 1711 typedef typename conditional< 1712 _Align == _Hp::value, 1713 typename _Hp::type, 1714 void 1715 >::type type; 1716 }; 1717 1718 template <class _Hp, class _Tp, size_t _Align> 1719 struct __find_pod<__type_list<_Hp, _Tp>, _Align> 1720 { 1721 typedef typename conditional< 1722 _Align == _Hp::value, 1723 typename _Hp::type, 1724 typename __find_pod<_Tp, _Align>::type 1725 >::type type; 1726 }; 1727 1728 template <class _TL, size_t _Len> struct __find_max_align; 1729 1730 template <class _Hp, size_t _Len> 1731 struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; 1732 1733 template <size_t _Len, size_t _A1, size_t _A2> 1734 struct __select_align 1735 { 1736 private: 1737 static const size_t __min = _A2 < _A1 ? _A2 : _A1; 1738 static const size_t __max = _A1 < _A2 ? _A2 : _A1; 1739 public: 1740 static const size_t value = _Len < __max ? __min : __max; 1741 }; 1742 1743 template <class _Hp, class _Tp, size_t _Len> 1744 struct __find_max_align<__type_list<_Hp, _Tp>, _Len> 1745 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; 1746 1747 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1748 struct _LIBCPP_TEMPLATE_VIS aligned_storage 1749 { 1750 typedef typename __find_pod<__all_types, _Align>::type _Aligner; 1751 static_assert(!is_void<_Aligner>::value, ""); 1752 union type 1753 { 1754 _Aligner __align; 1755 unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; 1756 }; 1757 }; 1758 1759 #if _LIBCPP_STD_VER > 11 1760 template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1761 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; 1762 #endif 1763 1764 #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ 1765 template <size_t _Len>\ 1766 struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ 1767 {\ 1768 struct _ALIGNAS(n) type\ 1769 {\ 1770 unsigned char __lx[(_Len + n - 1)/n * n];\ 1771 };\ 1772 } 1773 1774 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); 1775 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); 1776 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); 1777 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); 1778 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); 1779 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); 1780 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); 1781 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); 1782 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); 1783 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); 1784 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); 1785 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); 1786 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); 1787 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); 1788 // PE/COFF does not support alignment beyond 8192 (=0x2000) 1789 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) 1790 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); 1791 #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) 1792 1793 #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION 1794 1795 #ifndef _LIBCPP_HAS_NO_VARIADICS 1796 1797 // aligned_union 1798 1799 template <size_t _I0, size_t ..._In> 1800 struct __static_max; 1801 1802 template <size_t _I0> 1803 struct __static_max<_I0> 1804 { 1805 static const size_t value = _I0; 1806 }; 1807 1808 template <size_t _I0, size_t _I1, size_t ..._In> 1809 struct __static_max<_I0, _I1, _In...> 1810 { 1811 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : 1812 __static_max<_I1, _In...>::value; 1813 }; 1814 1815 template <size_t _Len, class _Type0, class ..._Types> 1816 struct aligned_union 1817 { 1818 static const size_t alignment_value = __static_max<__alignof__(_Type0), 1819 __alignof__(_Types)...>::value; 1820 static const size_t __len = __static_max<_Len, sizeof(_Type0), 1821 sizeof(_Types)...>::value; 1822 typedef typename aligned_storage<__len, alignment_value>::type type; 1823 }; 1824 1825 #if _LIBCPP_STD_VER > 11 1826 template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; 1827 #endif 1828 1829 #endif // _LIBCPP_HAS_NO_VARIADICS 1830 1831 template <class _Tp> 1832 struct __numeric_type 1833 { 1834 static void __test(...); 1835 static float __test(float); 1836 static double __test(char); 1837 static double __test(int); 1838 static double __test(unsigned); 1839 static double __test(long); 1840 static double __test(unsigned long); 1841 static double __test(long long); 1842 static double __test(unsigned long long); 1843 static double __test(double); 1844 static long double __test(long double); 1845 1846 typedef decltype(__test(declval<_Tp>())) type; 1847 static const bool value = !is_same<type, void>::value; 1848 }; 1849 1850 template <> 1851 struct __numeric_type<void> 1852 { 1853 static const bool value = true; 1854 }; 1855 1856 // __promote 1857 1858 template <class _A1, class _A2 = void, class _A3 = void, 1859 bool = __numeric_type<_A1>::value && 1860 __numeric_type<_A2>::value && 1861 __numeric_type<_A3>::value> 1862 class __promote_imp 1863 { 1864 public: 1865 static const bool value = false; 1866 }; 1867 1868 template <class _A1, class _A2, class _A3> 1869 class __promote_imp<_A1, _A2, _A3, true> 1870 { 1871 private: 1872 typedef typename __promote_imp<_A1>::type __type1; 1873 typedef typename __promote_imp<_A2>::type __type2; 1874 typedef typename __promote_imp<_A3>::type __type3; 1875 public: 1876 typedef decltype(__type1() + __type2() + __type3()) type; 1877 static const bool value = true; 1878 }; 1879 1880 template <class _A1, class _A2> 1881 class __promote_imp<_A1, _A2, void, true> 1882 { 1883 private: 1884 typedef typename __promote_imp<_A1>::type __type1; 1885 typedef typename __promote_imp<_A2>::type __type2; 1886 public: 1887 typedef decltype(__type1() + __type2()) type; 1888 static const bool value = true; 1889 }; 1890 1891 template <class _A1> 1892 class __promote_imp<_A1, void, void, true> 1893 { 1894 public: 1895 typedef typename __numeric_type<_A1>::type type; 1896 static const bool value = true; 1897 }; 1898 1899 template <class _A1, class _A2 = void, class _A3 = void> 1900 class __promote : public __promote_imp<_A1, _A2, _A3> {}; 1901 1902 // make_signed / make_unsigned 1903 1904 typedef 1905 __type_list<signed char, 1906 __type_list<signed short, 1907 __type_list<signed int, 1908 __type_list<signed long, 1909 __type_list<signed long long, 1910 #ifndef _LIBCPP_HAS_NO_INT128 1911 __type_list<__int128_t, 1912 #endif 1913 __nat 1914 #ifndef _LIBCPP_HAS_NO_INT128 1915 > 1916 #endif 1917 > > > > > __signed_types; 1918 1919 typedef 1920 __type_list<unsigned char, 1921 __type_list<unsigned short, 1922 __type_list<unsigned int, 1923 __type_list<unsigned long, 1924 __type_list<unsigned long long, 1925 #ifndef _LIBCPP_HAS_NO_INT128 1926 __type_list<__uint128_t, 1927 #endif 1928 __nat 1929 #ifndef _LIBCPP_HAS_NO_INT128 1930 > 1931 #endif 1932 > > > > > __unsigned_types; 1933 1934 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; 1935 1936 template <class _Hp, class _Tp, size_t _Size> 1937 struct __find_first<__type_list<_Hp, _Tp>, _Size, true> 1938 { 1939 typedef _Hp type; 1940 }; 1941 1942 template <class _Hp, class _Tp, size_t _Size> 1943 struct __find_first<__type_list<_Hp, _Tp>, _Size, false> 1944 { 1945 typedef typename __find_first<_Tp, _Size>::type type; 1946 }; 1947 1948 template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, 1949 bool = is_volatile<typename remove_reference<_Tp>::type>::value> 1950 struct __apply_cv 1951 { 1952 typedef _Up type; 1953 }; 1954 1955 template <class _Tp, class _Up> 1956 struct __apply_cv<_Tp, _Up, true, false> 1957 { 1958 typedef const _Up type; 1959 }; 1960 1961 template <class _Tp, class _Up> 1962 struct __apply_cv<_Tp, _Up, false, true> 1963 { 1964 typedef volatile _Up type; 1965 }; 1966 1967 template <class _Tp, class _Up> 1968 struct __apply_cv<_Tp, _Up, true, true> 1969 { 1970 typedef const volatile _Up type; 1971 }; 1972 1973 template <class _Tp, class _Up> 1974 struct __apply_cv<_Tp&, _Up, false, false> 1975 { 1976 typedef _Up& type; 1977 }; 1978 1979 template <class _Tp, class _Up> 1980 struct __apply_cv<_Tp&, _Up, true, false> 1981 { 1982 typedef const _Up& type; 1983 }; 1984 1985 template <class _Tp, class _Up> 1986 struct __apply_cv<_Tp&, _Up, false, true> 1987 { 1988 typedef volatile _Up& type; 1989 }; 1990 1991 template <class _Tp, class _Up> 1992 struct __apply_cv<_Tp&, _Up, true, true> 1993 { 1994 typedef const volatile _Up& type; 1995 }; 1996 1997 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 1998 struct __make_signed {}; 1999 2000 template <class _Tp> 2001 struct __make_signed<_Tp, true> 2002 { 2003 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; 2004 }; 2005 2006 template <> struct __make_signed<bool, true> {}; 2007 template <> struct __make_signed< signed short, true> {typedef short type;}; 2008 template <> struct __make_signed<unsigned short, true> {typedef short type;}; 2009 template <> struct __make_signed< signed int, true> {typedef int type;}; 2010 template <> struct __make_signed<unsigned int, true> {typedef int type;}; 2011 template <> struct __make_signed< signed long, true> {typedef long type;}; 2012 template <> struct __make_signed<unsigned long, true> {typedef long type;}; 2013 template <> struct __make_signed< signed long long, true> {typedef long long type;}; 2014 template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; 2015 #ifndef _LIBCPP_HAS_NO_INT128 2016 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; 2017 template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; 2018 #endif 2019 2020 template <class _Tp> 2021 struct _LIBCPP_TEMPLATE_VIS make_signed 2022 { 2023 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; 2024 }; 2025 2026 #if _LIBCPP_STD_VER > 11 2027 template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; 2028 #endif 2029 2030 template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 2031 struct __make_unsigned {}; 2032 2033 template <class _Tp> 2034 struct __make_unsigned<_Tp, true> 2035 { 2036 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; 2037 }; 2038 2039 template <> struct __make_unsigned<bool, true> {}; 2040 template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; 2041 template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; 2042 template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; 2043 template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; 2044 template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; 2045 template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; 2046 template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; 2047 template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; 2048 #ifndef _LIBCPP_HAS_NO_INT128 2049 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; 2050 template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; 2051 #endif 2052 2053 template <class _Tp> 2054 struct _LIBCPP_TEMPLATE_VIS make_unsigned 2055 { 2056 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; 2057 }; 2058 2059 #if _LIBCPP_STD_VER > 11 2060 template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; 2061 #endif 2062 2063 #ifdef _LIBCPP_HAS_NO_VARIADICS 2064 2065 template <class _Tp, class _Up = void, class _Vp = void> 2066 struct _LIBCPP_TEMPLATE_VIS common_type 2067 { 2068 public: 2069 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type; 2070 }; 2071 2072 template <> 2073 struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void> 2074 { 2075 public: 2076 typedef void type; 2077 }; 2078 2079 template <class _Tp> 2080 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void> 2081 { 2082 public: 2083 typedef typename common_type<_Tp, _Tp>::type type; 2084 }; 2085 2086 template <class _Tp, class _Up> 2087 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, void> 2088 { 2089 typedef typename decay<decltype( 2090 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() 2091 )>::type type; 2092 }; 2093 2094 #else // _LIBCPP_HAS_NO_VARIADICS 2095 2096 // bullet 1 - sizeof...(Tp) == 0 2097 2098 template <class ..._Tp> 2099 struct _LIBCPP_TEMPLATE_VIS common_type {}; 2100 2101 // bullet 2 - sizeof...(Tp) == 1 2102 2103 template <class _Tp> 2104 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> 2105 : public common_type<_Tp, _Tp> {}; 2106 2107 // bullet 3 - sizeof...(Tp) == 2 2108 2109 template <class _Tp, class _Up, class = void> 2110 struct __common_type2_imp {}; 2111 2112 template <class _Tp, class _Up> 2113 struct __common_type2_imp<_Tp, _Up, 2114 typename __void_t<decltype( 2115 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() 2116 )>::type> 2117 { 2118 typedef typename decay<decltype( 2119 true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() 2120 )>::type type; 2121 }; 2122 2123 template <class _Tp, class _Up, 2124 class _DTp = typename decay<_Tp>::type, 2125 class _DUp = typename decay<_Up>::type> 2126 using __common_type2 = 2127 typename conditional< 2128 is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value, 2129 __common_type2_imp<_Tp, _Up>, 2130 common_type<_DTp, _DUp> 2131 >::type; 2132 2133 template <class _Tp, class _Up> 2134 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> 2135 : __common_type2<_Tp, _Up> {}; 2136 2137 // bullet 4 - sizeof...(Tp) > 2 2138 2139 template <class ...Tp> struct __common_types; 2140 2141 template <class, class = void> 2142 struct __common_type_impl {}; 2143 2144 template <class _Tp, class _Up> 2145 struct __common_type_impl< 2146 __common_types<_Tp, _Up>, 2147 typename __void_t<typename common_type<_Tp, _Up>::type>::type> 2148 { 2149 typedef typename common_type<_Tp, _Up>::type type; 2150 }; 2151 2152 template <class _Tp, class _Up, class ..._Vp> 2153 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>, 2154 typename __void_t<typename common_type<_Tp, _Up>::type>::type> 2155 : __common_type_impl< 2156 __common_types<typename common_type<_Tp, _Up>::type, _Vp...> > 2157 { 2158 2159 }; 2160 2161 template <class _Tp, class _Up, class ..._Vp> 2162 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp...> 2163 : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {}; 2164 2165 #if _LIBCPP_STD_VER > 11 2166 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; 2167 #endif 2168 2169 #endif // _LIBCPP_HAS_NO_VARIADICS 2170 2171 // is_assignable 2172 2173 template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; }; 2174 2175 template <class _Tp, class _Arg> 2176 typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type 2177 __is_assignable_test(int); 2178 2179 template <class, class> 2180 false_type __is_assignable_test(...); 2181 2182 2183 template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> 2184 struct __is_assignable_imp 2185 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {}; 2186 2187 template <class _Tp, class _Arg> 2188 struct __is_assignable_imp<_Tp, _Arg, true> 2189 : public false_type 2190 { 2191 }; 2192 2193 template <class _Tp, class _Arg> 2194 struct is_assignable 2195 : public __is_assignable_imp<_Tp, _Arg> {}; 2196 2197 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2198 template <class _Tp, class _Arg> 2199 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v 2200 = is_assignable<_Tp, _Arg>::value; 2201 #endif 2202 2203 // is_copy_assignable 2204 2205 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable 2206 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 2207 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 2208 2209 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2210 template <class _Tp> 2211 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v 2212 = is_copy_assignable<_Tp>::value; 2213 #endif 2214 2215 // is_move_assignable 2216 2217 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable 2218 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2219 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 2220 typename add_rvalue_reference<_Tp>::type> {}; 2221 #else 2222 : public is_copy_assignable<_Tp> {}; 2223 #endif 2224 2225 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2226 template <class _Tp> 2227 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v 2228 = is_move_assignable<_Tp>::value; 2229 #endif 2230 2231 // is_destructible 2232 2233 // if it's a reference, return true 2234 // if it's a function, return false 2235 // if it's void, return false 2236 // if it's an array of unknown bound, return false 2237 // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed 2238 // where _Up is remove_all_extents<_Tp>::type 2239 2240 template <class> 2241 struct __is_destructible_apply { typedef int type; }; 2242 2243 template <typename _Tp> 2244 struct __is_destructor_wellformed { 2245 template <typename _Tp1> 2246 static char __test ( 2247 typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type 2248 ); 2249 2250 template <typename _Tp1> 2251 static __two __test (...); 2252 2253 static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char); 2254 }; 2255 2256 template <class _Tp, bool> 2257 struct __destructible_imp; 2258 2259 template <class _Tp> 2260 struct __destructible_imp<_Tp, false> 2261 : public _VSTD::integral_constant<bool, 2262 __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {}; 2263 2264 template <class _Tp> 2265 struct __destructible_imp<_Tp, true> 2266 : public _VSTD::true_type {}; 2267 2268 template <class _Tp, bool> 2269 struct __destructible_false; 2270 2271 template <class _Tp> 2272 struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {}; 2273 2274 template <class _Tp> 2275 struct __destructible_false<_Tp, true> : public _VSTD::false_type {}; 2276 2277 template <class _Tp> 2278 struct is_destructible 2279 : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {}; 2280 2281 template <class _Tp> 2282 struct is_destructible<_Tp[]> 2283 : public _VSTD::false_type {}; 2284 2285 template <> 2286 struct is_destructible<void> 2287 : public _VSTD::false_type {}; 2288 2289 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 2290 template <class _Tp> 2291 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v 2292 = is_destructible<_Tp>::value; 2293 #endif 2294 2295 // move 2296 2297 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2298 2299 template <class _Tp> 2300 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 2301 typename remove_reference<_Tp>::type&& 2302 move(_Tp&& __t) _NOEXCEPT 2303 { 2304 typedef typename remove_reference<_Tp>::type _Up; 2305 return static_cast<_Up&&>(__t); 2306 } 2307 2308 template <class _Tp> 2309 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 2310 _Tp&& 2311 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT 2312 { 2313 return static_cast<_Tp&&>(__t); 2314 } 2315 2316 template <class _Tp> 2317 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 2318 _Tp&& 2319 forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT 2320 { 2321 static_assert(!is_lvalue_reference<_Tp>::value, 2322 "can not forward an rvalue as an lvalue"); 2323 return static_cast<_Tp&&>(__t); 2324 } 2325 2326 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2327 2328 template <class _Tp> 2329 inline _LIBCPP_INLINE_VISIBILITY 2330 _Tp& 2331 move(_Tp& __t) 2332 { 2333 return __t; 2334 } 2335 2336 template <class _Tp> 2337 inline _LIBCPP_INLINE_VISIBILITY 2338 const _Tp& 2339 move(const _Tp& __t) 2340 { 2341 return __t; 2342 } 2343 2344 template <class _Tp> 2345 inline _LIBCPP_INLINE_VISIBILITY 2346 _Tp& 2347 forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT 2348 { 2349 return __t; 2350 } 2351 2352 2353 template <class _Tp> 2354 class __rv 2355 { 2356 typedef typename remove_reference<_Tp>::type _Trr; 2357 _Trr& t_; 2358 public: 2359 _LIBCPP_INLINE_VISIBILITY 2360 _Trr* operator->() {return &t_;} 2361 _LIBCPP_INLINE_VISIBILITY 2362 explicit __rv(_Trr& __t) : t_(__t) {} 2363 }; 2364 2365 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2366 2367 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2368 2369 template <class _Tp> 2370 inline _LIBCPP_INLINE_VISIBILITY 2371 typename decay<_Tp>::type 2372 __decay_copy(_Tp&& __t) 2373 { 2374 return _VSTD::forward<_Tp>(__t); 2375 } 2376 2377 #else 2378 2379 template <class _Tp> 2380 inline _LIBCPP_INLINE_VISIBILITY 2381 typename decay<_Tp>::type 2382 __decay_copy(const _Tp& __t) 2383 { 2384 return _VSTD::forward<_Tp>(__t); 2385 } 2386 2387 #endif 2388 2389 #ifndef _LIBCPP_HAS_NO_VARIADICS 2390 2391 template <class _Rp, class _Class, class ..._Param> 2392 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> 2393 { 2394 typedef _Class _ClassType; 2395 typedef _Rp _ReturnType; 2396 typedef _Rp (_FnType) (_Param...); 2397 }; 2398 2399 template <class _Rp, class _Class, class ..._Param> 2400 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> 2401 { 2402 typedef _Class _ClassType; 2403 typedef _Rp _ReturnType; 2404 typedef _Rp (_FnType) (_Param..., ...); 2405 }; 2406 2407 template <class _Rp, class _Class, class ..._Param> 2408 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> 2409 { 2410 typedef _Class const _ClassType; 2411 typedef _Rp _ReturnType; 2412 typedef _Rp (_FnType) (_Param...); 2413 }; 2414 2415 template <class _Rp, class _Class, class ..._Param> 2416 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> 2417 { 2418 typedef _Class const _ClassType; 2419 typedef _Rp _ReturnType; 2420 typedef _Rp (_FnType) (_Param..., ...); 2421 }; 2422 2423 template <class _Rp, class _Class, class ..._Param> 2424 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> 2425 { 2426 typedef _Class volatile _ClassType; 2427 typedef _Rp _ReturnType; 2428 typedef _Rp (_FnType) (_Param...); 2429 }; 2430 2431 template <class _Rp, class _Class, class ..._Param> 2432 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> 2433 { 2434 typedef _Class volatile _ClassType; 2435 typedef _Rp _ReturnType; 2436 typedef _Rp (_FnType) (_Param..., ...); 2437 }; 2438 2439 template <class _Rp, class _Class, class ..._Param> 2440 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> 2441 { 2442 typedef _Class const volatile _ClassType; 2443 typedef _Rp _ReturnType; 2444 typedef _Rp (_FnType) (_Param...); 2445 }; 2446 2447 template <class _Rp, class _Class, class ..._Param> 2448 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> 2449 { 2450 typedef _Class const volatile _ClassType; 2451 typedef _Rp _ReturnType; 2452 typedef _Rp (_FnType) (_Param..., ...); 2453 }; 2454 2455 #if __has_feature(cxx_reference_qualified_functions) || \ 2456 (defined(_GNUC_VER) && _GNUC_VER >= 409) 2457 2458 template <class _Rp, class _Class, class ..._Param> 2459 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> 2460 { 2461 typedef _Class& _ClassType; 2462 typedef _Rp _ReturnType; 2463 typedef _Rp (_FnType) (_Param...); 2464 }; 2465 2466 template <class _Rp, class _Class, class ..._Param> 2467 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false> 2468 { 2469 typedef _Class& _ClassType; 2470 typedef _Rp _ReturnType; 2471 typedef _Rp (_FnType) (_Param..., ...); 2472 }; 2473 2474 template <class _Rp, class _Class, class ..._Param> 2475 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> 2476 { 2477 typedef _Class const& _ClassType; 2478 typedef _Rp _ReturnType; 2479 typedef _Rp (_FnType) (_Param...); 2480 }; 2481 2482 template <class _Rp, class _Class, class ..._Param> 2483 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> 2484 { 2485 typedef _Class const& _ClassType; 2486 typedef _Rp _ReturnType; 2487 typedef _Rp (_FnType) (_Param..., ...); 2488 }; 2489 2490 template <class _Rp, class _Class, class ..._Param> 2491 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> 2492 { 2493 typedef _Class volatile& _ClassType; 2494 typedef _Rp _ReturnType; 2495 typedef _Rp (_FnType) (_Param...); 2496 }; 2497 2498 template <class _Rp, class _Class, class ..._Param> 2499 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> 2500 { 2501 typedef _Class volatile& _ClassType; 2502 typedef _Rp _ReturnType; 2503 typedef _Rp (_FnType) (_Param..., ...); 2504 }; 2505 2506 template <class _Rp, class _Class, class ..._Param> 2507 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> 2508 { 2509 typedef _Class const volatile& _ClassType; 2510 typedef _Rp _ReturnType; 2511 typedef _Rp (_FnType) (_Param...); 2512 }; 2513 2514 template <class _Rp, class _Class, class ..._Param> 2515 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> 2516 { 2517 typedef _Class const volatile& _ClassType; 2518 typedef _Rp _ReturnType; 2519 typedef _Rp (_FnType) (_Param..., ...); 2520 }; 2521 2522 template <class _Rp, class _Class, class ..._Param> 2523 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> 2524 { 2525 typedef _Class&& _ClassType; 2526 typedef _Rp _ReturnType; 2527 typedef _Rp (_FnType) (_Param...); 2528 }; 2529 2530 template <class _Rp, class _Class, class ..._Param> 2531 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false> 2532 { 2533 typedef _Class&& _ClassType; 2534 typedef _Rp _ReturnType; 2535 typedef _Rp (_FnType) (_Param..., ...); 2536 }; 2537 2538 template <class _Rp, class _Class, class ..._Param> 2539 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> 2540 { 2541 typedef _Class const&& _ClassType; 2542 typedef _Rp _ReturnType; 2543 typedef _Rp (_FnType) (_Param...); 2544 }; 2545 2546 template <class _Rp, class _Class, class ..._Param> 2547 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> 2548 { 2549 typedef _Class const&& _ClassType; 2550 typedef _Rp _ReturnType; 2551 typedef _Rp (_FnType) (_Param..., ...); 2552 }; 2553 2554 template <class _Rp, class _Class, class ..._Param> 2555 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> 2556 { 2557 typedef _Class volatile&& _ClassType; 2558 typedef _Rp _ReturnType; 2559 typedef _Rp (_FnType) (_Param...); 2560 }; 2561 2562 template <class _Rp, class _Class, class ..._Param> 2563 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> 2564 { 2565 typedef _Class volatile&& _ClassType; 2566 typedef _Rp _ReturnType; 2567 typedef _Rp (_FnType) (_Param..., ...); 2568 }; 2569 2570 template <class _Rp, class _Class, class ..._Param> 2571 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> 2572 { 2573 typedef _Class const volatile&& _ClassType; 2574 typedef _Rp _ReturnType; 2575 typedef _Rp (_FnType) (_Param...); 2576 }; 2577 2578 template <class _Rp, class _Class, class ..._Param> 2579 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> 2580 { 2581 typedef _Class const volatile&& _ClassType; 2582 typedef _Rp _ReturnType; 2583 typedef _Rp (_FnType) (_Param..., ...); 2584 }; 2585 2586 #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409 2587 2588 #else // _LIBCPP_HAS_NO_VARIADICS 2589 2590 template <class _Rp, class _Class> 2591 struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> 2592 { 2593 typedef _Class _ClassType; 2594 typedef _Rp _ReturnType; 2595 typedef _Rp (_FnType) (); 2596 }; 2597 2598 template <class _Rp, class _Class> 2599 struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false> 2600 { 2601 typedef _Class _ClassType; 2602 typedef _Rp _ReturnType; 2603 typedef _Rp (_FnType) (...); 2604 }; 2605 2606 template <class _Rp, class _Class, class _P0> 2607 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> 2608 { 2609 typedef _Class _ClassType; 2610 typedef _Rp _ReturnType; 2611 typedef _Rp (_FnType) (_P0); 2612 }; 2613 2614 template <class _Rp, class _Class, class _P0> 2615 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false> 2616 { 2617 typedef _Class _ClassType; 2618 typedef _Rp _ReturnType; 2619 typedef _Rp (_FnType) (_P0, ...); 2620 }; 2621 2622 template <class _Rp, class _Class, class _P0, class _P1> 2623 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> 2624 { 2625 typedef _Class _ClassType; 2626 typedef _Rp _ReturnType; 2627 typedef _Rp (_FnType) (_P0, _P1); 2628 }; 2629 2630 template <class _Rp, class _Class, class _P0, class _P1> 2631 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false> 2632 { 2633 typedef _Class _ClassType; 2634 typedef _Rp _ReturnType; 2635 typedef _Rp (_FnType) (_P0, _P1, ...); 2636 }; 2637 2638 template <class _Rp, class _Class, class _P0, class _P1, class _P2> 2639 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> 2640 { 2641 typedef _Class _ClassType; 2642 typedef _Rp _ReturnType; 2643 typedef _Rp (_FnType) (_P0, _P1, _P2); 2644 }; 2645 2646 template <class _Rp, class _Class, class _P0, class _P1, class _P2> 2647 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false> 2648 { 2649 typedef _Class _ClassType; 2650 typedef _Rp _ReturnType; 2651 typedef _Rp (_FnType) (_P0, _P1, _P2, ...); 2652 }; 2653 2654 template <class _Rp, class _Class> 2655 struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> 2656 { 2657 typedef _Class const _ClassType; 2658 typedef _Rp _ReturnType; 2659 typedef _Rp (_FnType) (); 2660 }; 2661 2662 template <class _Rp, class _Class> 2663 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false> 2664 { 2665 typedef _Class const _ClassType; 2666 typedef _Rp _ReturnType; 2667 typedef _Rp (_FnType) (...); 2668 }; 2669 2670 template <class _Rp, class _Class, class _P0> 2671 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> 2672 { 2673 typedef _Class const _ClassType; 2674 typedef _Rp _ReturnType; 2675 typedef _Rp (_FnType) (_P0); 2676 }; 2677 2678 template <class _Rp, class _Class, class _P0> 2679 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false> 2680 { 2681 typedef _Class const _ClassType; 2682 typedef _Rp _ReturnType; 2683 typedef _Rp (_FnType) (_P0, ...); 2684 }; 2685 2686 template <class _Rp, class _Class, class _P0, class _P1> 2687 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> 2688 { 2689 typedef _Class const _ClassType; 2690 typedef _Rp _ReturnType; 2691 typedef _Rp (_FnType) (_P0, _P1); 2692 }; 2693 2694 template <class _Rp, class _Class, class _P0, class _P1> 2695 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false> 2696 { 2697 typedef _Class const _ClassType; 2698 typedef _Rp _ReturnType; 2699 typedef _Rp (_FnType) (_P0, _P1, ...); 2700 }; 2701 2702 template <class _Rp, class _Class, class _P0, class _P1, class _P2> 2703 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false> 2704 { 2705 typedef _Class const _ClassType; 2706 typedef _Rp _ReturnType; 2707 typedef _Rp (_FnType) (_P0, _P1, _P2); 2708 }; 2709 2710 template <class _Rp, class _Class, class _P0, class _P1, class _P2> 2711 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false> 2712 { 2713 typedef _Class const _ClassType; 2714 typedef _Rp _ReturnType; 2715 typedef _Rp (_FnType) (_P0, _P1, _P2, ...); 2716 }; 2717 2718 template <class _Rp, class _Class> 2719 struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> 2720 { 2721 typedef _Class volatile _ClassType; 2722 typedef _Rp _ReturnType; 2723 typedef _Rp (_FnType) (); 2724 }; 2725 2726 template <class _Rp, class _Class> 2727 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false> 2728 { 2729 typedef _Class volatile _ClassType; 2730 typedef _Rp _ReturnType; 2731 typedef _Rp (_FnType) (...); 2732 }; 2733 2734 template <class _Rp, class _Class, class _P0> 2735 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> 2736 { 2737 typedef _Class volatile _ClassType; 2738 typedef _Rp _ReturnType; 2739 typedef _Rp (_FnType) (_P0); 2740 }; 2741 2742 template <class _Rp, class _Class, class _P0> 2743 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false> 2744 { 2745 typedef _Class volatile _ClassType; 2746 typedef _Rp _ReturnType; 2747 typedef _Rp (_FnType) (_P0, ...); 2748 }; 2749 2750 template <class _Rp, class _Class, class _P0, class _P1> 2751 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false> 2752 { 2753 typedef _Class volatile _ClassType; 2754 typedef _Rp _ReturnType; 2755 typedef _Rp (_FnType) (_P0, _P1); 2756 }; 2757 2758 template <class _Rp, class _Class, class _P0, class _P1> 2759 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false> 2760 { 2761 typedef _Class volatile _ClassType; 2762 typedef _Rp _ReturnType; 2763 typedef _Rp (_FnType) (_P0, _P1, ...); 2764 }; 2765 2766 template <class _Rp, class _Class, class _P0, class _P1, class _P2> 2767 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false> 2768 { 2769 typedef _Class volatile _ClassType; 2770 typedef _Rp _ReturnType; 2771 typedef _Rp (_FnType) (_P0, _P1, _P2); 2772 }; 2773 2774 template <class _Rp, class _Class, class _P0, class _P1, class _P2> 2775 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false> 2776 { 2777 typedef _Class volatile _ClassType; 2778 typedef _Rp _ReturnType; 2779 typedef _Rp (_FnType) (_P0, _P1, _P2, ...); 2780 }; 2781 2782 template <class _Rp, class _Class> 2783 struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false> 2784 { 2785 typedef _Class const volatile _ClassType; 2786 typedef _Rp _ReturnType; 2787 typedef _Rp (_FnType) (); 2788 }; 2789 2790 template <class _Rp, class _Class> 2791 struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false> 2792 { 2793 typedef _Class const volatile _ClassType; 2794 typedef _Rp _ReturnType; 2795 typedef _Rp (_FnType) (...); 2796 }; 2797 2798 template <class _Rp, class _Class, class _P0> 2799 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false> 2800 { 2801 typedef _Class const volatile _ClassType; 2802 typedef _Rp _ReturnType; 2803 typedef _Rp (_FnType) (_P0); 2804 }; 2805 2806 template <class _Rp, class _Class, class _P0> 2807 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false> 2808 { 2809 typedef _Class const volatile _ClassType; 2810 typedef _Rp _ReturnType; 2811 typedef _Rp (_FnType) (_P0, ...); 2812 }; 2813 2814 template <class _Rp, class _Class, class _P0, class _P1> 2815 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false> 2816 { 2817 typedef _Class const volatile _ClassType; 2818 typedef _Rp _ReturnType; 2819 typedef _Rp (_FnType) (_P0, _P1); 2820 }; 2821 2822 template <class _Rp, class _Class, class _P0, class _P1> 2823 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false> 2824 { 2825 typedef _Class const volatile _ClassType; 2826 typedef _Rp _ReturnType; 2827 typedef _Rp (_FnType) (_P0, _P1, ...); 2828 }; 2829 2830 template <class _Rp, class _Class, class _P0, class _P1, class _P2> 2831 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false> 2832 { 2833 typedef _Class const volatile _ClassType; 2834 typedef _Rp _ReturnType; 2835 typedef _Rp (_FnType) (_P0, _P1, _P2); 2836 }; 2837 2838 template <class _Rp, class _Class, class _P0, class _P1, class _P2> 2839 struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false> 2840 { 2841 typedef _Class const volatile _ClassType; 2842 typedef _Rp _ReturnType; 2843 typedef _Rp (_FnType) (_P0, _P1, _P2, ...); 2844 }; 2845 2846 #endif // _LIBCPP_HAS_NO_VARIADICS 2847 2848 template <class _Rp, class _Class> 2849 struct __member_pointer_traits_imp<_Rp _Class::*, false, true> 2850 { 2851 typedef _Class _ClassType; 2852 typedef _Rp _ReturnType; 2853 }; 2854 2855 template <class _MP> 2856 struct __member_pointer_traits 2857 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type, 2858 is_member_function_pointer<_MP>::value, 2859 is_member_object_pointer<_MP>::value> 2860 { 2861 // typedef ... _ClassType; 2862 // typedef ... _ReturnType; 2863 // typedef ... _FnType; 2864 }; 2865 2866 2867 template <class _DecayedFp> 2868 struct __member_pointer_class_type {}; 2869 2870 template <class _Ret, class _ClassType> 2871 struct __member_pointer_class_type<_Ret _ClassType::*> { 2872 typedef _ClassType type; 2873 }; 2874 2875 // result_of 2876 2877 template <class _Callable> class result_of; 2878 2879 #ifdef _LIBCPP_HAS_NO_VARIADICS 2880 2881 template <class _Fn, bool, bool> 2882 class __result_of 2883 { 2884 }; 2885 2886 template <class _Fn> 2887 class __result_of<_Fn(), true, false> 2888 { 2889 public: 2890 typedef decltype(declval<_Fn>()()) type; 2891 }; 2892 2893 template <class _Fn, class _A0> 2894 class __result_of<_Fn(_A0), true, false> 2895 { 2896 public: 2897 typedef decltype(declval<_Fn>()(declval<_A0>())) type; 2898 }; 2899 2900 template <class _Fn, class _A0, class _A1> 2901 class __result_of<_Fn(_A0, _A1), true, false> 2902 { 2903 public: 2904 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; 2905 }; 2906 2907 template <class _Fn, class _A0, class _A1, class _A2> 2908 class __result_of<_Fn(_A0, _A1, _A2), true, false> 2909 { 2910 public: 2911 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; 2912 }; 2913 2914 template <class _MP, class _Tp, bool _IsMemberFunctionPtr> 2915 struct __result_of_mp; 2916 2917 // member function pointer 2918 2919 template <class _MP, class _Tp> 2920 struct __result_of_mp<_MP, _Tp, true> 2921 : public __identity<typename __member_pointer_traits<_MP>::_ReturnType> 2922 { 2923 }; 2924 2925 // member data pointer 2926 2927 template <class _MP, class _Tp, bool> 2928 struct __result_of_mdp; 2929 2930 template <class _Rp, class _Class, class _Tp> 2931 struct __result_of_mdp<_Rp _Class::*, _Tp, false> 2932 { 2933 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type; 2934 }; 2935 2936 template <class _Rp, class _Class, class _Tp> 2937 struct __result_of_mdp<_Rp _Class::*, _Tp, true> 2938 { 2939 typedef typename __apply_cv<_Tp, _Rp>::type& type; 2940 }; 2941 2942 template <class _Rp, class _Class, class _Tp> 2943 struct __result_of_mp<_Rp _Class::*, _Tp, false> 2944 : public __result_of_mdp<_Rp _Class::*, _Tp, 2945 is_base_of<_Class, typename remove_reference<_Tp>::type>::value> 2946 { 2947 }; 2948 2949 2950 2951 template <class _Fn, class _Tp> 2952 class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer 2953 : public __result_of_mp<typename remove_reference<_Fn>::type, 2954 _Tp, 2955 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 2956 { 2957 }; 2958 2959 template <class _Fn, class _Tp, class _A0> 2960 class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer 2961 : public __result_of_mp<typename remove_reference<_Fn>::type, 2962 _Tp, 2963 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 2964 { 2965 }; 2966 2967 template <class _Fn, class _Tp, class _A0, class _A1> 2968 class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer 2969 : public __result_of_mp<typename remove_reference<_Fn>::type, 2970 _Tp, 2971 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 2972 { 2973 }; 2974 2975 template <class _Fn, class _Tp, class _A0, class _A1, class _A2> 2976 class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer 2977 : public __result_of_mp<typename remove_reference<_Fn>::type, 2978 _Tp, 2979 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 2980 { 2981 }; 2982 2983 // result_of 2984 2985 template <class _Fn> 2986 class _LIBCPP_TEMPLATE_VIS result_of<_Fn()> 2987 : public __result_of<_Fn(), 2988 is_class<typename remove_reference<_Fn>::type>::value || 2989 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, 2990 is_member_pointer<typename remove_reference<_Fn>::type>::value 2991 > 2992 { 2993 }; 2994 2995 template <class _Fn, class _A0> 2996 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0)> 2997 : public __result_of<_Fn(_A0), 2998 is_class<typename remove_reference<_Fn>::type>::value || 2999 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, 3000 is_member_pointer<typename remove_reference<_Fn>::type>::value 3001 > 3002 { 3003 }; 3004 3005 template <class _Fn, class _A0, class _A1> 3006 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1)> 3007 : public __result_of<_Fn(_A0, _A1), 3008 is_class<typename remove_reference<_Fn>::type>::value || 3009 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, 3010 is_member_pointer<typename remove_reference<_Fn>::type>::value 3011 > 3012 { 3013 }; 3014 3015 template <class _Fn, class _A0, class _A1, class _A2> 3016 class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_A0, _A1, _A2)> 3017 : public __result_of<_Fn(_A0, _A1, _A2), 3018 is_class<typename remove_reference<_Fn>::type>::value || 3019 is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, 3020 is_member_pointer<typename remove_reference<_Fn>::type>::value 3021 > 3022 { 3023 }; 3024 3025 #endif // _LIBCPP_HAS_NO_VARIADICS 3026 3027 // template <class T, class... Args> struct is_constructible; 3028 3029 namespace __is_construct 3030 { 3031 struct __nat {}; 3032 } 3033 3034 #if !defined(_LIBCPP_CXX03_LANG) && (!__has_feature(is_constructible) || \ 3035 defined(_LIBCPP_TESTING_FALLBACK_IS_CONSTRUCTIBLE)) 3036 3037 template <class _Tp, class... _Args> 3038 struct __libcpp_is_constructible; 3039 3040 template <class _To, class _From> 3041 struct __is_invalid_base_to_derived_cast { 3042 static_assert(is_reference<_To>::value, "Wrong specialization"); 3043 using _RawFrom = __uncvref_t<_From>; 3044 using _RawTo = __uncvref_t<_To>; 3045 static const bool value = __lazy_and< 3046 __lazy_not<is_same<_RawFrom, _RawTo>>, 3047 is_base_of<_RawFrom, _RawTo>, 3048 __lazy_not<__libcpp_is_constructible<_RawTo, _From>> 3049 >::value; 3050 }; 3051 3052 template <class _To, class _From> 3053 struct __is_invalid_lvalue_to_rvalue_cast : false_type { 3054 static_assert(is_reference<_To>::value, "Wrong specialization"); 3055 }; 3056 3057 template <class _ToRef, class _FromRef> 3058 struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> { 3059 using _RawFrom = __uncvref_t<_FromRef>; 3060 using _RawTo = __uncvref_t<_ToRef>; 3061 static const bool value = __lazy_and< 3062 __lazy_not<is_function<_RawTo>>, 3063 __lazy_or< 3064 is_same<_RawFrom, _RawTo>, 3065 is_base_of<_RawTo, _RawFrom>> 3066 >::value; 3067 }; 3068 3069 struct __is_constructible_helper 3070 { 3071 template <class _To> 3072 static void __eat(_To); 3073 3074 // This overload is needed to work around a Clang bug that disallows 3075 // static_cast<T&&>(e) for non-reference-compatible types. 3076 // Example: static_cast<int&&>(declval<double>()); 3077 // NOTE: The static_cast implementation below is required to support 3078 // classes with explicit conversion operators. 3079 template <class _To, class _From, 3080 class = decltype(__eat<_To>(_VSTD::declval<_From>()))> 3081 static true_type __test_cast(int); 3082 3083 template <class _To, class _From, 3084 class = decltype(static_cast<_To>(_VSTD::declval<_From>()))> 3085 static integral_constant<bool, 3086 !__is_invalid_base_to_derived_cast<_To, _From>::value && 3087 !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value 3088 > __test_cast(long); 3089 3090 template <class, class> 3091 static false_type __test_cast(...); 3092 3093 template <class _Tp, class ..._Args, 3094 class = decltype(_Tp(_VSTD::declval<_Args>()...))> 3095 static true_type __test_nary(int); 3096 template <class _Tp, class...> 3097 static false_type __test_nary(...); 3098 3099 template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))> 3100 static is_destructible<_Tp> __test_unary(int); 3101 template <class, class> 3102 static false_type __test_unary(...); 3103 }; 3104 3105 template <class _Tp, bool = is_void<_Tp>::value> 3106 struct __is_default_constructible 3107 : decltype(__is_constructible_helper::__test_nary<_Tp>(0)) 3108 {}; 3109 3110 template <class _Tp> 3111 struct __is_default_constructible<_Tp, true> : false_type {}; 3112 3113 template <class _Tp> 3114 struct __is_default_constructible<_Tp[], false> : false_type {}; 3115 3116 template <class _Tp, size_t _Nx> 3117 struct __is_default_constructible<_Tp[_Nx], false> 3118 : __is_default_constructible<typename remove_all_extents<_Tp>::type> {}; 3119 3120 template <class _Tp, class... _Args> 3121 struct __libcpp_is_constructible 3122 { 3123 static_assert(sizeof...(_Args) > 1, "Wrong specialization"); 3124 typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0)) 3125 type; 3126 }; 3127 3128 template <class _Tp> 3129 struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {}; 3130 3131 template <class _Tp, class _A0> 3132 struct __libcpp_is_constructible<_Tp, _A0> 3133 : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0)) 3134 {}; 3135 3136 template <class _Tp, class _A0> 3137 struct __libcpp_is_constructible<_Tp&, _A0> 3138 : public decltype(__is_constructible_helper:: 3139 __test_cast<_Tp&, _A0>(0)) 3140 {}; 3141 3142 template <class _Tp, class _A0> 3143 struct __libcpp_is_constructible<_Tp&&, _A0> 3144 : public decltype(__is_constructible_helper:: 3145 __test_cast<_Tp&&, _A0>(0)) 3146 {}; 3147 3148 #endif 3149 3150 #if __has_feature(is_constructible) 3151 template <class _Tp, class ..._Args> 3152 struct _LIBCPP_TEMPLATE_VIS is_constructible 3153 : public integral_constant<bool, __is_constructible(_Tp, _Args...)> 3154 {}; 3155 #elif !defined(_LIBCPP_CXX03_LANG) 3156 template <class _Tp, class... _Args> 3157 struct _LIBCPP_TEMPLATE_VIS is_constructible 3158 : public __libcpp_is_constructible<_Tp, _Args...>::type {}; 3159 #else 3160 // template <class T> struct is_constructible0; 3161 3162 // main is_constructible0 test 3163 3164 template <class _Tp> 3165 decltype((_Tp(), true_type())) 3166 __is_constructible0_test(_Tp&); 3167 3168 false_type 3169 __is_constructible0_test(__any); 3170 3171 template <class _Tp, class _A0> 3172 decltype((_Tp(_VSTD::declval<_A0>()), true_type())) 3173 __is_constructible1_test(_Tp&, _A0&); 3174 3175 template <class _A0> 3176 false_type 3177 __is_constructible1_test(__any, _A0&); 3178 3179 template <class _Tp, class _A0, class _A1> 3180 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) 3181 __is_constructible2_test(_Tp&, _A0&, _A1&); 3182 3183 template <class _A0, class _A1> 3184 false_type 3185 __is_constructible2_test(__any, _A0&, _A1&); 3186 3187 template <class _Tp, class _A0, class _A1, class _A2> 3188 decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>(), _VSTD::declval<_A2>()), true_type())) 3189 __is_constructible3_test(_Tp&, _A0&, _A1&, _A2&); 3190 3191 template <class _A0, class _A1, class _A2> 3192 false_type 3193 __is_constructible3_test(__any, _A0&, _A1&, _A2&); 3194 3195 template <bool, class _Tp> 3196 struct __is_constructible0_imp // false, _Tp is not a scalar 3197 : public common_type 3198 < 3199 decltype(__is_constructible0_test(declval<_Tp&>())) 3200 >::type 3201 {}; 3202 3203 template <bool, class _Tp, class _A0> 3204 struct __is_constructible1_imp // false, _Tp is not a scalar 3205 : public common_type 3206 < 3207 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) 3208 >::type 3209 {}; 3210 3211 template <bool, class _Tp, class _A0, class _A1> 3212 struct __is_constructible2_imp // false, _Tp is not a scalar 3213 : public common_type 3214 < 3215 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) 3216 >::type 3217 {}; 3218 3219 template <bool, class _Tp, class _A0, class _A1, class _A2> 3220 struct __is_constructible3_imp // false, _Tp is not a scalar 3221 : public common_type 3222 < 3223 decltype(__is_constructible3_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>(), declval<_A2>())) 3224 >::type 3225 {}; 3226 3227 // handle scalars and reference types 3228 3229 // Scalars are default constructible, references are not 3230 3231 template <class _Tp> 3232 struct __is_constructible0_imp<true, _Tp> 3233 : public is_scalar<_Tp> 3234 {}; 3235 3236 template <class _Tp, class _A0> 3237 struct __is_constructible1_imp<true, _Tp, _A0> 3238 : public is_convertible<_A0, _Tp> 3239 {}; 3240 3241 template <class _Tp, class _A0, class _A1> 3242 struct __is_constructible2_imp<true, _Tp, _A0, _A1> 3243 : public false_type 3244 {}; 3245 3246 template <class _Tp, class _A0, class _A1, class _A2> 3247 struct __is_constructible3_imp<true, _Tp, _A0, _A1, _A2> 3248 : public false_type 3249 {}; 3250 3251 // Treat scalars and reference types separately 3252 3253 template <bool, class _Tp> 3254 struct __is_constructible0_void_check 3255 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 3256 _Tp> 3257 {}; 3258 3259 template <bool, class _Tp, class _A0> 3260 struct __is_constructible1_void_check 3261 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 3262 _Tp, _A0> 3263 {}; 3264 3265 template <bool, class _Tp, class _A0, class _A1> 3266 struct __is_constructible2_void_check 3267 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 3268 _Tp, _A0, _A1> 3269 {}; 3270 3271 template <bool, class _Tp, class _A0, class _A1, class _A2> 3272 struct __is_constructible3_void_check 3273 : public __is_constructible3_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 3274 _Tp, _A0, _A1, _A2> 3275 {}; 3276 3277 // If any of T or Args is void, is_constructible should be false 3278 3279 template <class _Tp> 3280 struct __is_constructible0_void_check<true, _Tp> 3281 : public false_type 3282 {}; 3283 3284 template <class _Tp, class _A0> 3285 struct __is_constructible1_void_check<true, _Tp, _A0> 3286 : public false_type 3287 {}; 3288 3289 template <class _Tp, class _A0, class _A1> 3290 struct __is_constructible2_void_check<true, _Tp, _A0, _A1> 3291 : public false_type 3292 {}; 3293 3294 template <class _Tp, class _A0, class _A1, class _A2> 3295 struct __is_constructible3_void_check<true, _Tp, _A0, _A1, _A2> 3296 : public false_type 3297 {}; 3298 3299 // is_constructible entry point 3300 3301 template <class _Tp, class _A0 = __is_construct::__nat, 3302 class _A1 = __is_construct::__nat, 3303 class _A2 = __is_construct::__nat> 3304 struct _LIBCPP_TEMPLATE_VIS is_constructible 3305 : public __is_constructible3_void_check<is_void<_Tp>::value 3306 || is_abstract<_Tp>::value 3307 || is_function<_Tp>::value 3308 || is_void<_A0>::value 3309 || is_void<_A1>::value 3310 || is_void<_A2>::value, 3311 _Tp, _A0, _A1, _A2> 3312 {}; 3313 3314 template <class _Tp> 3315 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> 3316 : public __is_constructible0_void_check<is_void<_Tp>::value 3317 || is_abstract<_Tp>::value 3318 || is_function<_Tp>::value, 3319 _Tp> 3320 {}; 3321 3322 template <class _Tp, class _A0> 3323 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, __is_construct::__nat> 3324 : public __is_constructible1_void_check<is_void<_Tp>::value 3325 || is_abstract<_Tp>::value 3326 || is_function<_Tp>::value 3327 || is_void<_A0>::value, 3328 _Tp, _A0> 3329 {}; 3330 3331 template <class _Tp, class _A0, class _A1> 3332 struct _LIBCPP_TEMPLATE_VIS is_constructible<_Tp, _A0, _A1, __is_construct::__nat> 3333 : public __is_constructible2_void_check<is_void<_Tp>::value 3334 || is_abstract<_Tp>::value 3335 || is_function<_Tp>::value 3336 || is_void<_A0>::value 3337 || is_void<_A1>::value, 3338 _Tp, _A0, _A1> 3339 {}; 3340 3341 // Array types are default constructible if their element type 3342 // is default constructible 3343 3344 template <class _Ap, size_t _Np> 3345 struct __is_constructible0_imp<false, _Ap[_Np]> 3346 : public is_constructible<typename remove_all_extents<_Ap>::type> 3347 {}; 3348 3349 template <class _Ap, size_t _Np, class _A0> 3350 struct __is_constructible1_imp<false, _Ap[_Np], _A0> 3351 : public false_type 3352 {}; 3353 3354 template <class _Ap, size_t _Np, class _A0, class _A1> 3355 struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1> 3356 : public false_type 3357 {}; 3358 3359 template <class _Ap, size_t _Np, class _A0, class _A1, class _A2> 3360 struct __is_constructible3_imp<false, _Ap[_Np], _A0, _A1, _A2> 3361 : public false_type 3362 {}; 3363 3364 // Incomplete array types are not constructible 3365 3366 template <class _Ap> 3367 struct __is_constructible0_imp<false, _Ap[]> 3368 : public false_type 3369 {}; 3370 3371 template <class _Ap, class _A0> 3372 struct __is_constructible1_imp<false, _Ap[], _A0> 3373 : public false_type 3374 {}; 3375 3376 template <class _Ap, class _A0, class _A1> 3377 struct __is_constructible2_imp<false, _Ap[], _A0, _A1> 3378 : public false_type 3379 {}; 3380 3381 template <class _Ap, class _A0, class _A1, class _A2> 3382 struct __is_constructible3_imp<false, _Ap[], _A0, _A1, _A2> 3383 : public false_type 3384 {}; 3385 3386 #endif // __has_feature(is_constructible) 3387 3388 3389 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 3390 template <class _Tp, class ..._Args> 3391 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v 3392 = is_constructible<_Tp, _Args...>::value; 3393 #endif 3394 3395 // is_default_constructible 3396 3397 template <class _Tp> 3398 struct _LIBCPP_TEMPLATE_VIS is_default_constructible 3399 : public is_constructible<_Tp> 3400 {}; 3401 3402 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3403 template <class _Tp> 3404 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v 3405 = is_default_constructible<_Tp>::value; 3406 #endif 3407 3408 // is_copy_constructible 3409 3410 template <class _Tp> 3411 struct _LIBCPP_TEMPLATE_VIS is_copy_constructible 3412 : public is_constructible<_Tp, 3413 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 3414 3415 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3416 template <class _Tp> 3417 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v 3418 = is_copy_constructible<_Tp>::value; 3419 #endif 3420 3421 // is_move_constructible 3422 3423 template <class _Tp> 3424 struct _LIBCPP_TEMPLATE_VIS is_move_constructible 3425 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3426 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 3427 #else 3428 : public is_copy_constructible<_Tp> 3429 #endif 3430 {}; 3431 3432 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3433 template <class _Tp> 3434 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v 3435 = is_move_constructible<_Tp>::value; 3436 #endif 3437 3438 // is_trivially_constructible 3439 3440 #ifndef _LIBCPP_HAS_NO_VARIADICS 3441 3442 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 3443 3444 template <class _Tp, class... _Args> 3445 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible 3446 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> 3447 { 3448 }; 3449 3450 #else // !__has_feature(is_trivially_constructible) 3451 3452 template <class _Tp, class... _Args> 3453 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible 3454 : false_type 3455 { 3456 }; 3457 3458 template <class _Tp> 3459 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp> 3460 #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403) 3461 : integral_constant<bool, __has_trivial_constructor(_Tp)> 3462 #else 3463 : integral_constant<bool, is_scalar<_Tp>::value> 3464 #endif 3465 { 3466 }; 3467 3468 template <class _Tp> 3469 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3470 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&> 3471 #else 3472 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp> 3473 #endif 3474 : integral_constant<bool, is_scalar<_Tp>::value> 3475 { 3476 }; 3477 3478 template <class _Tp> 3479 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&> 3480 : integral_constant<bool, is_scalar<_Tp>::value> 3481 { 3482 }; 3483 3484 template <class _Tp> 3485 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&> 3486 : integral_constant<bool, is_scalar<_Tp>::value> 3487 { 3488 }; 3489 3490 #endif // !__has_feature(is_trivially_constructible) 3491 3492 #else // _LIBCPP_HAS_NO_VARIADICS 3493 3494 template <class _Tp, class _A0 = __is_construct::__nat, 3495 class _A1 = __is_construct::__nat> 3496 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible 3497 : false_type 3498 { 3499 }; 3500 3501 #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 3502 3503 template <class _Tp> 3504 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat, 3505 __is_construct::__nat> 3506 : integral_constant<bool, __is_trivially_constructible(_Tp)> 3507 { 3508 }; 3509 3510 template <class _Tp> 3511 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp, 3512 __is_construct::__nat> 3513 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)> 3514 { 3515 }; 3516 3517 template <class _Tp> 3518 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&, 3519 __is_construct::__nat> 3520 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)> 3521 { 3522 }; 3523 3524 template <class _Tp> 3525 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&, 3526 __is_construct::__nat> 3527 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)> 3528 { 3529 }; 3530 3531 #else // !__has_feature(is_trivially_constructible) 3532 3533 template <class _Tp> 3534 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, __is_construct::__nat, 3535 __is_construct::__nat> 3536 : integral_constant<bool, is_scalar<_Tp>::value> 3537 { 3538 }; 3539 3540 template <class _Tp> 3541 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp, 3542 __is_construct::__nat> 3543 : integral_constant<bool, is_scalar<_Tp>::value> 3544 { 3545 }; 3546 3547 template <class _Tp> 3548 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&, 3549 __is_construct::__nat> 3550 : integral_constant<bool, is_scalar<_Tp>::value> 3551 { 3552 }; 3553 3554 template <class _Tp> 3555 struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&, 3556 __is_construct::__nat> 3557 : integral_constant<bool, is_scalar<_Tp>::value> 3558 { 3559 }; 3560 3561 #endif // !__has_feature(is_trivially_constructible) 3562 3563 #endif // _LIBCPP_HAS_NO_VARIADICS 3564 3565 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 3566 template <class _Tp, class... _Args> 3567 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v 3568 = is_trivially_constructible<_Tp, _Args...>::value; 3569 #endif 3570 3571 // is_trivially_default_constructible 3572 3573 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible 3574 : public is_trivially_constructible<_Tp> 3575 {}; 3576 3577 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3578 template <class _Tp> 3579 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v 3580 = is_trivially_default_constructible<_Tp>::value; 3581 #endif 3582 3583 // is_trivially_copy_constructible 3584 3585 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible 3586 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> 3587 {}; 3588 3589 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3590 template <class _Tp> 3591 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v 3592 = is_trivially_copy_constructible<_Tp>::value; 3593 #endif 3594 3595 // is_trivially_move_constructible 3596 3597 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible 3598 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3599 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 3600 #else 3601 : public is_trivially_copy_constructible<_Tp> 3602 #endif 3603 {}; 3604 3605 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3606 template <class _Tp> 3607 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v 3608 = is_trivially_move_constructible<_Tp>::value; 3609 #endif 3610 3611 // is_trivially_assignable 3612 3613 #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 3614 3615 template <class _Tp, class _Arg> 3616 struct is_trivially_assignable 3617 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> 3618 { 3619 }; 3620 3621 #else // !__has_feature(is_trivially_assignable) 3622 3623 template <class _Tp, class _Arg> 3624 struct is_trivially_assignable 3625 : public false_type {}; 3626 3627 template <class _Tp> 3628 struct is_trivially_assignable<_Tp&, _Tp> 3629 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3630 3631 template <class _Tp> 3632 struct is_trivially_assignable<_Tp&, _Tp&> 3633 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3634 3635 template <class _Tp> 3636 struct is_trivially_assignable<_Tp&, const _Tp&> 3637 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3638 3639 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3640 3641 template <class _Tp> 3642 struct is_trivially_assignable<_Tp&, _Tp&&> 3643 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3644 3645 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3646 3647 #endif // !__has_feature(is_trivially_assignable) 3648 3649 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3650 template <class _Tp, class _Arg> 3651 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v 3652 = is_trivially_assignable<_Tp, _Arg>::value; 3653 #endif 3654 3655 // is_trivially_copy_assignable 3656 3657 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable 3658 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 3659 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 3660 3661 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3662 template <class _Tp> 3663 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v 3664 = is_trivially_copy_assignable<_Tp>::value; 3665 #endif 3666 3667 // is_trivially_move_assignable 3668 3669 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable 3670 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 3671 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3672 typename add_rvalue_reference<_Tp>::type> 3673 #else 3674 typename add_lvalue_reference<_Tp>::type> 3675 #endif 3676 {}; 3677 3678 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3679 template <class _Tp> 3680 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v 3681 = is_trivially_move_assignable<_Tp>::value; 3682 #endif 3683 3684 // is_trivially_destructible 3685 3686 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403) 3687 3688 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible 3689 : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {}; 3690 3691 #else 3692 3693 template <class _Tp> struct __libcpp_trivial_destructor 3694 : public integral_constant<bool, is_scalar<_Tp>::value || 3695 is_reference<_Tp>::value> {}; 3696 3697 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible 3698 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; 3699 3700 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]> 3701 : public false_type {}; 3702 3703 #endif 3704 3705 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3706 template <class _Tp> 3707 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v 3708 = is_trivially_destructible<_Tp>::value; 3709 #endif 3710 3711 // is_nothrow_constructible 3712 3713 #if 0 3714 template <class _Tp, class... _Args> 3715 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible 3716 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))> 3717 { 3718 }; 3719 3720 #else 3721 3722 #ifndef _LIBCPP_HAS_NO_VARIADICS 3723 3724 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) 3725 3726 template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible; 3727 3728 template <class _Tp, class... _Args> 3729 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...> 3730 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 3731 { 3732 }; 3733 3734 template <class _Tp> 3735 void __implicit_conversion_to(_Tp) noexcept { } 3736 3737 template <class _Tp, class _Arg> 3738 struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg> 3739 : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))> 3740 { 3741 }; 3742 3743 template <class _Tp, bool _IsReference, class... _Args> 3744 struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...> 3745 : public false_type 3746 { 3747 }; 3748 3749 template <class _Tp, class... _Args> 3750 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible 3751 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...> 3752 { 3753 }; 3754 3755 template <class _Tp, size_t _Ns> 3756 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> 3757 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> 3758 { 3759 }; 3760 3761 #else // __has_feature(cxx_noexcept) 3762 3763 template <class _Tp, class... _Args> 3764 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible 3765 : false_type 3766 { 3767 }; 3768 3769 template <class _Tp> 3770 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp> 3771 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403) 3772 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 3773 #else 3774 : integral_constant<bool, is_scalar<_Tp>::value> 3775 #endif 3776 { 3777 }; 3778 3779 template <class _Tp> 3780 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3781 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&&> 3782 #else 3783 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp> 3784 #endif 3785 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) 3786 : integral_constant<bool, __has_nothrow_copy(_Tp)> 3787 #else 3788 : integral_constant<bool, is_scalar<_Tp>::value> 3789 #endif 3790 { 3791 }; 3792 3793 template <class _Tp> 3794 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&> 3795 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) 3796 : integral_constant<bool, __has_nothrow_copy(_Tp)> 3797 #else 3798 : integral_constant<bool, is_scalar<_Tp>::value> 3799 #endif 3800 { 3801 }; 3802 3803 template <class _Tp> 3804 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&> 3805 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) 3806 : integral_constant<bool, __has_nothrow_copy(_Tp)> 3807 #else 3808 : integral_constant<bool, is_scalar<_Tp>::value> 3809 #endif 3810 { 3811 }; 3812 3813 #endif // __has_feature(cxx_noexcept) 3814 3815 #else // _LIBCPP_HAS_NO_VARIADICS 3816 3817 template <class _Tp, class _A0 = __is_construct::__nat, 3818 class _A1 = __is_construct::__nat> 3819 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible 3820 : false_type 3821 { 3822 }; 3823 3824 template <class _Tp> 3825 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat, 3826 __is_construct::__nat> 3827 #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403) 3828 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 3829 #else 3830 : integral_constant<bool, is_scalar<_Tp>::value> 3831 #endif 3832 { 3833 }; 3834 3835 template <class _Tp> 3836 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp, 3837 __is_construct::__nat> 3838 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) 3839 : integral_constant<bool, __has_nothrow_copy(_Tp)> 3840 #else 3841 : integral_constant<bool, is_scalar<_Tp>::value> 3842 #endif 3843 { 3844 }; 3845 3846 template <class _Tp> 3847 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, const _Tp&, 3848 __is_construct::__nat> 3849 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) 3850 : integral_constant<bool, __has_nothrow_copy(_Tp)> 3851 #else 3852 : integral_constant<bool, is_scalar<_Tp>::value> 3853 #endif 3854 { 3855 }; 3856 3857 template <class _Tp> 3858 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&, 3859 __is_construct::__nat> 3860 #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) 3861 : integral_constant<bool, __has_nothrow_copy(_Tp)> 3862 #else 3863 : integral_constant<bool, is_scalar<_Tp>::value> 3864 #endif 3865 { 3866 }; 3867 3868 #endif // _LIBCPP_HAS_NO_VARIADICS 3869 #endif // __has_feature(is_nothrow_constructible) 3870 3871 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 3872 template <class _Tp, class ..._Args> 3873 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v 3874 = is_nothrow_constructible<_Tp, _Args...>::value; 3875 #endif 3876 3877 // is_nothrow_default_constructible 3878 3879 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible 3880 : public is_nothrow_constructible<_Tp> 3881 {}; 3882 3883 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3884 template <class _Tp> 3885 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v 3886 = is_nothrow_default_constructible<_Tp>::value; 3887 #endif 3888 3889 // is_nothrow_copy_constructible 3890 3891 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible 3892 : public is_nothrow_constructible<_Tp, 3893 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 3894 3895 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3896 template <class _Tp> 3897 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v 3898 = is_nothrow_copy_constructible<_Tp>::value; 3899 #endif 3900 3901 // is_nothrow_move_constructible 3902 3903 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible 3904 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3905 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 3906 #else 3907 : public is_nothrow_copy_constructible<_Tp> 3908 #endif 3909 {}; 3910 3911 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3912 template <class _Tp> 3913 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v 3914 = is_nothrow_move_constructible<_Tp>::value; 3915 #endif 3916 3917 // is_nothrow_assignable 3918 3919 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) 3920 3921 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; 3922 3923 template <class _Tp, class _Arg> 3924 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> 3925 : public false_type 3926 { 3927 }; 3928 3929 template <class _Tp, class _Arg> 3930 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> 3931 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > 3932 { 3933 }; 3934 3935 template <class _Tp, class _Arg> 3936 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable 3937 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> 3938 { 3939 }; 3940 3941 #else // __has_feature(cxx_noexcept) 3942 3943 template <class _Tp, class _Arg> 3944 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable 3945 : public false_type {}; 3946 3947 template <class _Tp> 3948 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp> 3949 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) 3950 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 3951 #else 3952 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3953 #endif 3954 3955 template <class _Tp> 3956 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, _Tp&> 3957 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) 3958 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 3959 #else 3960 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3961 #endif 3962 3963 template <class _Tp> 3964 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable<_Tp&, const _Tp&> 3965 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) 3966 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 3967 #else 3968 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3969 #endif 3970 3971 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3972 3973 template <class _Tp> 3974 struct is_nothrow_assignable<_Tp&, _Tp&&> 3975 #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) 3976 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 3977 #else 3978 : integral_constant<bool, is_scalar<_Tp>::value> {}; 3979 #endif 3980 3981 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3982 3983 #endif // __has_feature(cxx_noexcept) 3984 3985 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3986 template <class _Tp, class _Arg> 3987 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v 3988 = is_nothrow_assignable<_Tp, _Arg>::value; 3989 #endif 3990 3991 // is_nothrow_copy_assignable 3992 3993 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable 3994 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 3995 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; 3996 3997 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 3998 template <class _Tp> 3999 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v 4000 = is_nothrow_copy_assignable<_Tp>::value; 4001 #endif 4002 4003 // is_nothrow_move_assignable 4004 4005 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable 4006 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 4007 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4008 typename add_rvalue_reference<_Tp>::type> 4009 #else 4010 typename add_lvalue_reference<_Tp>::type> 4011 #endif 4012 {}; 4013 4014 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 4015 template <class _Tp> 4016 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v 4017 = is_nothrow_move_assignable<_Tp>::value; 4018 #endif 4019 4020 // is_nothrow_destructible 4021 4022 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) 4023 4024 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible; 4025 4026 template <class _Tp> 4027 struct __libcpp_is_nothrow_destructible<false, _Tp> 4028 : public false_type 4029 { 4030 }; 4031 4032 template <class _Tp> 4033 struct __libcpp_is_nothrow_destructible<true, _Tp> 4034 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > 4035 { 4036 }; 4037 4038 template <class _Tp> 4039 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible 4040 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> 4041 { 4042 }; 4043 4044 template <class _Tp, size_t _Ns> 4045 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> 4046 : public is_nothrow_destructible<_Tp> 4047 { 4048 }; 4049 4050 template <class _Tp> 4051 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> 4052 : public true_type 4053 { 4054 }; 4055 4056 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4057 4058 template <class _Tp> 4059 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> 4060 : public true_type 4061 { 4062 }; 4063 4064 #endif 4065 4066 #else 4067 4068 template <class _Tp> struct __libcpp_nothrow_destructor 4069 : public integral_constant<bool, is_scalar<_Tp>::value || 4070 is_reference<_Tp>::value> {}; 4071 4072 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible 4073 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; 4074 4075 template <class _Tp> 4076 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> 4077 : public false_type {}; 4078 4079 #endif 4080 4081 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 4082 template <class _Tp> 4083 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v 4084 = is_nothrow_destructible<_Tp>::value; 4085 #endif 4086 4087 // is_pod 4088 4089 #if __has_feature(is_pod) || (_GNUC_VER >= 403) 4090 4091 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod 4092 : public integral_constant<bool, __is_pod(_Tp)> {}; 4093 4094 #else 4095 4096 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod 4097 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && 4098 is_trivially_copy_constructible<_Tp>::value && 4099 is_trivially_copy_assignable<_Tp>::value && 4100 is_trivially_destructible<_Tp>::value> {}; 4101 4102 #endif 4103 4104 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 4105 template <class _Tp> 4106 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v 4107 = is_pod<_Tp>::value; 4108 #endif 4109 4110 // is_literal_type; 4111 4112 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type 4113 #ifdef _LIBCPP_IS_LITERAL 4114 : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)> 4115 #else 4116 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value || 4117 is_reference<typename remove_all_extents<_Tp>::type>::value> 4118 #endif 4119 {}; 4120 4121 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 4122 template <class _Tp> 4123 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v 4124 = is_literal_type<_Tp>::value; 4125 #endif 4126 4127 // is_standard_layout; 4128 4129 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout 4130 #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407) 4131 : public integral_constant<bool, __is_standard_layout(_Tp)> 4132 #else 4133 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 4134 #endif 4135 {}; 4136 4137 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 4138 template <class _Tp> 4139 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v 4140 = is_standard_layout<_Tp>::value; 4141 #endif 4142 4143 // is_trivially_copyable; 4144 4145 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable 4146 #if __has_feature(is_trivially_copyable) 4147 : public integral_constant<bool, __is_trivially_copyable(_Tp)> 4148 #elif _GNUC_VER >= 501 4149 : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)> 4150 #else 4151 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 4152 #endif 4153 {}; 4154 4155 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 4156 template <class _Tp> 4157 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v 4158 = is_trivially_copyable<_Tp>::value; 4159 #endif 4160 4161 // is_trivial; 4162 4163 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial 4164 #if __has_feature(is_trivial) || _GNUC_VER >= 407 4165 : public integral_constant<bool, __is_trivial(_Tp)> 4166 #else 4167 : integral_constant<bool, is_trivially_copyable<_Tp>::value && 4168 is_trivially_default_constructible<_Tp>::value> 4169 #endif 4170 {}; 4171 4172 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 4173 template <class _Tp> 4174 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v 4175 = is_trivial<_Tp>::value; 4176 #endif 4177 4178 template <class _Tp> struct __is_reference_wrapper_impl : public false_type {}; 4179 template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {}; 4180 template <class _Tp> struct __is_reference_wrapper 4181 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {}; 4182 4183 #ifndef _LIBCPP_CXX03_LANG 4184 4185 template <class _Fp, class _A0, 4186 class _DecayFp = typename decay<_Fp>::type, 4187 class _DecayA0 = typename decay<_A0>::type, 4188 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> 4189 using __enable_if_bullet1 = typename enable_if 4190 < 4191 is_member_function_pointer<_DecayFp>::value 4192 && is_base_of<_ClassT, _DecayA0>::value 4193 >::type; 4194 4195 template <class _Fp, class _A0, 4196 class _DecayFp = typename decay<_Fp>::type, 4197 class _DecayA0 = typename decay<_A0>::type> 4198 using __enable_if_bullet2 = typename enable_if 4199 < 4200 is_member_function_pointer<_DecayFp>::value 4201 && __is_reference_wrapper<_DecayA0>::value 4202 >::type; 4203 4204 template <class _Fp, class _A0, 4205 class _DecayFp = typename decay<_Fp>::type, 4206 class _DecayA0 = typename decay<_A0>::type, 4207 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> 4208 using __enable_if_bullet3 = typename enable_if 4209 < 4210 is_member_function_pointer<_DecayFp>::value 4211 && !is_base_of<_ClassT, _DecayA0>::value 4212 && !__is_reference_wrapper<_DecayA0>::value 4213 >::type; 4214 4215 template <class _Fp, class _A0, 4216 class _DecayFp = typename decay<_Fp>::type, 4217 class _DecayA0 = typename decay<_A0>::type, 4218 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> 4219 using __enable_if_bullet4 = typename enable_if 4220 < 4221 is_member_object_pointer<_DecayFp>::value 4222 && is_base_of<_ClassT, _DecayA0>::value 4223 >::type; 4224 4225 template <class _Fp, class _A0, 4226 class _DecayFp = typename decay<_Fp>::type, 4227 class _DecayA0 = typename decay<_A0>::type> 4228 using __enable_if_bullet5 = typename enable_if 4229 < 4230 is_member_object_pointer<_DecayFp>::value 4231 && __is_reference_wrapper<_DecayA0>::value 4232 >::type; 4233 4234 template <class _Fp, class _A0, 4235 class _DecayFp = typename decay<_Fp>::type, 4236 class _DecayA0 = typename decay<_A0>::type, 4237 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> 4238 using __enable_if_bullet6 = typename enable_if 4239 < 4240 is_member_object_pointer<_DecayFp>::value 4241 && !is_base_of<_ClassT, _DecayA0>::value 4242 && !__is_reference_wrapper<_DecayA0>::value 4243 >::type; 4244 4245 // __invoke forward declarations 4246 4247 // fall back - none of the bullets 4248 4249 #define _LIBCPP_INVOKE_RETURN(...) \ 4250 noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \ 4251 { return __VA_ARGS__; } 4252 4253 template <class ..._Args> 4254 auto __invoke(__any, _Args&& ...__args) -> __nat; 4255 4256 template <class ..._Args> 4257 auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat; 4258 4259 // bullets 1, 2 and 3 4260 4261 template <class _Fp, class _A0, class ..._Args, 4262 class = __enable_if_bullet1<_Fp, _A0>> 4263 inline _LIBCPP_INLINE_VISIBILITY 4264 auto 4265 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 4266 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)) 4267 4268 template <class _Fp, class _A0, class ..._Args, 4269 class = __enable_if_bullet1<_Fp, _A0>> 4270 inline _LIBCPP_INLINE_VISIBILITY 4271 _LIBCPP_CONSTEXPR auto 4272 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 4273 _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)) 4274 4275 template <class _Fp, class _A0, class ..._Args, 4276 class = __enable_if_bullet2<_Fp, _A0>> 4277 inline _LIBCPP_INLINE_VISIBILITY 4278 auto 4279 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 4280 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...)) 4281 4282 template <class _Fp, class _A0, class ..._Args, 4283 class = __enable_if_bullet2<_Fp, _A0>> 4284 inline _LIBCPP_INLINE_VISIBILITY 4285 _LIBCPP_CONSTEXPR auto 4286 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 4287 _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...)) 4288 4289 template <class _Fp, class _A0, class ..._Args, 4290 class = __enable_if_bullet3<_Fp, _A0>> 4291 inline _LIBCPP_INLINE_VISIBILITY 4292 auto 4293 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 4294 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)) 4295 4296 template <class _Fp, class _A0, class ..._Args, 4297 class = __enable_if_bullet3<_Fp, _A0>> 4298 inline _LIBCPP_INLINE_VISIBILITY 4299 _LIBCPP_CONSTEXPR auto 4300 __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 4301 _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)) 4302 4303 // bullets 4, 5 and 6 4304 4305 template <class _Fp, class _A0, 4306 class = __enable_if_bullet4<_Fp, _A0>> 4307 inline _LIBCPP_INLINE_VISIBILITY 4308 auto 4309 __invoke(_Fp&& __f, _A0&& __a0) 4310 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f) 4311 4312 template <class _Fp, class _A0, 4313 class = __enable_if_bullet4<_Fp, _A0>> 4314 inline _LIBCPP_INLINE_VISIBILITY 4315 _LIBCPP_CONSTEXPR auto 4316 __invoke_constexpr(_Fp&& __f, _A0&& __a0) 4317 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f) 4318 4319 template <class _Fp, class _A0, 4320 class = __enable_if_bullet5<_Fp, _A0>> 4321 inline _LIBCPP_INLINE_VISIBILITY 4322 auto 4323 __invoke(_Fp&& __f, _A0&& __a0) 4324 _LIBCPP_INVOKE_RETURN(__a0.get().*__f) 4325 4326 template <class _Fp, class _A0, 4327 class = __enable_if_bullet5<_Fp, _A0>> 4328 inline _LIBCPP_INLINE_VISIBILITY 4329 _LIBCPP_CONSTEXPR auto 4330 __invoke_constexpr(_Fp&& __f, _A0&& __a0) 4331 _LIBCPP_INVOKE_RETURN(__a0.get().*__f) 4332 4333 template <class _Fp, class _A0, 4334 class = __enable_if_bullet6<_Fp, _A0>> 4335 inline _LIBCPP_INLINE_VISIBILITY 4336 auto 4337 __invoke(_Fp&& __f, _A0&& __a0) 4338 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f) 4339 4340 template <class _Fp, class _A0, 4341 class = __enable_if_bullet6<_Fp, _A0>> 4342 inline _LIBCPP_INLINE_VISIBILITY 4343 _LIBCPP_CONSTEXPR auto 4344 __invoke_constexpr(_Fp&& __f, _A0&& __a0) 4345 _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f) 4346 4347 // bullet 7 4348 4349 template <class _Fp, class ..._Args> 4350 inline _LIBCPP_INLINE_VISIBILITY 4351 auto 4352 __invoke(_Fp&& __f, _Args&& ...__args) 4353 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)) 4354 4355 template <class _Fp, class ..._Args> 4356 inline _LIBCPP_INLINE_VISIBILITY 4357 _LIBCPP_CONSTEXPR auto 4358 __invoke_constexpr(_Fp&& __f, _Args&& ...__args) 4359 _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)) 4360 4361 #undef _LIBCPP_INVOKE_RETURN 4362 4363 // __invokable 4364 4365 template <class _Ret, class _Fp, class ..._Args> 4366 struct __invokable_r 4367 { 4368 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void, 4369 // or incomplete array types as required by the standard. 4370 using _Result = decltype( 4371 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)); 4372 4373 using type = 4374 typename conditional< 4375 !is_same<_Result, __nat>::value, 4376 typename conditional< 4377 is_void<_Ret>::value, 4378 true_type, 4379 is_convertible<_Result, _Ret> 4380 >::type, 4381 false_type 4382 >::type; 4383 static const bool value = type::value; 4384 }; 4385 4386 template <class _Fp, class ..._Args> 4387 using __invokable = __invokable_r<void, _Fp, _Args...>; 4388 4389 template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args> 4390 struct __nothrow_invokable_r_imp { 4391 static const bool value = false; 4392 }; 4393 4394 template <class _Ret, class _Fp, class ..._Args> 4395 struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> 4396 { 4397 typedef __nothrow_invokable_r_imp _ThisT; 4398 4399 template <class _Tp> 4400 static void __test_noexcept(_Tp) noexcept; 4401 4402 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>( 4403 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...))); 4404 }; 4405 4406 template <class _Ret, class _Fp, class ..._Args> 4407 struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> 4408 { 4409 static const bool value = noexcept( 4410 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)); 4411 }; 4412 4413 template <class _Ret, class _Fp, class ..._Args> 4414 using __nothrow_invokable_r = 4415 __nothrow_invokable_r_imp< 4416 __invokable_r<_Ret, _Fp, _Args...>::value, 4417 is_void<_Ret>::value, 4418 _Ret, _Fp, _Args... 4419 >; 4420 4421 template <class _Fp, class ..._Args> 4422 using __nothrow_invokable = 4423 __nothrow_invokable_r_imp< 4424 __invokable<_Fp, _Args...>::value, 4425 true, void, _Fp, _Args... 4426 >; 4427 4428 template <class _Fp, class ..._Args> 4429 struct __invoke_of 4430 : public enable_if< 4431 __invokable<_Fp, _Args...>::value, 4432 typename __invokable_r<void, _Fp, _Args...>::_Result> 4433 { 4434 }; 4435 4436 // result_of 4437 4438 template <class _Fp, class ..._Args> 4439 class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> 4440 : public __invoke_of<_Fp, _Args...> 4441 { 4442 }; 4443 4444 #if _LIBCPP_STD_VER > 11 4445 template <class _Tp> using result_of_t = typename result_of<_Tp>::type; 4446 #endif 4447 4448 #if _LIBCPP_STD_VER > 14 4449 4450 // invoke_result 4451 4452 template <class _Fn, class... _Args> 4453 struct _LIBCPP_TEMPLATE_VIS invoke_result 4454 : __invoke_of<_Fn, _Args...> 4455 { 4456 }; 4457 4458 template <class _Fn, class... _Args> 4459 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; 4460 4461 // is_invocable 4462 4463 template <class _Fn, class ..._Args> 4464 struct _LIBCPP_TEMPLATE_VIS is_invocable 4465 : integral_constant<bool, __invokable<_Fn, _Args...>::value> {}; 4466 4467 template <class _Ret, class _Fn, class ..._Args> 4468 struct _LIBCPP_TEMPLATE_VIS is_invocable_r 4469 : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {}; 4470 4471 template <class _Fn, class ..._Args> 4472 _LIBCPP_INLINE_VAR constexpr bool is_invocable_v 4473 = is_invocable<_Fn, _Args...>::value; 4474 4475 template <class _Ret, class _Fn, class ..._Args> 4476 _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v 4477 = is_invocable_r<_Ret, _Fn, _Args...>::value; 4478 4479 // is_nothrow_invocable 4480 4481 template <class _Fn, class ..._Args> 4482 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable 4483 : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {}; 4484 4485 template <class _Ret, class _Fn, class ..._Args> 4486 struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r 4487 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; 4488 4489 template <class _Fn, class ..._Args> 4490 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v 4491 = is_nothrow_invocable<_Fn, _Args...>::value; 4492 4493 template <class _Ret, class _Fn, class ..._Args> 4494 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v 4495 = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; 4496 4497 #endif // _LIBCPP_STD_VER > 14 4498 4499 #endif // !defined(_LIBCPP_CXX03_LANG) 4500 4501 template <class _Tp> struct __is_swappable; 4502 template <class _Tp> struct __is_nothrow_swappable; 4503 4504 template <class _Tp> 4505 inline _LIBCPP_INLINE_VISIBILITY 4506 #ifndef _LIBCPP_CXX03_LANG 4507 typename enable_if 4508 < 4509 is_move_constructible<_Tp>::value && 4510 is_move_assignable<_Tp>::value 4511 >::type 4512 #else 4513 void 4514 #endif 4515 swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && 4516 is_nothrow_move_assignable<_Tp>::value) 4517 { 4518 _Tp __t(_VSTD::move(__x)); 4519 __x = _VSTD::move(__y); 4520 __y = _VSTD::move(__t); 4521 } 4522 4523 template<class _Tp, size_t _Np> 4524 inline _LIBCPP_INLINE_VISIBILITY 4525 typename enable_if< 4526 __is_swappable<_Tp>::value 4527 >::type 4528 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); 4529 4530 template <class _ForwardIterator1, class _ForwardIterator2> 4531 inline _LIBCPP_INLINE_VISIBILITY 4532 void 4533 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) 4534 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) 4535 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), 4536 *_VSTD::declval<_ForwardIterator2>()))) 4537 { 4538 swap(*__a, *__b); 4539 } 4540 4541 // __swappable 4542 4543 namespace __detail 4544 { 4545 // ALL generic swap overloads MUST already have a declaration available at this point. 4546 4547 template <class _Tp, class _Up = _Tp, 4548 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value> 4549 struct __swappable_with 4550 { 4551 template <class _LHS, class _RHS> 4552 static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>())) 4553 __test_swap(int); 4554 template <class, class> 4555 static __nat __test_swap(long); 4556 4557 // Extra parens are needed for the C++03 definition of decltype. 4558 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1; 4559 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2; 4560 4561 static const bool value = !is_same<__swap1, __nat>::value 4562 && !is_same<__swap2, __nat>::value; 4563 }; 4564 4565 template <class _Tp, class _Up> 4566 struct __swappable_with<_Tp, _Up, false> : false_type {}; 4567 4568 template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value> 4569 struct __nothrow_swappable_with { 4570 static const bool value = 4571 #ifndef _LIBCPP_HAS_NO_NOEXCEPT 4572 noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>())) 4573 && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>())); 4574 #else 4575 false; 4576 #endif 4577 }; 4578 4579 template <class _Tp, class _Up> 4580 struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {}; 4581 4582 } // __detail 4583 4584 template <class _Tp> 4585 struct __is_swappable 4586 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value> 4587 { 4588 }; 4589 4590 template <class _Tp> 4591 struct __is_nothrow_swappable 4592 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value> 4593 { 4594 }; 4595 4596 #if _LIBCPP_STD_VER > 14 4597 4598 template <class _Tp, class _Up> 4599 struct _LIBCPP_TEMPLATE_VIS is_swappable_with 4600 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value> 4601 { 4602 }; 4603 4604 template <class _Tp> 4605 struct _LIBCPP_TEMPLATE_VIS is_swappable 4606 : public conditional< 4607 __is_referenceable<_Tp>::value, 4608 is_swappable_with< 4609 typename add_lvalue_reference<_Tp>::type, 4610 typename add_lvalue_reference<_Tp>::type>, 4611 false_type 4612 >::type 4613 { 4614 }; 4615 4616 template <class _Tp, class _Up> 4617 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with 4618 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value> 4619 { 4620 }; 4621 4622 template <class _Tp> 4623 struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable 4624 : public conditional< 4625 __is_referenceable<_Tp>::value, 4626 is_nothrow_swappable_with< 4627 typename add_lvalue_reference<_Tp>::type, 4628 typename add_lvalue_reference<_Tp>::type>, 4629 false_type 4630 >::type 4631 { 4632 }; 4633 4634 template <class _Tp, class _Up> 4635 _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v 4636 = is_swappable_with<_Tp, _Up>::value; 4637 4638 template <class _Tp> 4639 _LIBCPP_INLINE_VAR constexpr bool is_swappable_v 4640 = is_swappable<_Tp>::value; 4641 4642 template <class _Tp, class _Up> 4643 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v 4644 = is_nothrow_swappable_with<_Tp, _Up>::value; 4645 4646 template <class _Tp> 4647 _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v 4648 = is_nothrow_swappable<_Tp>::value; 4649 4650 #endif // _LIBCPP_STD_VER > 14 4651 4652 #ifdef _LIBCPP_UNDERLYING_TYPE 4653 4654 template <class _Tp> 4655 struct underlying_type 4656 { 4657 typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type; 4658 }; 4659 4660 #if _LIBCPP_STD_VER > 11 4661 template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; 4662 #endif 4663 4664 #else // _LIBCPP_UNDERLYING_TYPE 4665 4666 template <class _Tp, bool _Support = false> 4667 struct underlying_type 4668 { 4669 static_assert(_Support, "The underyling_type trait requires compiler " 4670 "support. Either no such support exists or " 4671 "libc++ does not know how to use it."); 4672 }; 4673 4674 #endif // _LIBCPP_UNDERLYING_TYPE 4675 4676 4677 template <class _Tp, bool = is_enum<_Tp>::value> 4678 struct __sfinae_underlying_type 4679 { 4680 typedef typename underlying_type<_Tp>::type type; 4681 typedef decltype(((type)1) + 0) __promoted_type; 4682 }; 4683 4684 template <class _Tp> 4685 struct __sfinae_underlying_type<_Tp, false> {}; 4686 4687 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4688 int __convert_to_integral(int __val) { return __val; } 4689 4690 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4691 unsigned __convert_to_integral(unsigned __val) { return __val; } 4692 4693 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4694 long __convert_to_integral(long __val) { return __val; } 4695 4696 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4697 unsigned long __convert_to_integral(unsigned long __val) { return __val; } 4698 4699 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4700 long long __convert_to_integral(long long __val) { return __val; } 4701 4702 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4703 unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } 4704 4705 template<typename _Fp> 4706 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4707 typename enable_if<is_floating_point<_Fp>::value, long long>::type 4708 __convert_to_integral(_Fp __val) { return __val; } 4709 4710 #ifndef _LIBCPP_HAS_NO_INT128 4711 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4712 __int128_t __convert_to_integral(__int128_t __val) { return __val; } 4713 4714 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4715 __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } 4716 #endif 4717 4718 template <class _Tp> 4719 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 4720 typename __sfinae_underlying_type<_Tp>::__promoted_type 4721 __convert_to_integral(_Tp __val) { return __val; } 4722 4723 #ifndef _LIBCPP_CXX03_LANG 4724 4725 template <class _Tp> 4726 struct __has_operator_addressof_member_imp 4727 { 4728 template <class _Up> 4729 static auto __test(int) 4730 -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type; 4731 template <class> 4732 static auto __test(long) -> false_type; 4733 4734 static const bool value = decltype(__test<_Tp>(0))::value; 4735 }; 4736 4737 template <class _Tp> 4738 struct __has_operator_addressof_free_imp 4739 { 4740 template <class _Up> 4741 static auto __test(int) 4742 -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type; 4743 template <class> 4744 static auto __test(long) -> false_type; 4745 4746 static const bool value = decltype(__test<_Tp>(0))::value; 4747 }; 4748 4749 template <class _Tp> 4750 struct __has_operator_addressof 4751 : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value 4752 || __has_operator_addressof_free_imp<_Tp>::value> 4753 {}; 4754 4755 #endif // _LIBCPP_CXX03_LANG 4756 4757 #if _LIBCPP_STD_VER > 14 4758 4759 template <class...> using void_t = void; 4760 4761 # ifndef _LIBCPP_HAS_NO_VARIADICS 4762 template <class... _Args> 4763 struct conjunction : __and_<_Args...> {}; 4764 template<class... _Args> 4765 _LIBCPP_INLINE_VAR constexpr bool conjunction_v 4766 = conjunction<_Args...>::value; 4767 4768 template <class... _Args> 4769 struct disjunction : __or_<_Args...> {}; 4770 template<class... _Args> 4771 _LIBCPP_INLINE_VAR constexpr bool disjunction_v 4772 = disjunction<_Args...>::value; 4773 4774 template <class _Tp> 4775 struct negation : __not_<_Tp> {}; 4776 template<class _Tp> 4777 _LIBCPP_INLINE_VAR constexpr bool negation_v 4778 = negation<_Tp>::value; 4779 # endif // _LIBCPP_HAS_NO_VARIADICS 4780 #endif // _LIBCPP_STD_VER > 14 4781 4782 // These traits are used in __tree and __hash_table 4783 #ifndef _LIBCPP_CXX03_LANG 4784 struct __extract_key_fail_tag {}; 4785 struct __extract_key_self_tag {}; 4786 struct __extract_key_first_tag {}; 4787 4788 template <class _ValTy, class _Key, 4789 class _RawValTy = typename __unconstref<_ValTy>::type> 4790 struct __can_extract_key 4791 : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag, 4792 __extract_key_fail_tag>::type {}; 4793 4794 template <class _Pair, class _Key, class _First, class _Second> 4795 struct __can_extract_key<_Pair, _Key, pair<_First, _Second>> 4796 : conditional<is_same<typename remove_const<_First>::type, _Key>::value, 4797 __extract_key_first_tag, __extract_key_fail_tag>::type {}; 4798 4799 // __can_extract_map_key uses true_type/false_type instead of the tags. 4800 // It returns true if _Key != _ContainerValueTy (the container is a map not a set) 4801 // and _ValTy == _Key. 4802 template <class _ValTy, class _Key, class _ContainerValueTy, 4803 class _RawValTy = typename __unconstref<_ValTy>::type> 4804 struct __can_extract_map_key 4805 : integral_constant<bool, is_same<_RawValTy, _Key>::value> {}; 4806 4807 // This specialization returns __extract_key_fail_tag for non-map containers 4808 // because _Key == _ContainerValueTy 4809 template <class _ValTy, class _Key, class _RawValTy> 4810 struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy> 4811 : false_type {}; 4812 4813 #endif 4814 4815 #if _LIBCPP_STD_VER > 17 4816 enum class endian 4817 { 4818 little = 0xDEAD, 4819 big = 0xFACE, 4820 #if defined(_LIBCPP_LITTLE_ENDIAN) 4821 native = little 4822 #elif defined(_LIBCPP_BIG_ENDIAN) 4823 native = big 4824 #else 4825 native = 0xCAFE 4826 #endif 4827 }; 4828 #endif 4829 4830 _LIBCPP_END_NAMESPACE_STD 4831 4832 #if _LIBCPP_STD_VER > 14 4833 // std::byte 4834 namespace std // purposefully not versioned 4835 { 4836 template <class _Integer> 4837 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & 4838 operator<<=(byte& __lhs, _Integer __shift) noexcept 4839 { return __lhs = __lhs << __shift; } 4840 4841 template <class _Integer> 4842 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type 4843 operator<< (byte __lhs, _Integer __shift) noexcept 4844 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); } 4845 4846 template <class _Integer> 4847 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & 4848 operator>>=(byte& __lhs, _Integer __shift) noexcept 4849 { return __lhs = __lhs >> __shift; } 4850 4851 template <class _Integer> 4852 constexpr typename enable_if<is_integral_v<_Integer>, byte>::type 4853 operator>> (byte __lhs, _Integer __shift) noexcept 4854 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); } 4855 4856 template <class _Integer> 4857 constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type 4858 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); } 4859 4860 } 4861 #endif 4862 4863 #endif // _LIBCPP_TYPE_TRAITS 4864