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