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