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