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