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