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