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