type_traits revision 275472
194742Sobrien// -*- C++ -*- 294742Sobrien//===------------------------ type_traits ---------------------------------===// 394742Sobrien// 495253Sru// The LLVM Compiler Infrastructure 594742Sobrien// 694772Simp// This file is dual licensed under the MIT and the University of Illinois Open 794772Simp// Source Licenses. See LICENSE.TXT for details. 896991Srwatson// 996991Srwatson//===----------------------------------------------------------------------===// 1096991Srwatson 1194854Ssos#ifndef _LIBCPP_TYPE_TRAITS 1294917Simp#define _LIBCPP_TYPE_TRAITS 1394917Simp 1494917Simp/* 1594917Simp type_traits synopsis 1694845Smarkm 1794845Smarkmnamespace std 1894845Smarkm{ 1995382Srnordier 2094847Sjhb // helper class: 2194847Sjhb template <class T, T v> struct integral_constant; 2294847Sjhb typedef integral_constant<bool, true> true_type; 2394849Sphk typedef integral_constant<bool, false> false_type; 2494849Sphk 2594849Sphk // helper traits 2694849Sphk template <bool, class T = void> struct enable_if; 2794849Sphk template <bool, class T, class F> struct conditional; 2894849Sphk 2994849Sphk // Primary classification traits: 3094855Sscottl template <class T> struct is_void; 3194855Sscottl template <class T> struct is_null_pointer; // C++14 3294902Sbenno template <class T> struct is_integral; 3394915Sken template <class T> struct is_floating_point; 3499607Smjacob template <class T> struct is_array; 3594915Sken template <class T> struct is_pointer; 3694915Sken template <class T> struct is_lvalue_reference; 3794915Sken template <class T> struct is_rvalue_reference; 3894915Sken template <class T> struct is_member_object_pointer; 3994915Sken template <class T> struct is_member_function_pointer; 4094915Sken template <class T> struct is_enum; 4194915Sken template <class T> struct is_union; 4294915Sken template <class T> struct is_class; 4399607Smjacob template <class T> struct is_function; 4499607Smjacob 4597611Sbillf // Secondary classification traits: 4694918Sgshapiro template <class T> struct is_reference; 4794918Sgshapiro template <class T> struct is_arithmetic; 4894918Sgshapiro template <class T> struct is_fundamental; 4994918Sgshapiro template <class T> struct is_member_pointer; 5094918Sgshapiro template <class T> struct is_scalar; 5194955Smurray template <class T> struct is_object; 5294955Smurray template <class T> struct is_compound; 5395054Snectar 5495455Sdes // Const-volatile properties and transformations: 5598750Sdes template <class T> struct is_const; 5699606Sdes template <class T> struct is_volatile; 5799606Sdes template <class T> struct remove_const; 5899606Sdes template <class T> struct remove_volatile; 5996268Sgad template <class T> struct remove_cv; 6096268Sgad template <class T> struct add_const; 6196268Sgad template <class T> struct add_volatile; 6296301Sgrog template <class T> struct add_cv; 6396332Speter 6496332Speter // Reference transformations: 6596332Speter template <class T> struct remove_reference; 6696332Speter template <class T> struct add_lvalue_reference; 6796332Speter template <class T> struct add_rvalue_reference; 6896451Sru 6997611Sbillf // Pointer transformations: 7098208Simp template <class T> struct remove_pointer; 7198333Sanholt template <class T> struct add_pointer; 7299193Sjmallett 7398475Sjmallett // Integral properties: 7498986Sjmallett template <class T> struct is_signed; 7599193Sjmallett template <class T> struct is_unsigned; 7699193Sjmallett template <class T> struct make_signed; 7799611Sgordon template <class T> struct make_unsigned; 78 79 // Array properties and transformations: 80 template <class T> struct rank; 81 template <class T, unsigned I = 0> struct extent; 82 template <class T> struct remove_extent; 83 template <class T> struct remove_all_extents; 84 85 // Member introspection: 86 template <class T> struct is_pod; 87 template <class T> struct is_trivial; 88 template <class T> struct is_trivially_copyable; 89 template <class T> struct is_standard_layout; 90 template <class T> struct is_literal_type; 91 template <class T> struct is_empty; 92 template <class T> struct is_polymorphic; 93 template <class T> struct is_abstract; 94 95 template <class T, class... Args> struct is_constructible; 96 template <class T> struct is_default_constructible; 97 template <class T> struct is_copy_constructible; 98 template <class T> struct is_move_constructible; 99 template <class T, class U> struct is_assignable; 100 template <class T> struct is_copy_assignable; 101 template <class T> struct is_move_assignable; 102 template <class T> struct is_destructible; 103 104 template <class T, class... Args> struct is_trivially_constructible; 105 template <class T> struct is_trivially_default_constructible; 106 template <class T> struct is_trivially_copy_constructible; 107 template <class T> struct is_trivially_move_constructible; 108 template <class T, class U> struct is_trivially_assignable; 109 template <class T> struct is_trivially_copy_assignable; 110 template <class T> struct is_trivially_move_assignable; 111 template <class T> struct is_trivially_destructible; 112 113 template <class T, class... Args> struct is_nothrow_constructible; 114 template <class T> struct is_nothrow_default_constructible; 115 template <class T> struct is_nothrow_copy_constructible; 116 template <class T> struct is_nothrow_move_constructible; 117 template <class T, class U> struct is_nothrow_assignable; 118 template <class T> struct is_nothrow_copy_assignable; 119 template <class T> struct is_nothrow_move_assignable; 120 template <class T> struct is_nothrow_destructible; 121 122 template <class T> struct has_virtual_destructor; 123 124 // Relationships between types: 125 template <class T, class U> struct is_same; 126 template <class Base, class Derived> struct is_base_of; 127 template <class From, class To> struct is_convertible; 128 129 // Alignment properties and transformations: 130 template <class T> struct alignment_of; 131 template <size_t Len, size_t Align = most_stringent_alignment_requirement> 132 struct aligned_storage; 133 template <size_t Len, class... Types> struct aligned_union; 134 135 template <class T> struct decay; 136 template <class... T> struct common_type; 137 template <class T> struct underlying_type; 138 template <class> class result_of; // undefined 139 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; 140 141 // const-volatile modifications: 142 template <class T> 143 using remove_const_t = typename remove_const<T>::type; // C++14 144 template <class T> 145 using remove_volatile_t = typename remove_volatile<T>::type; // C++14 146 template <class T> 147 using remove_cv_t = typename remove_cv<T>::type; // C++14 148 template <class T> 149 using add_const_t = typename add_const<T>::type; // C++14 150 template <class T> 151 using add_volatile_t = typename add_volatile<T>::type; // C++14 152 template <class T> 153 using add_cv_t = typename add_cv<T>::type; // C++14 154 155 // reference modifications: 156 template <class T> 157 using remove_reference_t = typename remove_reference<T>::type; // C++14 158 template <class T> 159 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14 160 template <class T> 161 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14 162 163 // sign modifications: 164 template <class T> 165 using make_signed_t = typename make_signed<T>::type; // C++14 166 template <class T> 167 using make_unsigned_t = typename make_unsigned<T>::type; // C++14 168 169 // array modifications: 170 template <class T> 171 using remove_extent_t = typename remove_extent<T>::type; // C++14 172 template <class T> 173 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14 174 175 // pointer modifications: 176 template <class T> 177 using remove_pointer_t = typename remove_pointer<T>::type; // C++14 178 template <class T> 179 using add_pointer_t = typename add_pointer<T>::type; // C++14 180 181 // other transformations: 182 template <size_t Len, std::size_t Align=default-alignment> 183 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14 184 template <std::size_t Len, class... Types> 185 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14 186 template <class T> 187 using decay_t = typename decay<T>::type; // C++14 188 template <bool b, class T=void> 189 using enable_if_t = typename enable_if<b,T>::type; // C++14 190 template <bool b, class T, class F> 191 using conditional_t = typename conditional<b,T,F>::type; // C++14 192 template <class... T> 193 using common_type_t = typename common_type<T...>::type; // C++14 194 template <class T> 195 using underlying_type_t = typename underlying_type<T>::type; // C++14 196 template <class F, class... ArgTypes> 197 using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14 198 199} // std 200 201*/ 202#include <__config> 203#include <cstddef> 204 205#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 206#pragma GCC system_header 207#endif 208 209_LIBCPP_BEGIN_NAMESPACE_STD 210 211template <bool _Bp, class _If, class _Then> 212 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; 213template <class _If, class _Then> 214 struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;}; 215 216#if _LIBCPP_STD_VER > 11 217template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; 218#endif 219 220template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {}; 221template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;}; 222 223#if _LIBCPP_STD_VER > 11 224template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; 225#endif 226 227 228struct __two {char __lx[2];}; 229 230// helper class: 231 232template <class _Tp, _Tp __v> 233struct _LIBCPP_TYPE_VIS_ONLY integral_constant 234{ 235 static _LIBCPP_CONSTEXPR const _Tp value = __v; 236 typedef _Tp value_type; 237 typedef integral_constant type; 238 _LIBCPP_INLINE_VISIBILITY 239 _LIBCPP_CONSTEXPR operator value_type() const {return value;} 240#if _LIBCPP_STD_VER > 11 241 _LIBCPP_INLINE_VISIBILITY 242 constexpr value_type operator ()() const {return value;} 243#endif 244}; 245 246template <class _Tp, _Tp __v> 247_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; 248 249typedef integral_constant<bool, true> true_type; 250typedef integral_constant<bool, false> false_type; 251 252// is_const 253 254template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; 255template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; 256 257// is_volatile 258 259template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; 260template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; 261 262// remove_const 263 264template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; 265template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;}; 266#if _LIBCPP_STD_VER > 11 267template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; 268#endif 269 270// remove_volatile 271 272template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; 273template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;}; 274#if _LIBCPP_STD_VER > 11 275template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; 276#endif 277 278// remove_cv 279 280template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv 281{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; 282#if _LIBCPP_STD_VER > 11 283template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; 284#endif 285 286// is_void 287 288template <class _Tp> struct __libcpp_is_void : public false_type {}; 289template <> struct __libcpp_is_void<void> : public true_type {}; 290 291template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void 292 : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; 293 294// __is_nullptr_t 295 296template <class _Tp> struct __libcpp___is_nullptr : public false_type {}; 297template <> struct __libcpp___is_nullptr<nullptr_t> : public true_type {}; 298 299template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t 300 : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {}; 301 302#if _LIBCPP_STD_VER > 11 303template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer 304 : public __libcpp___is_nullptr<typename remove_cv<_Tp>::type> {}; 305#endif 306 307// is_integral 308 309template <class _Tp> struct __libcpp_is_integral : public false_type {}; 310template <> struct __libcpp_is_integral<bool> : public true_type {}; 311template <> struct __libcpp_is_integral<char> : public true_type {}; 312template <> struct __libcpp_is_integral<signed char> : public true_type {}; 313template <> struct __libcpp_is_integral<unsigned char> : public true_type {}; 314template <> struct __libcpp_is_integral<wchar_t> : public true_type {}; 315#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 316template <> struct __libcpp_is_integral<char16_t> : public true_type {}; 317template <> struct __libcpp_is_integral<char32_t> : public true_type {}; 318#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 319template <> struct __libcpp_is_integral<short> : public true_type {}; 320template <> struct __libcpp_is_integral<unsigned short> : public true_type {}; 321template <> struct __libcpp_is_integral<int> : public true_type {}; 322template <> struct __libcpp_is_integral<unsigned int> : public true_type {}; 323template <> struct __libcpp_is_integral<long> : public true_type {}; 324template <> struct __libcpp_is_integral<unsigned long> : public true_type {}; 325template <> struct __libcpp_is_integral<long long> : public true_type {}; 326template <> struct __libcpp_is_integral<unsigned long long> : public true_type {}; 327 328template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral 329 : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; 330 331// is_floating_point 332 333template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; 334template <> struct __libcpp_is_floating_point<float> : public true_type {}; 335template <> struct __libcpp_is_floating_point<double> : public true_type {}; 336template <> struct __libcpp_is_floating_point<long double> : public true_type {}; 337 338template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point 339 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; 340 341// is_array 342 343template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array 344 : public false_type {}; 345template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> 346 : public true_type {}; 347template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> 348 : public true_type {}; 349 350// is_pointer 351 352template <class _Tp> struct __libcpp_is_pointer : public false_type {}; 353template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; 354 355template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer 356 : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {}; 357 358// is_reference 359 360template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; 361template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {}; 362 363template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {}; 364#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 365template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {}; 366#endif 367 368template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {}; 369template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {}; 370#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 371template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; 372#endif 373 374#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 375#define _LIBCPP_HAS_TYPE_TRAITS 376#endif 377 378// is_union 379 380#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 381 382template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union 383 : public integral_constant<bool, __is_union(_Tp)> {}; 384 385#else 386 387template <class _Tp> struct __libcpp_union : public false_type {}; 388template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union 389 : public __libcpp_union<typename remove_cv<_Tp>::type> {}; 390 391#endif 392 393// is_class 394 395#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 396 397template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class 398 : public integral_constant<bool, __is_class(_Tp)> {}; 399 400#else 401 402namespace __is_class_imp 403{ 404template <class _Tp> char __test(int _Tp::*); 405template <class _Tp> __two __test(...); 406} 407 408template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class 409 : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; 410 411#endif 412 413// is_same 414 415template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; 416template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; 417 418// is_function 419 420namespace __is_function_imp 421{ 422template <class _Tp> char __test(_Tp*); 423template <class _Tp> __two __test(...); 424template <class _Tp> _Tp& __source(); 425} 426 427template <class _Tp, bool = is_class<_Tp>::value || 428 is_union<_Tp>::value || 429 is_void<_Tp>::value || 430 is_reference<_Tp>::value || 431 __is_nullptr_t<_Tp>::value > 432struct __libcpp_is_function 433 : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1> 434 {}; 435template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {}; 436 437template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function 438 : public __libcpp_is_function<_Tp> {}; 439 440// is_member_function_pointer 441 442// template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {}; 443// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; 444// 445 446template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr> 447struct __member_pointer_traits_imp 448{ // forward declaration; specializations later 449}; 450 451 452namespace __libcpp_is_member_function_pointer_imp { 453 template <typename _Tp> 454 char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *); 455 456 template <typename> 457 std::__two __test(...); 458}; 459 460template <class _Tp> struct __libcpp_is_member_function_pointer 461 : public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {}; 462 463template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer 464 : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {}; 465 466// is_member_pointer 467 468template <class _Tp> struct __libcpp_is_member_pointer : public false_type {}; 469template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; 470 471template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer 472 : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {}; 473 474// is_member_object_pointer 475 476template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer 477 : public integral_constant<bool, is_member_pointer<_Tp>::value && 478 !is_member_function_pointer<_Tp>::value> {}; 479 480// is_enum 481 482#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 483 484template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum 485 : public integral_constant<bool, __is_enum(_Tp)> {}; 486 487#else 488 489template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum 490 : public integral_constant<bool, !is_void<_Tp>::value && 491 !is_integral<_Tp>::value && 492 !is_floating_point<_Tp>::value && 493 !is_array<_Tp>::value && 494 !is_pointer<_Tp>::value && 495 !is_reference<_Tp>::value && 496 !is_member_pointer<_Tp>::value && 497 !is_union<_Tp>::value && 498 !is_class<_Tp>::value && 499 !is_function<_Tp>::value > {}; 500 501#endif 502 503// is_arithmetic 504 505template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic 506 : public integral_constant<bool, is_integral<_Tp>::value || 507 is_floating_point<_Tp>::value> {}; 508 509// is_fundamental 510 511template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental 512 : public integral_constant<bool, is_void<_Tp>::value || 513 __is_nullptr_t<_Tp>::value || 514 is_arithmetic<_Tp>::value> {}; 515 516// is_scalar 517 518template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar 519 : public integral_constant<bool, is_arithmetic<_Tp>::value || 520 is_member_pointer<_Tp>::value || 521 is_pointer<_Tp>::value || 522 __is_nullptr_t<_Tp>::value || 523 is_enum<_Tp>::value > {}; 524 525template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {}; 526 527// is_object 528 529template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object 530 : public integral_constant<bool, is_scalar<_Tp>::value || 531 is_array<_Tp>::value || 532 is_union<_Tp>::value || 533 is_class<_Tp>::value > {}; 534 535// is_compound 536 537template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound 538 : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; 539 540// add_const 541 542template <class _Tp, bool = is_reference<_Tp>::value || 543 is_function<_Tp>::value || 544 is_const<_Tp>::value > 545struct __add_const {typedef _Tp type;}; 546 547template <class _Tp> 548struct __add_const<_Tp, false> {typedef const _Tp type;}; 549 550template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const 551 {typedef typename __add_const<_Tp>::type type;}; 552 553#if _LIBCPP_STD_VER > 11 554template <class _Tp> using add_const_t = typename add_const<_Tp>::type; 555#endif 556 557// add_volatile 558 559template <class _Tp, bool = is_reference<_Tp>::value || 560 is_function<_Tp>::value || 561 is_volatile<_Tp>::value > 562struct __add_volatile {typedef _Tp type;}; 563 564template <class _Tp> 565struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; 566 567template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile 568 {typedef typename __add_volatile<_Tp>::type type;}; 569 570#if _LIBCPP_STD_VER > 11 571template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; 572#endif 573 574// add_cv 575 576template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv 577 {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;}; 578 579#if _LIBCPP_STD_VER > 11 580template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; 581#endif 582 583// remove_reference 584 585template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;}; 586template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;}; 587#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 588template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;}; 589#endif 590 591#if _LIBCPP_STD_VER > 11 592template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; 593#endif 594 595// add_lvalue_reference 596 597template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;}; 598template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler 599template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;}; 600template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;}; 601template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;}; 602template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;}; 603 604#if _LIBCPP_STD_VER > 11 605template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; 606#endif 607 608#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 609 610template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;}; 611template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;}; 612template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;}; 613template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;}; 614template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;}; 615 616#if _LIBCPP_STD_VER > 11 617template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; 618#endif 619 620#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 621 622#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 623 624template <class _Tp> 625typename add_rvalue_reference<_Tp>::type 626declval() _NOEXCEPT; 627 628#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 629 630template <class _Tp> 631typename add_lvalue_reference<_Tp>::type 632declval(); 633 634#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 635 636struct __any 637{ 638 __any(...); 639}; 640 641// remove_pointer 642 643template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;}; 644template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;}; 645template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;}; 646template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;}; 647template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;}; 648 649#if _LIBCPP_STD_VER > 11 650template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; 651#endif 652 653// add_pointer 654 655template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer 656 {typedef typename remove_reference<_Tp>::type* type;}; 657 658#if _LIBCPP_STD_VER > 11 659template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; 660#endif 661 662// is_signed 663 664template <class _Tp, bool = is_integral<_Tp>::value> 665struct ___is_signed : public integral_constant<bool, _Tp(-1) < _Tp(0)> {}; 666 667template <class _Tp> 668struct ___is_signed<_Tp, false> : public true_type {}; // floating point 669 670template <class _Tp, bool = is_arithmetic<_Tp>::value> 671struct __libcpp_is_signed : public ___is_signed<_Tp> {}; 672 673template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; 674 675template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; 676 677// is_unsigned 678 679template <class _Tp, bool = is_integral<_Tp>::value> 680struct ___is_unsigned : public integral_constant<bool, _Tp(0) < _Tp(-1)> {}; 681 682template <class _Tp> 683struct ___is_unsigned<_Tp, false> : public false_type {}; // floating point 684 685template <class _Tp, bool = is_arithmetic<_Tp>::value> 686struct __libcpp_is_unsigned : public ___is_unsigned<_Tp> {}; 687 688template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; 689 690template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; 691 692// rank 693 694template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank 695 : public integral_constant<size_t, 0> {}; 696template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> 697 : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 698template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> 699 : public integral_constant<size_t, rank<_Tp>::value + 1> {}; 700 701// extent 702 703template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent 704 : public integral_constant<size_t, 0> {}; 705template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0> 706 : public integral_constant<size_t, 0> {}; 707template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip> 708 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 709template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0> 710 : public integral_constant<size_t, _Np> {}; 711template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> 712 : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; 713 714// remove_extent 715 716template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent 717 {typedef _Tp type;}; 718template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]> 719 {typedef _Tp type;}; 720template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]> 721 {typedef _Tp type;}; 722 723#if _LIBCPP_STD_VER > 11 724template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; 725#endif 726 727// remove_all_extents 728 729template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents 730 {typedef _Tp type;}; 731template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]> 732 {typedef typename remove_all_extents<_Tp>::type type;}; 733template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]> 734 {typedef typename remove_all_extents<_Tp>::type type;}; 735 736#if _LIBCPP_STD_VER > 11 737template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; 738#endif 739 740// decay 741 742template <class _Tp> 743struct _LIBCPP_TYPE_VIS_ONLY decay 744{ 745private: 746 typedef typename remove_reference<_Tp>::type _Up; 747public: 748 typedef typename conditional 749 < 750 is_array<_Up>::value, 751 typename remove_extent<_Up>::type*, 752 typename conditional 753 < 754 is_function<_Up>::value, 755 typename add_pointer<_Up>::type, 756 typename remove_cv<_Up>::type 757 >::type 758 >::type type; 759}; 760 761#if _LIBCPP_STD_VER > 11 762template <class _Tp> using decay_t = typename decay<_Tp>::type; 763#endif 764 765// is_abstract 766 767namespace __is_abstract_imp 768{ 769template <class _Tp> char __test(_Tp (*)[1]); 770template <class _Tp> __two __test(...); 771} 772 773template <class _Tp, bool = is_class<_Tp>::value> 774struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {}; 775 776template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}; 777 778template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; 779 780// is_base_of 781 782#ifdef _LIBCPP_HAS_IS_BASE_OF 783 784template <class _Bp, class _Dp> 785struct _LIBCPP_TYPE_VIS_ONLY is_base_of 786 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; 787 788#else // __has_feature(is_base_of) 789 790namespace __is_base_of_imp 791{ 792template <class _Tp> 793struct _Dst 794{ 795 _Dst(const volatile _Tp &); 796}; 797template <class _Tp> 798struct _Src 799{ 800 operator const volatile _Tp &(); 801 template <class _Up> operator const _Dst<_Up> &(); 802}; 803template <size_t> struct __one { typedef char type; }; 804template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int); 805template <class _Bp, class _Dp> __two __test(...); 806} 807 808template <class _Bp, class _Dp> 809struct _LIBCPP_TYPE_VIS_ONLY is_base_of 810 : public integral_constant<bool, is_class<_Bp>::value && 811 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; 812 813#endif // __has_feature(is_base_of) 814 815// is_convertible 816 817#if __has_feature(is_convertible_to) 818 819template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible 820 : public integral_constant<bool, __is_convertible_to(_T1, _T2) && 821 !is_abstract<_T2>::value> {}; 822 823#else // __has_feature(is_convertible_to) 824 825namespace __is_convertible_imp 826{ 827template <class _Tp> char __test(_Tp); 828template <class _Tp> __two __test(...); 829#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 830template <class _Tp> _Tp&& __source(); 831#else 832template <class _Tp> typename remove_reference<_Tp>::type& __source(); 833#endif 834 835template <class _Tp, bool _IsArray = is_array<_Tp>::value, 836 bool _IsFunction = is_function<_Tp>::value, 837 bool _IsVoid = is_void<_Tp>::value> 838 struct __is_array_function_or_void {enum {value = 0};}; 839template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; 840template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; 841template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; 842} 843 844template <class _Tp, 845 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> 846struct __is_convertible_check 847{ 848 static const size_t __v = 0; 849}; 850 851template <class _Tp> 852struct __is_convertible_check<_Tp, 0> 853{ 854 static const size_t __v = sizeof(_Tp); 855}; 856 857template <class _T1, class _T2, 858 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, 859 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> 860struct __is_convertible 861 : public integral_constant<bool, 862#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 863 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 864#else 865 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 866 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value 867 && (!is_const<typename remove_reference<_T2>::type>::value 868 || is_volatile<typename remove_reference<_T2>::type>::value) 869 && (is_same<typename remove_cv<_T1>::type, 870 typename remove_cv<typename remove_reference<_T2>::type>::type>::value 871 || is_base_of<typename remove_reference<_T2>::type, _T1>::value)) 872#endif 873 > 874{}; 875 876template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {}; 877 878template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {}; 879#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 880template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {}; 881template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {}; 882template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {}; 883template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {}; 884#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 885 886template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0> 887 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {}; 888 889template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0> 890 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {}; 891 892template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0> 893 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {}; 894 895template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0> 896 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {}; 897 898template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {}; 899#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 900template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {}; 901#endif 902template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {}; 903template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {}; 904template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {}; 905template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {}; 906template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {}; 907 908template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {}; 909 910template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; 911template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; 912template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; 913template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; 914 915template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; 916template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; 917template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; 918template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; 919 920template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; 921template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; 922template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; 923template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; 924 925template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible 926 : public __is_convertible<_T1, _T2> 927{ 928 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; 929 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; 930}; 931 932#endif // __has_feature(is_convertible_to) 933 934// is_empty 935 936#if __has_feature(is_empty) 937 938template <class _Tp> 939struct _LIBCPP_TYPE_VIS_ONLY is_empty 940 : public integral_constant<bool, __is_empty(_Tp)> {}; 941 942#else // __has_feature(is_empty) 943 944template <class _Tp> 945struct __is_empty1 946 : public _Tp 947{ 948 double __lx; 949}; 950 951struct __is_empty2 952{ 953 double __lx; 954}; 955 956template <class _Tp, bool = is_class<_Tp>::value> 957struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; 958 959template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; 960 961template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {}; 962 963#endif // __has_feature(is_empty) 964 965// is_polymorphic 966 967#if __has_feature(is_polymorphic) 968 969template <class _Tp> 970struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic 971 : public integral_constant<bool, __is_polymorphic(_Tp)> {}; 972 973#else 974 975template<typename _Tp> char &__is_polymorphic_impl( 976 typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0, 977 int>::type); 978template<typename _Tp> __two &__is_polymorphic_impl(...); 979 980template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic 981 : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; 982 983#endif // __has_feature(is_polymorphic) 984 985// has_virtual_destructor 986 987#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 988 989template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor 990 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; 991 992#else // _LIBCPP_HAS_TYPE_TRAITS 993 994template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor 995 : public false_type {}; 996 997#endif // _LIBCPP_HAS_TYPE_TRAITS 998 999// alignment_of 1000 1001template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of 1002 : public integral_constant<size_t, __alignof__(_Tp)> {}; 1003 1004// aligned_storage 1005 1006template <class _Hp, class _Tp> 1007struct __type_list 1008{ 1009 typedef _Hp _Head; 1010 typedef _Tp _Tail; 1011}; 1012 1013struct __nat 1014{ 1015#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 1016 __nat() = delete; 1017 __nat(const __nat&) = delete; 1018 __nat& operator=(const __nat&) = delete; 1019 ~__nat() = delete; 1020#endif 1021}; 1022 1023template <class _Tp> 1024struct __align_type 1025{ 1026 static const size_t value = alignment_of<_Tp>::value; 1027 typedef _Tp type; 1028}; 1029 1030struct __struct_double {long double __lx;}; 1031struct __struct_double4 {double __lx[4];}; 1032 1033typedef 1034 __type_list<__align_type<unsigned char>, 1035 __type_list<__align_type<unsigned short>, 1036 __type_list<__align_type<unsigned int>, 1037 __type_list<__align_type<unsigned long>, 1038 __type_list<__align_type<unsigned long long>, 1039 __type_list<__align_type<double>, 1040 __type_list<__align_type<long double>, 1041 __type_list<__align_type<__struct_double>, 1042 __type_list<__align_type<__struct_double4>, 1043 __type_list<__align_type<int*>, 1044 __nat 1045 > > > > > > > > > > __all_types; 1046 1047template <class _TL, size_t _Align> struct __find_pod; 1048 1049template <class _Hp, size_t _Align> 1050struct __find_pod<__type_list<_Hp, __nat>, _Align> 1051{ 1052 typedef typename conditional< 1053 _Align == _Hp::value, 1054 typename _Hp::type, 1055 void 1056 >::type type; 1057}; 1058 1059template <class _Hp, class _Tp, size_t _Align> 1060struct __find_pod<__type_list<_Hp, _Tp>, _Align> 1061{ 1062 typedef typename conditional< 1063 _Align == _Hp::value, 1064 typename _Hp::type, 1065 typename __find_pod<_Tp, _Align>::type 1066 >::type type; 1067}; 1068 1069template <class _TL, size_t _Len> struct __find_max_align; 1070 1071template <class _Hp, size_t _Len> 1072struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; 1073 1074template <size_t _Len, size_t _A1, size_t _A2> 1075struct __select_align 1076{ 1077private: 1078 static const size_t __min = _A2 < _A1 ? _A2 : _A1; 1079 static const size_t __max = _A1 < _A2 ? _A2 : _A1; 1080public: 1081 static const size_t value = _Len < __max ? __min : __max; 1082}; 1083 1084template <class _Hp, class _Tp, size_t _Len> 1085struct __find_max_align<__type_list<_Hp, _Tp>, _Len> 1086 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; 1087 1088template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1089struct _LIBCPP_TYPE_VIS_ONLY aligned_storage 1090{ 1091 typedef typename __find_pod<__all_types, _Align>::type _Aligner; 1092 static_assert(!is_void<_Aligner>::value, ""); 1093 union type 1094 { 1095 _Aligner __align; 1096 unsigned char __data[_Len]; 1097 }; 1098}; 1099 1100#if _LIBCPP_STD_VER > 11 1101template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> 1102 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; 1103#endif 1104 1105#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ 1106template <size_t _Len>\ 1107struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ 1108{\ 1109 struct _ALIGNAS(n) type\ 1110 {\ 1111 unsigned char __lx[_Len];\ 1112 };\ 1113} 1114 1115_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); 1116_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); 1117_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); 1118_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); 1119_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); 1120_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); 1121_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); 1122_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); 1123_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); 1124_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); 1125_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); 1126_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); 1127_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); 1128_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); 1129// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000) 1130#if !defined(_LIBCPP_MSVC) 1131_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); 1132#endif // !_LIBCPP_MSVC 1133 1134#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION 1135 1136#ifndef _LIBCPP_HAS_NO_VARIADICS 1137 1138// aligned_union 1139 1140template <size_t _I0, size_t ..._In> 1141struct __static_max; 1142 1143template <size_t _I0> 1144struct __static_max<_I0> 1145{ 1146 static const size_t value = _I0; 1147}; 1148 1149template <size_t _I0, size_t _I1, size_t ..._In> 1150struct __static_max<_I0, _I1, _In...> 1151{ 1152 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : 1153 __static_max<_I1, _In...>::value; 1154}; 1155 1156template <size_t _Len, class _Type0, class ..._Types> 1157struct aligned_union 1158{ 1159 static const size_t alignment_value = __static_max<__alignof__(_Type0), 1160 __alignof__(_Types)...>::value; 1161 static const size_t __len = __static_max<_Len, sizeof(_Type0), 1162 sizeof(_Types)...>::value; 1163 typedef typename aligned_storage<__len, alignment_value>::type type; 1164}; 1165 1166#if _LIBCPP_STD_VER > 11 1167template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; 1168#endif 1169 1170#endif // _LIBCPP_HAS_NO_VARIADICS 1171 1172// __promote 1173 1174template <class _A1, class _A2 = void, class _A3 = void, 1175 bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) && 1176 (is_arithmetic<_A2>::value || is_void<_A2>::value) && 1177 (is_arithmetic<_A3>::value || is_void<_A3>::value)> 1178class __promote {}; 1179 1180template <class _A1, class _A2, class _A3> 1181class __promote<_A1, _A2, _A3, true> 1182{ 1183private: 1184 typedef typename __promote<_A1>::type __type1; 1185 typedef typename __promote<_A2>::type __type2; 1186 typedef typename __promote<_A3>::type __type3; 1187public: 1188 typedef decltype(__type1() + __type2() + __type3()) type; 1189}; 1190 1191template <class _A1, class _A2> 1192class __promote<_A1, _A2, void, true> 1193{ 1194private: 1195 typedef typename __promote<_A1>::type __type1; 1196 typedef typename __promote<_A2>::type __type2; 1197public: 1198 typedef decltype(__type1() + __type2()) type; 1199}; 1200 1201template <class _A1> 1202class __promote<_A1, void, void, true> 1203{ 1204public: 1205 typedef typename conditional<is_arithmetic<_A1>::value, 1206 typename conditional<is_integral<_A1>::value, double, _A1>::type, 1207 void 1208 >::type type; 1209}; 1210 1211#ifdef _LIBCPP_STORE_AS_OPTIMIZATION 1212 1213// __transform 1214 1215template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;}; 1216template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;}; 1217template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;}; 1218template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;}; 1219template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; 1220 1221#endif // _LIBCPP_STORE_AS_OPTIMIZATION 1222 1223// make_signed / make_unsigned 1224 1225typedef 1226 __type_list<signed char, 1227 __type_list<signed short, 1228 __type_list<signed int, 1229 __type_list<signed long, 1230 __type_list<signed long long, 1231 __nat 1232 > > > > > __signed_types; 1233 1234typedef 1235 __type_list<unsigned char, 1236 __type_list<unsigned short, 1237 __type_list<unsigned int, 1238 __type_list<unsigned long, 1239 __type_list<unsigned long long, 1240 __nat 1241 > > > > > __unsigned_types; 1242 1243template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; 1244 1245template <class _Hp, class _Tp, size_t _Size> 1246struct __find_first<__type_list<_Hp, _Tp>, _Size, true> 1247{ 1248 typedef _Hp type; 1249}; 1250 1251template <class _Hp, class _Tp, size_t _Size> 1252struct __find_first<__type_list<_Hp, _Tp>, _Size, false> 1253{ 1254 typedef typename __find_first<_Tp, _Size>::type type; 1255}; 1256 1257template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, 1258 bool = is_volatile<typename remove_reference<_Tp>::type>::value> 1259struct __apply_cv 1260{ 1261 typedef _Up type; 1262}; 1263 1264template <class _Tp, class _Up> 1265struct __apply_cv<_Tp, _Up, true, false> 1266{ 1267 typedef const _Up type; 1268}; 1269 1270template <class _Tp, class _Up> 1271struct __apply_cv<_Tp, _Up, false, true> 1272{ 1273 typedef volatile _Up type; 1274}; 1275 1276template <class _Tp, class _Up> 1277struct __apply_cv<_Tp, _Up, true, true> 1278{ 1279 typedef const volatile _Up type; 1280}; 1281 1282template <class _Tp, class _Up> 1283struct __apply_cv<_Tp&, _Up, false, false> 1284{ 1285 typedef _Up& type; 1286}; 1287 1288template <class _Tp, class _Up> 1289struct __apply_cv<_Tp&, _Up, true, false> 1290{ 1291 typedef const _Up& type; 1292}; 1293 1294template <class _Tp, class _Up> 1295struct __apply_cv<_Tp&, _Up, false, true> 1296{ 1297 typedef volatile _Up& type; 1298}; 1299 1300template <class _Tp, class _Up> 1301struct __apply_cv<_Tp&, _Up, true, true> 1302{ 1303 typedef const volatile _Up& type; 1304}; 1305 1306template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 1307struct __make_signed {}; 1308 1309template <class _Tp> 1310struct __make_signed<_Tp, true> 1311{ 1312 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; 1313}; 1314 1315template <> struct __make_signed<bool, true> {}; 1316template <> struct __make_signed< signed short, true> {typedef short type;}; 1317template <> struct __make_signed<unsigned short, true> {typedef short type;}; 1318template <> struct __make_signed< signed int, true> {typedef int type;}; 1319template <> struct __make_signed<unsigned int, true> {typedef int type;}; 1320template <> struct __make_signed< signed long, true> {typedef long type;}; 1321template <> struct __make_signed<unsigned long, true> {typedef long type;}; 1322template <> struct __make_signed< signed long long, true> {typedef long long type;}; 1323template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; 1324 1325template <class _Tp> 1326struct _LIBCPP_TYPE_VIS_ONLY make_signed 1327{ 1328 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; 1329}; 1330 1331#if _LIBCPP_STD_VER > 11 1332template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; 1333#endif 1334 1335template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 1336struct __make_unsigned {}; 1337 1338template <class _Tp> 1339struct __make_unsigned<_Tp, true> 1340{ 1341 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; 1342}; 1343 1344template <> struct __make_unsigned<bool, true> {}; 1345template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; 1346template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; 1347template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; 1348template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; 1349template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; 1350template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; 1351template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; 1352template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; 1353 1354template <class _Tp> 1355struct _LIBCPP_TYPE_VIS_ONLY make_unsigned 1356{ 1357 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; 1358}; 1359 1360#if _LIBCPP_STD_VER > 11 1361template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; 1362#endif 1363 1364#ifdef _LIBCPP_HAS_NO_VARIADICS 1365 1366template <class _Tp, class _Up = void, class V = void> 1367struct _LIBCPP_TYPE_VIS_ONLY common_type 1368{ 1369public: 1370 typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type; 1371}; 1372 1373template <class _Tp> 1374struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void> 1375{ 1376public: 1377 typedef _Tp type; 1378}; 1379 1380template <class _Tp, class _Up> 1381struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> 1382{ 1383private: 1384#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1385 static _Tp&& __t(); 1386 static _Up&& __u(); 1387#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1388 static _Tp __t(); 1389 static _Up __u(); 1390#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1391public: 1392 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type; 1393}; 1394 1395#else // _LIBCPP_HAS_NO_VARIADICS 1396 1397template <class ..._Tp> struct common_type; 1398 1399template <class _Tp> 1400struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> 1401{ 1402 typedef typename decay<_Tp>::type type; 1403}; 1404 1405template <class _Tp, class _Up> 1406struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> 1407{ 1408private: 1409 static _Tp&& __t(); 1410 static _Up&& __u(); 1411 static bool __f(); 1412public: 1413 typedef typename decay<decltype(__f() ? __t() : __u())>::type type; 1414}; 1415 1416template <class _Tp, class _Up, class ..._Vp> 1417struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> 1418{ 1419 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; 1420}; 1421 1422#if _LIBCPP_STD_VER > 11 1423template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; 1424#endif 1425 1426#endif // _LIBCPP_HAS_NO_VARIADICS 1427 1428// is_assignable 1429 1430template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; }; 1431 1432template <class _Tp, class _Arg> 1433typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type 1434#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1435__is_assignable_test(_Tp&&, _Arg&&); 1436#else 1437__is_assignable_test(_Tp, _Arg&); 1438#endif 1439 1440template <class _Arg> 1441false_type 1442#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1443__is_assignable_test(__any, _Arg&&); 1444#else 1445__is_assignable_test(__any, _Arg&); 1446#endif 1447 1448template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> 1449struct __is_assignable_imp 1450 : public common_type 1451 < 1452 decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>())) 1453 >::type {}; 1454 1455template <class _Tp, class _Arg> 1456struct __is_assignable_imp<_Tp, _Arg, true> 1457 : public false_type 1458{ 1459}; 1460 1461template <class _Tp, class _Arg> 1462struct is_assignable 1463 : public __is_assignable_imp<_Tp, _Arg> {}; 1464 1465// is_copy_assignable 1466 1467template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable 1468 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 1469 const typename add_lvalue_reference<_Tp>::type> {}; 1470 1471// is_move_assignable 1472 1473template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable 1474#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1475 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 1476 const typename add_rvalue_reference<_Tp>::type> {}; 1477#else 1478 : public is_copy_assignable<_Tp> {}; 1479#endif 1480 1481// is_destructible 1482 1483template <class _Tp> 1484struct __destructible_test 1485{ 1486 _Tp __t; 1487}; 1488 1489template <class _Tp> 1490decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type())) 1491#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1492__is_destructible_test(_Tp&&); 1493#else 1494__is_destructible_test(_Tp&); 1495#endif 1496 1497false_type 1498__is_destructible_test(__any); 1499 1500template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value 1501 || is_function<_Tp>::value> 1502struct __destructible_imp 1503 : public common_type 1504 < 1505 decltype(__is_destructible_test(declval<_Tp>())) 1506 >::type {}; 1507 1508template <class _Tp> 1509struct __destructible_imp<_Tp, true> 1510 : public false_type {}; 1511 1512template <class _Tp> 1513struct is_destructible 1514 : public __destructible_imp<_Tp> {}; 1515 1516template <class _Tp> 1517struct is_destructible<_Tp[]> 1518 : public false_type {}; 1519 1520// move 1521 1522#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1523 1524template <class _Tp> 1525inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1526typename remove_reference<_Tp>::type&& 1527move(_Tp&& __t) _NOEXCEPT 1528{ 1529 typedef typename remove_reference<_Tp>::type _Up; 1530 return static_cast<_Up&&>(__t); 1531} 1532 1533template <class _Tp> 1534inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1535_Tp&& 1536forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT 1537{ 1538 return static_cast<_Tp&&>(__t); 1539} 1540 1541template <class _Tp> 1542inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1543_Tp&& 1544forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT 1545{ 1546 static_assert(!std::is_lvalue_reference<_Tp>::value, 1547 "Can not forward an rvalue as an lvalue."); 1548 return static_cast<_Tp&&>(__t); 1549} 1550 1551#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1552 1553template <class _Tp> 1554inline _LIBCPP_INLINE_VISIBILITY 1555_Tp& 1556move(_Tp& __t) 1557{ 1558 return __t; 1559} 1560 1561template <class _Tp> 1562inline _LIBCPP_INLINE_VISIBILITY 1563const _Tp& 1564move(const _Tp& __t) 1565{ 1566 return __t; 1567} 1568 1569template <class _Tp> 1570inline _LIBCPP_INLINE_VISIBILITY 1571_Tp& 1572forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT 1573{ 1574 return __t; 1575} 1576 1577 1578template <class _Tp> 1579class __rv 1580{ 1581 typedef typename remove_reference<_Tp>::type _Trr; 1582 _Trr& t_; 1583public: 1584 _LIBCPP_INLINE_VISIBILITY 1585 _Trr* operator->() {return &t_;} 1586 _LIBCPP_INLINE_VISIBILITY 1587 explicit __rv(_Trr& __t) : t_(__t) {} 1588}; 1589 1590#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1591 1592#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1593 1594template <class _Tp> 1595inline _LIBCPP_INLINE_VISIBILITY 1596typename decay<_Tp>::type 1597__decay_copy(_Tp&& __t) 1598{ 1599 return _VSTD::forward<_Tp>(__t); 1600} 1601 1602#else 1603 1604template <class _Tp> 1605inline _LIBCPP_INLINE_VISIBILITY 1606typename decay<_Tp>::type 1607__decay_copy(const _Tp& __t) 1608{ 1609 return _VSTD::forward<_Tp>(__t); 1610} 1611 1612#endif 1613 1614#ifndef _LIBCPP_HAS_NO_VARIADICS 1615 1616template <class _Rp, class _Class, class ..._Param> 1617struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> 1618{ 1619 typedef _Class _ClassType; 1620 typedef _Rp _ReturnType; 1621 typedef _Rp (_FnType) (_Param...); 1622}; 1623 1624template <class _Rp, class _Class, class ..._Param> 1625struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> 1626{ 1627 typedef _Class const _ClassType; 1628 typedef _Rp _ReturnType; 1629 typedef _Rp (_FnType) (_Param...); 1630}; 1631 1632template <class _Rp, class _Class, class ..._Param> 1633struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> 1634{ 1635 typedef _Class volatile _ClassType; 1636 typedef _Rp _ReturnType; 1637 typedef _Rp (_FnType) (_Param...); 1638}; 1639 1640template <class _Rp, class _Class, class ..._Param> 1641struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> 1642{ 1643 typedef _Class const volatile _ClassType; 1644 typedef _Rp _ReturnType; 1645 typedef _Rp (_FnType) (_Param...); 1646}; 1647 1648#if __has_feature(cxx_reference_qualified_functions) 1649 1650template <class _Rp, class _Class, class ..._Param> 1651struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> 1652{ 1653 typedef _Class& _ClassType; 1654 typedef _Rp _ReturnType; 1655 typedef _Rp (_FnType) (_Param...); 1656}; 1657 1658template <class _Rp, class _Class, class ..._Param> 1659struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> 1660{ 1661 typedef _Class const& _ClassType; 1662 typedef _Rp _ReturnType; 1663 typedef _Rp (_FnType) (_Param...); 1664}; 1665 1666template <class _Rp, class _Class, class ..._Param> 1667struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> 1668{ 1669 typedef _Class volatile& _ClassType; 1670 typedef _Rp _ReturnType; 1671 typedef _Rp (_FnType) (_Param...); 1672}; 1673 1674template <class _Rp, class _Class, class ..._Param> 1675struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> 1676{ 1677 typedef _Class const volatile& _ClassType; 1678 typedef _Rp _ReturnType; 1679 typedef _Rp (_FnType) (_Param...); 1680}; 1681 1682template <class _Rp, class _Class, class ..._Param> 1683struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> 1684{ 1685 typedef _Class&& _ClassType; 1686 typedef _Rp _ReturnType; 1687 typedef _Rp (_FnType) (_Param...); 1688}; 1689 1690template <class _Rp, class _Class, class ..._Param> 1691struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> 1692{ 1693 typedef _Class const&& _ClassType; 1694 typedef _Rp _ReturnType; 1695 typedef _Rp (_FnType) (_Param...); 1696}; 1697 1698template <class _Rp, class _Class, class ..._Param> 1699struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> 1700{ 1701 typedef _Class volatile&& _ClassType; 1702 typedef _Rp _ReturnType; 1703 typedef _Rp (_FnType) (_Param...); 1704}; 1705 1706template <class _Rp, class _Class, class ..._Param> 1707struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> 1708{ 1709 typedef _Class const volatile&& _ClassType; 1710 typedef _Rp _ReturnType; 1711 typedef _Rp (_FnType) (_Param...); 1712}; 1713 1714#endif // __has_feature(cxx_reference_qualified_functions) 1715 1716#else // _LIBCPP_HAS_NO_VARIADICS 1717 1718template <class _Rp, class _Class> 1719struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> 1720{ 1721 typedef _Class _ClassType; 1722 typedef _Rp _ReturnType; 1723 typedef _Rp (_FnType) (); 1724}; 1725 1726template <class _Rp, class _Class, class _P0> 1727struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> 1728{ 1729 typedef _Class _ClassType; 1730 typedef _Rp _ReturnType; 1731 typedef _Rp (_FnType) (_P0); 1732}; 1733 1734template <class _Rp, class _Class, class _P0, class _P1> 1735struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> 1736{ 1737 typedef _Class _ClassType; 1738 typedef _Rp _ReturnType; 1739 typedef _Rp (_FnType) (_P0, _P1); 1740}; 1741 1742template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1743struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> 1744{ 1745 typedef _Class _ClassType; 1746 typedef _Rp _ReturnType; 1747 typedef _Rp (_FnType) (_P0, _P1, _P2); 1748}; 1749 1750template <class _Rp, class _Class> 1751struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> 1752{ 1753 typedef _Class const _ClassType; 1754 typedef _Rp _ReturnType; 1755 typedef _Rp (_FnType) (); 1756}; 1757 1758template <class _Rp, class _Class, class _P0> 1759struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> 1760{ 1761 typedef _Class const _ClassType; 1762 typedef _Rp _ReturnType; 1763 typedef _Rp (_FnType) (_P0); 1764}; 1765 1766template <class _Rp, class _Class, class _P0, class _P1> 1767struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> 1768{ 1769 typedef _Class const _ClassType; 1770 typedef _Rp _ReturnType; 1771 typedef _Rp (_FnType) (_P0, _P1); 1772}; 1773 1774template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1775struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false> 1776{ 1777 typedef _Class const _ClassType; 1778 typedef _Rp _ReturnType; 1779 typedef _Rp (_FnType) (_P0, _P1, _P2); 1780}; 1781 1782template <class _Rp, class _Class> 1783struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> 1784{ 1785 typedef _Class volatile _ClassType; 1786 typedef _Rp _ReturnType; 1787 typedef _Rp (_FnType) (); 1788}; 1789 1790template <class _Rp, class _Class, class _P0> 1791struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> 1792{ 1793 typedef _Class volatile _ClassType; 1794 typedef _Rp _ReturnType; 1795 typedef _Rp (_FnType) (_P0); 1796}; 1797 1798template <class _Rp, class _Class, class _P0, class _P1> 1799struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false> 1800{ 1801 typedef _Class volatile _ClassType; 1802 typedef _Rp _ReturnType; 1803 typedef _Rp (_FnType) (_P0, _P1); 1804}; 1805 1806template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1807struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false> 1808{ 1809 typedef _Class volatile _ClassType; 1810 typedef _Rp _ReturnType; 1811 typedef _Rp (_FnType) (_P0, _P1, _P2); 1812}; 1813 1814template <class _Rp, class _Class> 1815struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false> 1816{ 1817 typedef _Class const volatile _ClassType; 1818 typedef _Rp _ReturnType; 1819 typedef _Rp (_FnType) (); 1820}; 1821 1822template <class _Rp, class _Class, class _P0> 1823struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false> 1824{ 1825 typedef _Class const volatile _ClassType; 1826 typedef _Rp _ReturnType; 1827 typedef _Rp (_FnType) (_P0); 1828}; 1829 1830template <class _Rp, class _Class, class _P0, class _P1> 1831struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false> 1832{ 1833 typedef _Class const volatile _ClassType; 1834 typedef _Rp _ReturnType; 1835 typedef _Rp (_FnType) (_P0, _P1); 1836}; 1837 1838template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1839struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false> 1840{ 1841 typedef _Class const volatile _ClassType; 1842 typedef _Rp _ReturnType; 1843 typedef _Rp (_FnType) (_P0, _P1, _P2); 1844}; 1845 1846#endif // _LIBCPP_HAS_NO_VARIADICS 1847 1848template <class _Rp, class _Class> 1849struct __member_pointer_traits_imp<_Rp _Class::*, false, true> 1850{ 1851 typedef _Class _ClassType; 1852 typedef _Rp _ReturnType; 1853}; 1854 1855template <class _MP> 1856struct __member_pointer_traits 1857 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type, 1858 is_member_function_pointer<_MP>::value, 1859 is_member_object_pointer<_MP>::value> 1860{ 1861// typedef ... _ClassType; 1862// typedef ... _ReturnType; 1863// typedef ... _FnType; 1864}; 1865 1866// result_of 1867 1868template <class _Callable> class result_of; 1869 1870#ifdef _LIBCPP_HAS_NO_VARIADICS 1871 1872template <class _Fn, bool, bool> 1873class __result_of 1874{ 1875}; 1876 1877template <class _Fn> 1878class __result_of<_Fn(), true, false> 1879{ 1880public: 1881 typedef decltype(declval<_Fn>()()) type; 1882}; 1883 1884template <class _Fn, class _A0> 1885class __result_of<_Fn(_A0), true, false> 1886{ 1887public: 1888 typedef decltype(declval<_Fn>()(declval<_A0>())) type; 1889}; 1890 1891template <class _Fn, class _A0, class _A1> 1892class __result_of<_Fn(_A0, _A1), true, false> 1893{ 1894public: 1895 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; 1896}; 1897 1898template <class _Fn, class _A0, class _A1, class _A2> 1899class __result_of<_Fn(_A0, _A1, _A2), true, false> 1900{ 1901public: 1902 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; 1903}; 1904 1905template <class _MP, class _Tp, bool _IsMemberFunctionPtr> 1906struct __result_of_mp; 1907 1908// member function pointer 1909 1910template <class _MP, class _Tp> 1911struct __result_of_mp<_MP, _Tp, true> 1912 : public common_type<typename __member_pointer_traits<_MP>::_ReturnType> 1913{ 1914}; 1915 1916// member data pointer 1917 1918template <class _MP, class _Tp, bool> 1919struct __result_of_mdp; 1920 1921template <class _Rp, class _Class, class _Tp> 1922struct __result_of_mdp<_Rp _Class::*, _Tp, false> 1923{ 1924 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type; 1925}; 1926 1927template <class _Rp, class _Class, class _Tp> 1928struct __result_of_mdp<_Rp _Class::*, _Tp, true> 1929{ 1930 typedef typename __apply_cv<_Tp, _Rp>::type& type; 1931}; 1932 1933template <class _Rp, class _Class, class _Tp> 1934struct __result_of_mp<_Rp _Class::*, _Tp, false> 1935 : public __result_of_mdp<_Rp _Class::*, _Tp, 1936 is_base_of<_Class, typename remove_reference<_Tp>::type>::value> 1937{ 1938}; 1939 1940 1941 1942template <class _Fn, class _Tp> 1943class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer 1944 : public __result_of_mp<typename remove_reference<_Fn>::type, 1945 _Tp, 1946 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1947{ 1948}; 1949 1950template <class _Fn, class _Tp, class _A0> 1951class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer 1952 : public __result_of_mp<typename remove_reference<_Fn>::type, 1953 _Tp, 1954 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1955{ 1956}; 1957 1958template <class _Fn, class _Tp, class _A0, class _A1> 1959class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer 1960 : public __result_of_mp<typename remove_reference<_Fn>::type, 1961 _Tp, 1962 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1963{ 1964}; 1965 1966template <class _Fn, class _Tp, class _A0, class _A1, class _A2> 1967class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer 1968 : public __result_of_mp<typename remove_reference<_Fn>::type, 1969 _Tp, 1970 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1971{ 1972}; 1973 1974// result_of 1975 1976template <class _Fn> 1977class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()> 1978 : public __result_of<_Fn(), 1979 is_class<typename remove_reference<_Fn>::type>::value || 1980 is_function<typename remove_reference<_Fn>::type>::value, 1981 is_member_pointer<typename remove_reference<_Fn>::type>::value 1982 > 1983{ 1984}; 1985 1986template <class _Fn, class _A0> 1987class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)> 1988 : public __result_of<_Fn(_A0), 1989 is_class<typename remove_reference<_Fn>::type>::value || 1990 is_function<typename remove_reference<_Fn>::type>::value, 1991 is_member_pointer<typename remove_reference<_Fn>::type>::value 1992 > 1993{ 1994}; 1995 1996template <class _Fn, class _A0, class _A1> 1997class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)> 1998 : public __result_of<_Fn(_A0, _A1), 1999 is_class<typename remove_reference<_Fn>::type>::value || 2000 is_function<typename remove_reference<_Fn>::type>::value, 2001 is_member_pointer<typename remove_reference<_Fn>::type>::value 2002 > 2003{ 2004}; 2005 2006template <class _Fn, class _A0, class _A1, class _A2> 2007class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)> 2008 : public __result_of<_Fn(_A0, _A1, _A2), 2009 is_class<typename remove_reference<_Fn>::type>::value || 2010 is_function<typename remove_reference<_Fn>::type>::value, 2011 is_member_pointer<typename remove_reference<_Fn>::type>::value 2012 > 2013{ 2014}; 2015 2016#endif // _LIBCPP_HAS_NO_VARIADICS 2017 2018#ifndef _LIBCPP_HAS_NO_VARIADICS 2019 2020// template <class T, class... Args> struct is_constructible; 2021 2022// main is_constructible test 2023 2024template <class _Tp, class ..._Args> 2025typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type 2026__is_constructible_test(_Tp&&, _Args&& ...); 2027 2028template <class ..._Args> 2029false_type 2030__is_constructible_test(__any, _Args&& ...); 2031 2032template <bool, class _Tp, class... _Args> 2033struct __is_constructible // false, _Tp is not a scalar 2034 : public common_type 2035 < 2036 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...)) 2037 >::type 2038 {}; 2039 2040// function types are not constructible 2041 2042template <class _Rp, class... _A1, class... _A2> 2043struct __is_constructible<false, _Rp(_A1...), _A2...> 2044 : public false_type 2045 {}; 2046 2047// handle scalars and reference types 2048 2049// Scalars are default constructible, references are not 2050 2051template <class _Tp> 2052struct __is_constructible<true, _Tp> 2053 : public is_scalar<_Tp> 2054 {}; 2055 2056// Scalars and references are constructible from one arg if that arg is 2057// implicitly convertible to the scalar or reference. 2058 2059template <class _Tp> 2060struct __is_constructible_ref 2061{ 2062 true_type static __lxx(_Tp); 2063 false_type static __lxx(...); 2064}; 2065 2066template <class _Tp, class _A0> 2067struct __is_constructible<true, _Tp, _A0> 2068 : public common_type 2069 < 2070 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>())) 2071 >::type 2072 {}; 2073 2074// Scalars and references are not constructible from multiple args. 2075 2076template <class _Tp, class _A0, class ..._Args> 2077struct __is_constructible<true, _Tp, _A0, _Args...> 2078 : public false_type 2079 {}; 2080 2081// Treat scalars and reference types separately 2082 2083template <bool, class _Tp, class... _Args> 2084struct __is_constructible_void_check 2085 : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2086 _Tp, _Args...> 2087 {}; 2088 2089// If any of T or Args is void, is_constructible should be false 2090 2091template <class _Tp, class... _Args> 2092struct __is_constructible_void_check<true, _Tp, _Args...> 2093 : public false_type 2094 {}; 2095 2096template <class ..._Args> struct __contains_void; 2097 2098template <> struct __contains_void<> : false_type {}; 2099 2100template <class _A0, class ..._Args> 2101struct __contains_void<_A0, _Args...> 2102{ 2103 static const bool value = is_void<_A0>::value || 2104 __contains_void<_Args...>::value; 2105}; 2106 2107// is_constructible entry point 2108 2109template <class _Tp, class... _Args> 2110struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2111 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value 2112 || is_abstract<_Tp>::value, 2113 _Tp, _Args...> 2114 {}; 2115 2116// Array types are default constructible if their element type 2117// is default constructible 2118 2119template <class _Ap, size_t _Np> 2120struct __is_constructible<false, _Ap[_Np]> 2121 : public is_constructible<typename remove_all_extents<_Ap>::type> 2122 {}; 2123 2124// Otherwise array types are not constructible by this syntax 2125 2126template <class _Ap, size_t _Np, class ..._Args> 2127struct __is_constructible<false, _Ap[_Np], _Args...> 2128 : public false_type 2129 {}; 2130 2131// Incomplete array types are not constructible 2132 2133template <class _Ap, class ..._Args> 2134struct __is_constructible<false, _Ap[], _Args...> 2135 : public false_type 2136 {}; 2137 2138#else // _LIBCPP_HAS_NO_VARIADICS 2139 2140// template <class T> struct is_constructible0; 2141 2142// main is_constructible0 test 2143 2144template <class _Tp> 2145decltype((_Tp(), true_type())) 2146__is_constructible0_test(_Tp&); 2147 2148false_type 2149__is_constructible0_test(__any); 2150 2151template <class _Tp, class _A0> 2152decltype((_Tp(_VSTD::declval<_A0>()), true_type())) 2153__is_constructible1_test(_Tp&, _A0&); 2154 2155template <class _A0> 2156false_type 2157__is_constructible1_test(__any, _A0&); 2158 2159template <class _Tp, class _A0, class _A1> 2160decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) 2161__is_constructible2_test(_Tp&, _A0&, _A1&); 2162 2163template <class _A0, class _A1> 2164false_type 2165__is_constructible2_test(__any, _A0&, _A1&); 2166 2167template <bool, class _Tp> 2168struct __is_constructible0_imp // false, _Tp is not a scalar 2169 : public common_type 2170 < 2171 decltype(__is_constructible0_test(declval<_Tp&>())) 2172 >::type 2173 {}; 2174 2175template <bool, class _Tp, class _A0> 2176struct __is_constructible1_imp // false, _Tp is not a scalar 2177 : public common_type 2178 < 2179 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) 2180 >::type 2181 {}; 2182 2183template <bool, class _Tp, class _A0, class _A1> 2184struct __is_constructible2_imp // false, _Tp is not a scalar 2185 : public common_type 2186 < 2187 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) 2188 >::type 2189 {}; 2190 2191// handle scalars and reference types 2192 2193// Scalars are default constructible, references are not 2194 2195template <class _Tp> 2196struct __is_constructible0_imp<true, _Tp> 2197 : public is_scalar<_Tp> 2198 {}; 2199 2200template <class _Tp, class _A0> 2201struct __is_constructible1_imp<true, _Tp, _A0> 2202 : public is_convertible<_A0, _Tp> 2203 {}; 2204 2205template <class _Tp, class _A0, class _A1> 2206struct __is_constructible2_imp<true, _Tp, _A0, _A1> 2207 : public false_type 2208 {}; 2209 2210// Treat scalars and reference types separately 2211 2212template <bool, class _Tp> 2213struct __is_constructible0_void_check 2214 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2215 _Tp> 2216 {}; 2217 2218template <bool, class _Tp, class _A0> 2219struct __is_constructible1_void_check 2220 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2221 _Tp, _A0> 2222 {}; 2223 2224template <bool, class _Tp, class _A0, class _A1> 2225struct __is_constructible2_void_check 2226 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2227 _Tp, _A0, _A1> 2228 {}; 2229 2230// If any of T or Args is void, is_constructible should be false 2231 2232template <class _Tp> 2233struct __is_constructible0_void_check<true, _Tp> 2234 : public false_type 2235 {}; 2236 2237template <class _Tp, class _A0> 2238struct __is_constructible1_void_check<true, _Tp, _A0> 2239 : public false_type 2240 {}; 2241 2242template <class _Tp, class _A0, class _A1> 2243struct __is_constructible2_void_check<true, _Tp, _A0, _A1> 2244 : public false_type 2245 {}; 2246 2247// is_constructible entry point 2248 2249namespace __is_construct 2250{ 2251 2252struct __nat {}; 2253 2254} 2255 2256template <class _Tp, class _A0 = __is_construct::__nat, 2257 class _A1 = __is_construct::__nat> 2258struct _LIBCPP_TYPE_VIS_ONLY is_constructible 2259 : public __is_constructible2_void_check<is_void<_Tp>::value 2260 || is_abstract<_Tp>::value 2261 || is_function<_Tp>::value 2262 || is_void<_A0>::value 2263 || is_void<_A1>::value, 2264 _Tp, _A0, _A1> 2265 {}; 2266 2267template <class _Tp> 2268struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> 2269 : public __is_constructible0_void_check<is_void<_Tp>::value 2270 || is_abstract<_Tp>::value 2271 || is_function<_Tp>::value, 2272 _Tp> 2273 {}; 2274 2275template <class _Tp, class _A0> 2276struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat> 2277 : public __is_constructible1_void_check<is_void<_Tp>::value 2278 || is_abstract<_Tp>::value 2279 || is_function<_Tp>::value 2280 || is_void<_A0>::value, 2281 _Tp, _A0> 2282 {}; 2283 2284// Array types are default constructible if their element type 2285// is default constructible 2286 2287template <class _Ap, size_t _Np> 2288struct __is_constructible0_imp<false, _Ap[_Np]> 2289 : public is_constructible<typename remove_all_extents<_Ap>::type> 2290 {}; 2291 2292template <class _Ap, size_t _Np, class _A0> 2293struct __is_constructible1_imp<false, _Ap[_Np], _A0> 2294 : public false_type 2295 {}; 2296 2297template <class _Ap, size_t _Np, class _A0, class _A1> 2298struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1> 2299 : public false_type 2300 {}; 2301 2302// Incomplete array types are not constructible 2303 2304template <class _Ap> 2305struct __is_constructible0_imp<false, _Ap[]> 2306 : public false_type 2307 {}; 2308 2309template <class _Ap, class _A0> 2310struct __is_constructible1_imp<false, _Ap[], _A0> 2311 : public false_type 2312 {}; 2313 2314template <class _Ap, class _A0, class _A1> 2315struct __is_constructible2_imp<false, _Ap[], _A0, _A1> 2316 : public false_type 2317 {}; 2318 2319#endif // _LIBCPP_HAS_NO_VARIADICS 2320 2321// is_default_constructible 2322 2323template <class _Tp> 2324struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible 2325 : public is_constructible<_Tp> 2326 {}; 2327 2328// is_copy_constructible 2329 2330template <class _Tp> 2331struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible 2332 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2333 {}; 2334 2335// is_move_constructible 2336 2337template <class _Tp> 2338struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible 2339#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2340 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2341#else 2342 : public is_copy_constructible<_Tp> 2343#endif 2344 {}; 2345 2346// is_trivially_constructible 2347 2348#ifndef _LIBCPP_HAS_NO_VARIADICS 2349 2350#if __has_feature(is_trivially_constructible) 2351 2352template <class _Tp, class... _Args> 2353struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2354 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> 2355{ 2356}; 2357 2358#else // !__has_feature(is_trivially_constructible) 2359 2360template <class _Tp, class... _Args> 2361struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2362 : false_type 2363{ 2364}; 2365 2366template <class _Tp> 2367struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> 2368#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2369 : integral_constant<bool, __has_trivial_constructor(_Tp)> 2370#else 2371 : integral_constant<bool, is_scalar<_Tp>::value> 2372#endif 2373{ 2374}; 2375 2376template <class _Tp> 2377#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2378struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&> 2379#else 2380struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp> 2381#endif 2382 : integral_constant<bool, is_scalar<_Tp>::value> 2383{ 2384}; 2385 2386template <class _Tp> 2387struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&> 2388 : integral_constant<bool, is_scalar<_Tp>::value> 2389{ 2390}; 2391 2392template <class _Tp> 2393struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&> 2394 : integral_constant<bool, is_scalar<_Tp>::value> 2395{ 2396}; 2397 2398#endif // !__has_feature(is_trivially_constructible) 2399 2400#else // _LIBCPP_HAS_NO_VARIADICS 2401 2402template <class _Tp, class _A0 = __is_construct::__nat, 2403 class _A1 = __is_construct::__nat> 2404struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible 2405 : false_type 2406{ 2407}; 2408 2409#if __has_feature(is_trivially_constructible) 2410 2411template <class _Tp> 2412struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, 2413 __is_construct::__nat> 2414 : integral_constant<bool, __is_trivially_constructible(_Tp)> 2415{ 2416}; 2417 2418template <class _Tp> 2419struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, 2420 __is_construct::__nat> 2421 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)> 2422{ 2423}; 2424 2425template <class _Tp> 2426struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, 2427 __is_construct::__nat> 2428 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)> 2429{ 2430}; 2431 2432template <class _Tp> 2433struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, 2434 __is_construct::__nat> 2435 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)> 2436{ 2437}; 2438 2439#else // !__has_feature(is_trivially_constructible) 2440 2441template <class _Tp> 2442struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, 2443 __is_construct::__nat> 2444 : integral_constant<bool, is_scalar<_Tp>::value> 2445{ 2446}; 2447 2448template <class _Tp> 2449struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, 2450 __is_construct::__nat> 2451 : integral_constant<bool, is_scalar<_Tp>::value> 2452{ 2453}; 2454 2455template <class _Tp> 2456struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, 2457 __is_construct::__nat> 2458 : integral_constant<bool, is_scalar<_Tp>::value> 2459{ 2460}; 2461 2462template <class _Tp> 2463struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, 2464 __is_construct::__nat> 2465 : integral_constant<bool, is_scalar<_Tp>::value> 2466{ 2467}; 2468 2469#endif // !__has_feature(is_trivially_constructible) 2470 2471#endif // _LIBCPP_HAS_NO_VARIADICS 2472 2473// is_trivially_default_constructible 2474 2475template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible 2476 : public is_trivially_constructible<_Tp> 2477 {}; 2478 2479// is_trivially_copy_constructible 2480 2481template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible 2482 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> 2483 {}; 2484 2485// is_trivially_move_constructible 2486 2487template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible 2488#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2489 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2490#else 2491 : public is_trivially_copy_constructible<_Tp> 2492#endif 2493 {}; 2494 2495// is_trivially_assignable 2496 2497#if __has_feature(is_trivially_constructible) 2498 2499template <class _Tp, class _Arg> 2500struct is_trivially_assignable 2501 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> 2502{ 2503}; 2504 2505#else // !__has_feature(is_trivially_constructible) 2506 2507template <class _Tp, class _Arg> 2508struct is_trivially_assignable 2509 : public false_type {}; 2510 2511template <class _Tp> 2512struct is_trivially_assignable<_Tp&, _Tp> 2513 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2514 2515template <class _Tp> 2516struct is_trivially_assignable<_Tp&, _Tp&> 2517 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2518 2519template <class _Tp> 2520struct is_trivially_assignable<_Tp&, const _Tp&> 2521 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2522 2523#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2524 2525template <class _Tp> 2526struct is_trivially_assignable<_Tp&, _Tp&&> 2527 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2528 2529#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2530 2531#endif // !__has_feature(is_trivially_constructible) 2532 2533// is_trivially_copy_assignable 2534 2535template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable 2536 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2537 const typename add_lvalue_reference<_Tp>::type> 2538 {}; 2539 2540// is_trivially_move_assignable 2541 2542template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable 2543 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2544#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2545 typename add_rvalue_reference<_Tp>::type> 2546#else 2547 typename add_lvalue_reference<_Tp>::type> 2548#endif 2549 {}; 2550 2551// is_trivially_destructible 2552 2553#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2554 2555template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible 2556 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {}; 2557 2558#else // _LIBCPP_HAS_TYPE_TRAITS 2559 2560template <class _Tp> struct __libcpp_trivial_destructor 2561 : public integral_constant<bool, is_scalar<_Tp>::value || 2562 is_reference<_Tp>::value> {}; 2563 2564template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible 2565 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; 2566 2567#endif // _LIBCPP_HAS_TYPE_TRAITS 2568 2569// is_nothrow_constructible 2570 2571#if 0 2572template <class _Tp, class... _Args> 2573struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2574 : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))> 2575{ 2576}; 2577 2578#else 2579 2580#ifndef _LIBCPP_HAS_NO_VARIADICS 2581 2582#if __has_feature(cxx_noexcept) 2583 2584template <bool, class _Tp, class... _Args> struct __is_nothrow_constructible; 2585 2586template <class _Tp, class... _Args> 2587struct __is_nothrow_constructible<true, _Tp, _Args...> 2588 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 2589{ 2590}; 2591 2592template <class _Tp, class... _Args> 2593struct __is_nothrow_constructible<false, _Tp, _Args...> 2594 : public false_type 2595{ 2596}; 2597 2598template <class _Tp, class... _Args> 2599struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2600 : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...> 2601{ 2602}; 2603 2604template <class _Tp, size_t _Ns> 2605struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> 2606 : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp> 2607{ 2608}; 2609 2610#else // __has_feature(cxx_noexcept) 2611 2612template <class _Tp, class... _Args> 2613struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2614 : false_type 2615{ 2616}; 2617 2618template <class _Tp> 2619struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> 2620#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2621 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2622#else 2623 : integral_constant<bool, is_scalar<_Tp>::value> 2624#endif 2625{ 2626}; 2627 2628template <class _Tp> 2629#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2630struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> 2631#else 2632struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> 2633#endif 2634#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2635 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2636#else 2637 : integral_constant<bool, is_scalar<_Tp>::value> 2638#endif 2639{ 2640}; 2641 2642template <class _Tp> 2643struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> 2644#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2645 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2646#else 2647 : integral_constant<bool, is_scalar<_Tp>::value> 2648#endif 2649{ 2650}; 2651 2652template <class _Tp> 2653struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> 2654#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2655 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2656#else 2657 : integral_constant<bool, is_scalar<_Tp>::value> 2658#endif 2659{ 2660}; 2661 2662#endif // __has_feature(cxx_noexcept) 2663 2664#else // _LIBCPP_HAS_NO_VARIADICS 2665 2666template <class _Tp, class _A0 = __is_construct::__nat, 2667 class _A1 = __is_construct::__nat> 2668struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible 2669 : false_type 2670{ 2671}; 2672 2673template <class _Tp> 2674struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat, 2675 __is_construct::__nat> 2676#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2677 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2678#else 2679 : integral_constant<bool, is_scalar<_Tp>::value> 2680#endif 2681{ 2682}; 2683 2684template <class _Tp> 2685struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, 2686 __is_construct::__nat> 2687#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2688 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2689#else 2690 : integral_constant<bool, is_scalar<_Tp>::value> 2691#endif 2692{ 2693}; 2694 2695template <class _Tp> 2696struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, 2697 __is_construct::__nat> 2698#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2699 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2700#else 2701 : integral_constant<bool, is_scalar<_Tp>::value> 2702#endif 2703{ 2704}; 2705 2706template <class _Tp> 2707struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, 2708 __is_construct::__nat> 2709#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2710 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2711#else 2712 : integral_constant<bool, is_scalar<_Tp>::value> 2713#endif 2714{ 2715}; 2716 2717#endif // _LIBCPP_HAS_NO_VARIADICS 2718#endif // __has_feature(is_nothrow_constructible) 2719 2720// is_nothrow_default_constructible 2721 2722template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible 2723 : public is_nothrow_constructible<_Tp> 2724 {}; 2725 2726// is_nothrow_copy_constructible 2727 2728template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible 2729 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2730 {}; 2731 2732// is_nothrow_move_constructible 2733 2734template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible 2735#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2736 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2737#else 2738 : public is_nothrow_copy_constructible<_Tp> 2739#endif 2740 {}; 2741 2742// is_nothrow_assignable 2743 2744#if __has_feature(cxx_noexcept) 2745 2746template <bool, class _Tp, class _Arg> struct __is_nothrow_assignable; 2747 2748template <class _Tp, class _Arg> 2749struct __is_nothrow_assignable<false, _Tp, _Arg> 2750 : public false_type 2751{ 2752}; 2753 2754template <class _Tp, class _Arg> 2755struct __is_nothrow_assignable<true, _Tp, _Arg> 2756 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > 2757{ 2758}; 2759 2760template <class _Tp, class _Arg> 2761struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable 2762 : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> 2763{ 2764}; 2765 2766#else // __has_feature(cxx_noexcept) 2767 2768template <class _Tp, class _Arg> 2769struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable 2770 : public false_type {}; 2771 2772template <class _Tp> 2773struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> 2774#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2775 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2776#else 2777 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2778#endif 2779 2780template <class _Tp> 2781struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&> 2782#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2783 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2784#else 2785 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2786#endif 2787 2788template <class _Tp> 2789struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> 2790#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2791 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2792#else 2793 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2794#endif 2795 2796#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2797 2798template <class _Tp> 2799struct is_nothrow_assignable<_Tp&, _Tp&&> 2800#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2801 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2802#else 2803 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2804#endif 2805 2806#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2807 2808#endif // __has_feature(cxx_noexcept) 2809 2810// is_nothrow_copy_assignable 2811 2812template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable 2813 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2814 const typename add_lvalue_reference<_Tp>::type> 2815 {}; 2816 2817// is_nothrow_move_assignable 2818 2819template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable 2820 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2821#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2822 typename add_rvalue_reference<_Tp>::type> 2823#else 2824 typename add_lvalue_reference<_Tp>::type> 2825#endif 2826 {}; 2827 2828// is_nothrow_destructible 2829 2830#if __has_feature(cxx_noexcept) 2831 2832template <bool, class _Tp> struct __is_nothrow_destructible; 2833 2834template <class _Tp> 2835struct __is_nothrow_destructible<false, _Tp> 2836 : public false_type 2837{ 2838}; 2839 2840template <class _Tp> 2841struct __is_nothrow_destructible<true, _Tp> 2842 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > 2843{ 2844}; 2845 2846template <class _Tp> 2847struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible 2848 : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> 2849{ 2850}; 2851 2852template <class _Tp, size_t _Ns> 2853struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]> 2854 : public is_nothrow_destructible<_Tp> 2855{ 2856}; 2857 2858template <class _Tp> 2859struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&> 2860 : public true_type 2861{ 2862}; 2863 2864#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2865 2866template <class _Tp> 2867struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&> 2868 : public true_type 2869{ 2870}; 2871 2872#endif 2873 2874#else 2875 2876template <class _Tp> struct __libcpp_nothrow_destructor 2877 : public integral_constant<bool, is_scalar<_Tp>::value || 2878 is_reference<_Tp>::value> {}; 2879 2880template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible 2881 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; 2882 2883#endif 2884 2885// is_pod 2886 2887#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2888 2889template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod 2890 : public integral_constant<bool, __is_pod(_Tp)> {}; 2891 2892#else // _LIBCPP_HAS_TYPE_TRAITS 2893 2894template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod 2895 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && 2896 is_trivially_copy_constructible<_Tp>::value && 2897 is_trivially_copy_assignable<_Tp>::value && 2898 is_trivially_destructible<_Tp>::value> {}; 2899 2900#endif // _LIBCPP_HAS_TYPE_TRAITS 2901 2902// is_literal_type; 2903 2904template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type 2905#if __has_feature(is_literal) 2906 : public integral_constant<bool, __is_literal(_Tp)> 2907#else 2908 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value || 2909 is_reference<typename remove_all_extents<_Tp>::type>::value> 2910#endif 2911 {}; 2912 2913// is_standard_layout; 2914 2915template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout 2916#if __has_feature(is_standard_layout) 2917 : public integral_constant<bool, __is_standard_layout(_Tp)> 2918#else 2919 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2920#endif 2921 {}; 2922 2923// is_trivially_copyable; 2924 2925template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable 2926#if __has_feature(is_trivially_copyable) 2927 : public integral_constant<bool, __is_trivially_copyable(_Tp)> 2928#else 2929 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2930#endif 2931 {}; 2932 2933// is_trivial; 2934 2935template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial 2936#if __has_feature(is_trivial) 2937 : public integral_constant<bool, __is_trivial(_Tp)> 2938#else 2939 : integral_constant<bool, is_trivially_copyable<_Tp>::value && 2940 is_trivially_default_constructible<_Tp>::value> 2941#endif 2942 {}; 2943 2944#ifndef _LIBCPP_HAS_NO_VARIADICS 2945 2946// Check for complete types 2947 2948template <class ..._Tp> struct __check_complete; 2949 2950template <> 2951struct __check_complete<> 2952{ 2953}; 2954 2955template <class _Hp, class _T0, class ..._Tp> 2956struct __check_complete<_Hp, _T0, _Tp...> 2957 : private __check_complete<_Hp>, 2958 private __check_complete<_T0, _Tp...> 2959{ 2960}; 2961 2962template <class _Hp> 2963struct __check_complete<_Hp, _Hp> 2964 : private __check_complete<_Hp> 2965{ 2966}; 2967 2968template <class _Tp> 2969struct __check_complete<_Tp> 2970{ 2971 static_assert(sizeof(_Tp) > 0, "Type must be complete."); 2972}; 2973 2974template <class _Tp> 2975struct __check_complete<_Tp&> 2976 : private __check_complete<_Tp> 2977{ 2978}; 2979 2980template <class _Tp> 2981struct __check_complete<_Tp&&> 2982 : private __check_complete<_Tp> 2983{ 2984}; 2985 2986template <class _Rp, class ..._Param> 2987struct __check_complete<_Rp (*)(_Param...)> 2988 : private __check_complete<_Rp> 2989{ 2990}; 2991 2992template <class ..._Param> 2993struct __check_complete<void (*)(_Param...)> 2994{ 2995}; 2996 2997template <class _Rp, class ..._Param> 2998struct __check_complete<_Rp (_Param...)> 2999 : private __check_complete<_Rp> 3000{ 3001}; 3002 3003template <class ..._Param> 3004struct __check_complete<void (_Param...)> 3005{ 3006}; 3007 3008template <class _Rp, class _Class, class ..._Param> 3009struct __check_complete<_Rp (_Class::*)(_Param...)> 3010 : private __check_complete<_Class> 3011{ 3012}; 3013 3014template <class _Rp, class _Class, class ..._Param> 3015struct __check_complete<_Rp (_Class::*)(_Param...) const> 3016 : private __check_complete<_Class> 3017{ 3018}; 3019 3020template <class _Rp, class _Class, class ..._Param> 3021struct __check_complete<_Rp (_Class::*)(_Param...) volatile> 3022 : private __check_complete<_Class> 3023{ 3024}; 3025 3026template <class _Rp, class _Class, class ..._Param> 3027struct __check_complete<_Rp (_Class::*)(_Param...) const volatile> 3028 : private __check_complete<_Class> 3029{ 3030}; 3031 3032#if __has_feature(cxx_reference_qualified_functions) 3033 3034template <class _Rp, class _Class, class ..._Param> 3035struct __check_complete<_Rp (_Class::*)(_Param...) &> 3036 : private __check_complete<_Class> 3037{ 3038}; 3039 3040template <class _Rp, class _Class, class ..._Param> 3041struct __check_complete<_Rp (_Class::*)(_Param...) const&> 3042 : private __check_complete<_Class> 3043{ 3044}; 3045 3046template <class _Rp, class _Class, class ..._Param> 3047struct __check_complete<_Rp (_Class::*)(_Param...) volatile&> 3048 : private __check_complete<_Class> 3049{ 3050}; 3051 3052template <class _Rp, class _Class, class ..._Param> 3053struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&> 3054 : private __check_complete<_Class> 3055{ 3056}; 3057 3058template <class _Rp, class _Class, class ..._Param> 3059struct __check_complete<_Rp (_Class::*)(_Param...) &&> 3060 : private __check_complete<_Class> 3061{ 3062}; 3063 3064template <class _Rp, class _Class, class ..._Param> 3065struct __check_complete<_Rp (_Class::*)(_Param...) const&&> 3066 : private __check_complete<_Class> 3067{ 3068}; 3069 3070template <class _Rp, class _Class, class ..._Param> 3071struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&> 3072 : private __check_complete<_Class> 3073{ 3074}; 3075 3076template <class _Rp, class _Class, class ..._Param> 3077struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&> 3078 : private __check_complete<_Class> 3079{ 3080}; 3081 3082#endif 3083 3084template <class _Rp, class _Class> 3085struct __check_complete<_Rp _Class::*> 3086 : private __check_complete<_Class> 3087{ 3088}; 3089 3090// __invoke forward declarations 3091 3092// fall back - none of the bullets 3093 3094template <class ..._Args> 3095auto 3096__invoke(__any, _Args&& ...__args) 3097 -> __nat; 3098 3099// bullets 1 and 2 3100 3101template <class _Fp, class _A0, class ..._Args, 3102 class = typename enable_if 3103 < 3104 is_member_function_pointer<typename remove_reference<_Fp>::type>::value && 3105 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3106 typename remove_reference<_A0>::type>::value 3107 >::type 3108 > 3109_LIBCPP_INLINE_VISIBILITY 3110auto 3111__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3112 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)); 3113 3114template <class _Fp, class _A0, class ..._Args, 3115 class = typename enable_if 3116 < 3117 is_member_function_pointer<typename remove_reference<_Fp>::type>::value && 3118 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3119 typename remove_reference<_A0>::type>::value 3120 >::type 3121 > 3122_LIBCPP_INLINE_VISIBILITY 3123auto 3124__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 3125 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)); 3126 3127// bullets 3 and 4 3128 3129template <class _Fp, class _A0, 3130 class = typename enable_if 3131 < 3132 is_member_object_pointer<typename remove_reference<_Fp>::type>::value && 3133 is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3134 typename remove_reference<_A0>::type>::value 3135 >::type 3136 > 3137_LIBCPP_INLINE_VISIBILITY 3138auto 3139__invoke(_Fp&& __f, _A0&& __a0) 3140 -> decltype(_VSTD::forward<_A0>(__a0).*__f); 3141 3142template <class _Fp, class _A0, 3143 class = typename enable_if 3144 < 3145 is_member_object_pointer<typename remove_reference<_Fp>::type>::value && 3146 !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType, 3147 typename remove_reference<_A0>::type>::value 3148 >::type 3149 > 3150_LIBCPP_INLINE_VISIBILITY 3151auto 3152__invoke(_Fp&& __f, _A0&& __a0) 3153 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f); 3154 3155// bullet 5 3156 3157template <class _Fp, class ..._Args> 3158_LIBCPP_INLINE_VISIBILITY 3159auto 3160__invoke(_Fp&& __f, _Args&& ...__args) 3161 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)); 3162 3163// __invokable 3164 3165template <class _Fp, class ..._Args> 3166struct __invokable_imp 3167 : private __check_complete<_Fp> 3168{ 3169 typedef decltype( 3170 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...) 3171 ) type; 3172 static const bool value = !is_same<type, __nat>::value; 3173}; 3174 3175template <class _Fp, class ..._Args> 3176struct __invokable 3177 : public integral_constant<bool, 3178 __invokable_imp<_Fp, _Args...>::value> 3179{ 3180}; 3181 3182// __invoke_of 3183 3184template <bool _Invokable, class _Fp, class ..._Args> 3185struct __invoke_of_imp // false 3186{ 3187}; 3188 3189template <class _Fp, class ..._Args> 3190struct __invoke_of_imp<true, _Fp, _Args...> 3191{ 3192 typedef typename __invokable_imp<_Fp, _Args...>::type type; 3193}; 3194 3195template <class _Fp, class ..._Args> 3196struct __invoke_of 3197 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...> 3198{ 3199}; 3200 3201template <class _Fp, class ..._Args> 3202class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)> 3203 : public __invoke_of<_Fp, _Args...> 3204{ 3205}; 3206 3207#if _LIBCPP_STD_VER > 11 3208template <class _Tp> using result_of_t = typename result_of<_Tp>::type; 3209#endif 3210 3211#endif // _LIBCPP_HAS_NO_VARIADICS 3212 3213template <class _Tp> 3214inline _LIBCPP_INLINE_VISIBILITY 3215#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 3216typename enable_if 3217< 3218 is_move_constructible<_Tp>::value && 3219 is_move_assignable<_Tp>::value 3220>::type 3221#else 3222void 3223#endif 3224swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && 3225 is_nothrow_move_assignable<_Tp>::value) 3226{ 3227 _Tp __t(_VSTD::move(__x)); 3228 __x = _VSTD::move(__y); 3229 __y = _VSTD::move(__t); 3230} 3231 3232template <class _ForwardIterator1, class _ForwardIterator2> 3233inline _LIBCPP_INLINE_VISIBILITY 3234void 3235iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) 3236 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) 3237 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), 3238 *_VSTD::declval<_ForwardIterator2>()))) 3239{ 3240 swap(*__a, *__b); 3241} 3242 3243// __swappable 3244 3245namespace __detail 3246{ 3247 3248using _VSTD::swap; 3249__nat swap(__any, __any); 3250 3251template <class _Tp> 3252struct __swappable 3253{ 3254 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type; 3255 static const bool value = !is_same<type, __nat>::value; 3256}; 3257 3258} // __detail 3259 3260template <class _Tp> 3261struct __is_swappable 3262 : public integral_constant<bool, __detail::__swappable<_Tp>::value> 3263{ 3264}; 3265 3266#if __has_feature(cxx_noexcept) 3267 3268template <bool, class _Tp> 3269struct __is_nothrow_swappable_imp 3270 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(), 3271 _VSTD::declval<_Tp&>()))> 3272{ 3273}; 3274 3275template <class _Tp> 3276struct __is_nothrow_swappable_imp<false, _Tp> 3277 : public false_type 3278{ 3279}; 3280 3281template <class _Tp> 3282struct __is_nothrow_swappable 3283 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp> 3284{ 3285}; 3286 3287#else // __has_feature(cxx_noexcept) 3288 3289template <class _Tp> 3290struct __is_nothrow_swappable 3291 : public false_type 3292{ 3293}; 3294 3295#endif // __has_feature(cxx_noexcept) 3296 3297#ifdef _LIBCXX_UNDERLYING_TYPE 3298 3299template <class _Tp> 3300struct underlying_type 3301{ 3302 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; 3303}; 3304 3305#if _LIBCPP_STD_VER > 11 3306template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; 3307#endif 3308 3309#else // _LIBCXX_UNDERLYING_TYPE 3310 3311template <class _Tp, bool _Support = false> 3312struct underlying_type 3313{ 3314 static_assert(_Support, "The underyling_type trait requires compiler " 3315 "support. Either no such support exists or " 3316 "libc++ does not know how to use it."); 3317}; 3318 3319#endif // _LIBCXX_UNDERLYING_TYPE 3320 3321#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 3322 3323template <class _Tp> 3324struct __has_operator_addressof_imp 3325{ 3326 template <class> 3327 static auto __test(__any) -> false_type; 3328 template <class _Up> 3329 static auto __test(_Up* __u) 3330 -> typename __select_2nd<decltype(__u->operator&()), true_type>::type; 3331 3332 static const bool value = decltype(__test<_Tp>(nullptr))::value; 3333}; 3334 3335template <class _Tp> 3336struct __has_operator_addressof 3337 : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value> 3338{}; 3339 3340#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 3341 3342_LIBCPP_END_NAMESPACE_STD 3343 3344#endif // _LIBCPP_TYPE_TRAITS 3345