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