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