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