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