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