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