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