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