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