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