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 __lx[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 620namespace __is_base_of_imp 621{ 622template <class _Tp> 623struct _Dst 624{ 625 _Dst(const volatile _Tp &); 626}; 627template <class _Tp> 628struct _Src 629{ 630 operator const volatile _Tp &(); 631 template <class _Up> operator const _Dst<_Up> &(); 632}; 633template <size_t> struct __one { typedef char type; }; 634template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int); 635template <class _Bp, class _Dp> __two __test(...); 636} 637 638template <class _Bp, class _Dp> 639struct _LIBCPP_VISIBLE is_base_of 640 : public integral_constant<bool, is_class<_Bp>::value && 641 sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; 642 643#endif // __has_feature(is_base_of) 644 645// is_convertible 646 647#if __has_feature(is_convertible_to) 648 649template <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible 650 : public integral_constant<bool, __is_convertible_to(_T1, _T2) && 651 !is_abstract<_T2>::value> {}; 652 653#else // __has_feature(is_convertible_to) 654 655namespace __is_convertible_imp 656{ 657template <class _Tp> char __test(_Tp); 658template <class _Tp> __two __test(...); 659#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 660template <class _Tp> _Tp&& __source(); 661#else 662template <class _Tp> typename remove_reference<_Tp>::type& __source(); 663#endif 664 665template <class _Tp, bool _IsArray = is_array<_Tp>::value, 666 bool _IsFunction = is_function<_Tp>::value, 667 bool _IsVoid = is_void<_Tp>::value> 668 struct __is_array_function_or_void {enum {value = 0};}; 669template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; 670template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; 671template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; 672} 673 674template <class _Tp, 675 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> 676struct __is_convertible_check 677{ 678 static const size_t __v = 0; 679}; 680 681template <class _Tp> 682struct __is_convertible_check<_Tp, 0> 683{ 684 static const size_t __v = sizeof(_Tp); 685}; 686 687template <class _T1, class _T2, 688 unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, 689 unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> 690struct __is_convertible 691 : public integral_constant<bool, 692#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 693 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 694#else 695 sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 696 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value 697 && (!is_const<typename remove_reference<_T2>::type>::value 698 || is_volatile<typename remove_reference<_T2>::type>::value) 699 && (is_same<typename remove_cv<_T1>::type, 700 typename remove_cv<typename remove_reference<_T2>::type>::type>::value 701 || is_base_of<typename remove_reference<_T2>::type, _T1>::value)) 702#endif 703 > 704{}; 705 706template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {}; 707 708template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {}; 709#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 710template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {}; 711template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {}; 712template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {}; 713template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {}; 714#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 715 716template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0> 717 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {}; 718 719template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0> 720 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {}; 721 722template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0> 723 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {}; 724 725template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0> 726 : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {}; 727 728template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {}; 729#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 730template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {}; 731#endif 732template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {}; 733template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {}; 734template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {}; 735template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {}; 736template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {}; 737 738template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {}; 739 740template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; 741template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; 742template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; 743template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; 744 745template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; 746template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; 747template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; 748template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; 749 750template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; 751template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; 752template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; 753template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; 754 755template <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible 756 : public __is_convertible<_T1, _T2> 757{ 758 static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; 759 static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; 760}; 761 762#endif // __has_feature(is_convertible_to) 763 764// is_empty 765 766#if __has_feature(is_empty) 767 768template <class _Tp> 769struct _LIBCPP_VISIBLE is_empty 770 : public integral_constant<bool, __is_empty(_Tp)> {}; 771 772#else // __has_feature(is_empty) 773 774template <class _Tp> 775struct __is_empty1 776 : public _Tp 777{ 778 double __lx; 779}; 780 781struct __is_empty2 782{ 783 double __lx; 784}; 785 786template <class _Tp, bool = is_class<_Tp>::value> 787struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; 788 789template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; 790 791template <class _Tp> struct _LIBCPP_VISIBLE is_empty : public __libcpp_empty<_Tp> {}; 792 793#endif // __has_feature(is_empty) 794 795// is_polymorphic 796 797#if __has_feature(is_polymorphic) 798 799template <class _Tp> 800struct _LIBCPP_VISIBLE is_polymorphic 801 : public integral_constant<bool, __is_polymorphic(_Tp)> {}; 802 803#else 804 805template <class _Tp> struct __is_polymorphic1 : public _Tp {}; 806template <class _Tp> struct __is_polymorphic2 : public _Tp {virtual ~__is_polymorphic2() throw();}; 807 808template <class _Tp, bool = is_class<_Tp>::value> 809struct __libcpp_polymorphic 810 : public integral_constant<bool, sizeof(__is_polymorphic1<_Tp>) == sizeof(__is_polymorphic2<_Tp>)> {}; 811 812template <class _Tp> struct __libcpp_polymorphic<_Tp, false> : public false_type {}; 813 814template <class _Tp> struct _LIBCPP_VISIBLE is_polymorphic 815 : public __libcpp_polymorphic<_Tp> {}; 816 817#endif // __has_feature(is_polymorphic) 818 819// has_virtual_destructor 820 821#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 822 823template <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor 824 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; 825 826#else // _LIBCPP_HAS_TYPE_TRAITS 827 828template <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor 829 : public false_type {}; 830 831#endif // _LIBCPP_HAS_TYPE_TRAITS 832 833// alignment_of 834 835template <class _Tp> struct __alignment_of {_Tp __lx;}; 836 837template <class _Tp> struct _LIBCPP_VISIBLE alignment_of 838 : public integral_constant<size_t, __alignof__(__alignment_of<typename remove_all_extents<_Tp>::type>)> {}; 839 840// aligned_storage 841 842template <class _Hp, class _Tp> 843struct __type_list 844{ 845 typedef _Hp _Head; 846 typedef _Tp _Tail; 847}; 848 849struct __nat 850{ 851#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 852 __nat() = delete; 853 __nat(const __nat&) = delete; 854 __nat& operator=(const __nat&) = delete; 855 ~__nat() = delete; 856#endif 857}; 858 859template <class _Tp> 860struct __align_type 861{ 862 static const size_t value = alignment_of<_Tp>::value; 863 typedef _Tp type; 864}; 865 866struct __struct_double {long double __lx;}; 867struct __struct_double4 {double __lx[4];}; 868 869typedef 870 __type_list<__align_type<unsigned char>, 871 __type_list<__align_type<unsigned short>, 872 __type_list<__align_type<unsigned int>, 873 __type_list<__align_type<unsigned long>, 874 __type_list<__align_type<unsigned long long>, 875 __type_list<__align_type<double>, 876 __type_list<__align_type<long double>, 877 __type_list<__align_type<__struct_double>, 878 __type_list<__align_type<__struct_double4>, 879 __type_list<__align_type<int*>, 880 __nat 881 > > > > > > > > > > __all_types; 882 883template <class _TL, size_t _Align> struct __find_pod; 884 885template <class _Hp, size_t _Align> 886struct __find_pod<__type_list<_Hp, __nat>, _Align> 887{ 888 typedef typename conditional< 889 _Align == _Hp::value, 890 typename _Hp::type, 891 void 892 >::type type; 893}; 894 895template <class _Hp, class _Tp, size_t _Align> 896struct __find_pod<__type_list<_Hp, _Tp>, _Align> 897{ 898 typedef typename conditional< 899 _Align == _Hp::value, 900 typename _Hp::type, 901 typename __find_pod<_Tp, _Align>::type 902 >::type type; 903}; 904 905template <class _TL, size_t _Len> struct __find_max_align; 906 907template <class _Hp, size_t _Len> 908struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; 909 910template <size_t _Len, size_t _A1, size_t _A2> 911struct __select_align 912{ 913private: 914 static const size_t __min = _A2 < _A1 ? _A2 : _A1; 915 static const size_t __max = _A1 < _A2 ? _A2 : _A1; 916public: 917 static const size_t value = _Len < __max ? __min : __max; 918}; 919 920template <class _Hp, class _Tp, size_t _Len> 921struct __find_max_align<__type_list<_Hp, _Tp>, _Len> 922 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; 923 924template <size_t _Len, const size_t _Align = __find_max_align<__all_types, _Len>::value> 925struct _LIBCPP_VISIBLE aligned_storage 926{ 927 typedef typename __find_pod<__all_types, _Align>::type _Aligner; 928 static_assert(!is_void<_Aligner>::value, ""); 929 union type 930 { 931 _Aligner __align; 932 unsigned char __data[_Len]; 933 }; 934}; 935 936#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ 937template <size_t _Len>\ 938struct _LIBCPP_VISIBLE aligned_storage<_Len, n>\ 939{\ 940 struct _ALIGNAS(n) type\ 941 {\ 942 unsigned char __lx[_Len];\ 943 };\ 944} 945 946_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); 947_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); 948_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); 949_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); 950_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); 951_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); 952_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); 953_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); 954_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); 955_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); 956_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); 957_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); 958_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); 959_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); 960// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000) 961#if !defined(_MSC_VER) 962_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); 963#endif // !_MSC_VER 964 965#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION 966 967// __promote 968 969template <class _A1, class _A2 = void, class _A3 = void, 970 bool = (is_arithmetic<_A1>::value || is_void<_A1>::value) && 971 (is_arithmetic<_A2>::value || is_void<_A2>::value) && 972 (is_arithmetic<_A3>::value || is_void<_A3>::value)> 973class __promote {}; 974 975template <class _A1, class _A2, class _A3> 976class __promote<_A1, _A2, _A3, true> 977{ 978private: 979 typedef typename __promote<_A1>::type __type1; 980 typedef typename __promote<_A2>::type __type2; 981 typedef typename __promote<_A3>::type __type3; 982public: 983 typedef decltype(__type1() + __type2() + __type3()) type; 984}; 985 986template <class _A1, class _A2> 987class __promote<_A1, _A2, void, true> 988{ 989private: 990 typedef typename __promote<_A1>::type __type1; 991 typedef typename __promote<_A2>::type __type2; 992public: 993 typedef decltype(__type1() + __type2()) type; 994}; 995 996template <class _A1> 997class __promote<_A1, void, void, true> 998{ 999public: 1000 typedef typename conditional<is_arithmetic<_A1>::value, 1001 typename conditional<is_integral<_A1>::value, double, _A1>::type, 1002 void 1003 >::type type; 1004}; 1005 1006#ifdef _LIBCPP_STORE_AS_OPTIMIZATION 1007 1008// __transform 1009 1010template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;}; 1011template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;}; 1012template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;}; 1013template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;}; 1014template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; 1015 1016#endif // _LIBCPP_STORE_AS_OPTIMIZATION 1017 1018// make_signed / make_unsigned 1019 1020typedef 1021 __type_list<signed char, 1022 __type_list<signed short, 1023 __type_list<signed int, 1024 __type_list<signed long, 1025 __type_list<signed long long, 1026 __nat 1027 > > > > > __signed_types; 1028 1029typedef 1030 __type_list<unsigned char, 1031 __type_list<unsigned short, 1032 __type_list<unsigned int, 1033 __type_list<unsigned long, 1034 __type_list<unsigned long long, 1035 __nat 1036 > > > > > __unsigned_types; 1037 1038template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; 1039 1040template <class _Hp, class _Tp, size_t _Size> 1041struct __find_first<__type_list<_Hp, _Tp>, _Size, true> 1042{ 1043 typedef _Hp type; 1044}; 1045 1046template <class _Hp, class _Tp, size_t _Size> 1047struct __find_first<__type_list<_Hp, _Tp>, _Size, false> 1048{ 1049 typedef typename __find_first<_Tp, _Size>::type type; 1050}; 1051 1052template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, 1053 bool = is_volatile<typename remove_reference<_Tp>::type>::value> 1054struct __apply_cv 1055{ 1056 typedef _Up type; 1057}; 1058 1059template <class _Tp, class _Up> 1060struct __apply_cv<_Tp, _Up, true, false> 1061{ 1062 typedef const _Up type; 1063}; 1064 1065template <class _Tp, class _Up> 1066struct __apply_cv<_Tp, _Up, false, true> 1067{ 1068 typedef volatile _Up type; 1069}; 1070 1071template <class _Tp, class _Up> 1072struct __apply_cv<_Tp, _Up, true, true> 1073{ 1074 typedef const volatile _Up type; 1075}; 1076 1077template <class _Tp, class _Up> 1078struct __apply_cv<_Tp&, _Up, false, false> 1079{ 1080 typedef _Up& type; 1081}; 1082 1083template <class _Tp, class _Up> 1084struct __apply_cv<_Tp&, _Up, true, false> 1085{ 1086 typedef const _Up& type; 1087}; 1088 1089template <class _Tp, class _Up> 1090struct __apply_cv<_Tp&, _Up, false, true> 1091{ 1092 typedef volatile _Up& type; 1093}; 1094 1095template <class _Tp, class _Up> 1096struct __apply_cv<_Tp&, _Up, true, true> 1097{ 1098 typedef const volatile _Up& type; 1099}; 1100 1101template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 1102struct __make_signed {}; 1103 1104template <class _Tp> 1105struct __make_signed<_Tp, true> 1106{ 1107 typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; 1108}; 1109 1110template <> struct __make_signed<bool, true> {}; 1111template <> struct __make_signed< signed short, true> {typedef short type;}; 1112template <> struct __make_signed<unsigned short, true> {typedef short type;}; 1113template <> struct __make_signed< signed int, true> {typedef int type;}; 1114template <> struct __make_signed<unsigned int, true> {typedef int type;}; 1115template <> struct __make_signed< signed long, true> {typedef long type;}; 1116template <> struct __make_signed<unsigned long, true> {typedef long type;}; 1117template <> struct __make_signed< signed long long, true> {typedef long long type;}; 1118template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; 1119 1120template <class _Tp> 1121struct _LIBCPP_VISIBLE make_signed 1122{ 1123 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; 1124}; 1125 1126template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> 1127struct __make_unsigned {}; 1128 1129template <class _Tp> 1130struct __make_unsigned<_Tp, true> 1131{ 1132 typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; 1133}; 1134 1135template <> struct __make_unsigned<bool, true> {}; 1136template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; 1137template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; 1138template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; 1139template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; 1140template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; 1141template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; 1142template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; 1143template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; 1144 1145template <class _Tp> 1146struct _LIBCPP_VISIBLE make_unsigned 1147{ 1148 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; 1149}; 1150 1151#ifdef _LIBCPP_HAS_NO_VARIADICS 1152 1153template <class _Tp, class _Up = void, class V = void> 1154struct _LIBCPP_VISIBLE common_type 1155{ 1156public: 1157 typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type; 1158}; 1159 1160template <class _Tp> 1161struct _LIBCPP_VISIBLE common_type<_Tp, void, void> 1162{ 1163public: 1164 typedef _Tp type; 1165}; 1166 1167template <class _Tp, class _Up> 1168struct _LIBCPP_VISIBLE common_type<_Tp, _Up, void> 1169{ 1170private: 1171#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1172 static _Tp&& __t(); 1173 static _Up&& __u(); 1174#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1175 static _Tp __t(); 1176 static _Up __u(); 1177#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1178public: 1179 typedef typename remove_reference<decltype(true ? __t() : __u())>::type type; 1180}; 1181 1182#else // _LIBCPP_HAS_NO_VARIADICS 1183 1184template <class ..._Tp> struct common_type; 1185 1186template <class _Tp> 1187struct _LIBCPP_VISIBLE common_type<_Tp> 1188{ 1189 typedef _Tp type; 1190}; 1191 1192template <class _Tp, class _Up> 1193struct _LIBCPP_VISIBLE common_type<_Tp, _Up> 1194{ 1195private: 1196 static _Tp&& __t(); 1197 static _Up&& __u(); 1198 static bool __f(); 1199public: 1200 typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type; 1201}; 1202 1203template <class _Tp, class _Up, class ..._Vp> 1204struct _LIBCPP_VISIBLE common_type<_Tp, _Up, _Vp...> 1205{ 1206 typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; 1207}; 1208 1209#endif // _LIBCPP_HAS_NO_VARIADICS 1210 1211// is_assignable 1212 1213template <class _Tp, class _Arg> 1214decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type())) 1215#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1216__is_assignable_test(_Tp&&, _Arg&&); 1217#else 1218__is_assignable_test(_Tp, _Arg&); 1219#endif 1220 1221template <class _Arg> 1222false_type 1223#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1224__is_assignable_test(__any, _Arg&&); 1225#else 1226__is_assignable_test(__any, _Arg&); 1227#endif 1228 1229template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> 1230struct __is_assignable_imp 1231 : public common_type 1232 < 1233 decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>())) 1234 >::type {}; 1235 1236template <class _Tp, class _Arg> 1237struct __is_assignable_imp<_Tp, _Arg, true> 1238 : public false_type 1239{ 1240}; 1241 1242template <class _Tp, class _Arg> 1243struct is_assignable 1244 : public __is_assignable_imp<_Tp, _Arg> {}; 1245 1246// is_copy_assignable 1247 1248template <class _Tp> struct _LIBCPP_VISIBLE is_copy_assignable 1249 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 1250 const typename add_lvalue_reference<_Tp>::type> {}; 1251 1252// is_move_assignable 1253 1254template <class _Tp> struct _LIBCPP_VISIBLE is_move_assignable 1255#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1256 : public is_assignable<typename add_lvalue_reference<_Tp>::type, 1257 const typename add_rvalue_reference<_Tp>::type> {}; 1258#else 1259 : public is_copy_assignable<_Tp> {}; 1260#endif 1261 1262// is_destructible 1263 1264template <class _Tp> 1265struct __destructible_test 1266{ 1267 _Tp __t; 1268}; 1269 1270template <class _Tp> 1271decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type())) 1272#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1273__is_destructible_test(_Tp&&); 1274#else 1275__is_destructible_test(_Tp&); 1276#endif 1277 1278false_type 1279__is_destructible_test(__any); 1280 1281template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value> 1282struct __destructible_imp 1283 : public common_type 1284 < 1285 decltype(__is_destructible_test(declval<_Tp>())) 1286 >::type {}; 1287 1288template <class _Tp> 1289struct __destructible_imp<_Tp, true> 1290 : public false_type {}; 1291 1292template <class _Tp> 1293struct is_destructible 1294 : public __destructible_imp<_Tp> {}; 1295 1296// move 1297 1298#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1299 1300template <class _Tp> 1301inline _LIBCPP_INLINE_VISIBILITY 1302typename remove_reference<_Tp>::type&& 1303move(_Tp&& __t) _NOEXCEPT 1304{ 1305 typedef typename remove_reference<_Tp>::type _Up; 1306 return static_cast<_Up&&>(__t); 1307} 1308 1309template <class _Tp> 1310inline _LIBCPP_INLINE_VISIBILITY 1311_Tp&& 1312forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT 1313{ 1314 return static_cast<_Tp&&>(__t); 1315} 1316 1317template <class _Tp> 1318inline _LIBCPP_INLINE_VISIBILITY 1319_Tp&& 1320forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT 1321{ 1322 static_assert(!std::is_lvalue_reference<_Tp>::value, 1323 "Can not forward an rvalue as an lvalue."); 1324 return static_cast<_Tp&&>(__t); 1325} 1326 1327#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1328 1329template <class _Tp> 1330inline _LIBCPP_INLINE_VISIBILITY 1331_Tp& 1332move(_Tp& __t) 1333{ 1334 return __t; 1335} 1336 1337template <class _Tp> 1338inline _LIBCPP_INLINE_VISIBILITY 1339const _Tp& 1340move(const _Tp& __t) 1341{ 1342 return __t; 1343} 1344 1345template <class _Tp> 1346inline _LIBCPP_INLINE_VISIBILITY 1347_Tp& 1348forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT 1349{ 1350 return __t; 1351} 1352 1353 1354template <class _Tp> 1355class __rv 1356{ 1357 typedef typename remove_reference<_Tp>::type _Trr; 1358 _Trr& t_; 1359public: 1360 _LIBCPP_INLINE_VISIBILITY 1361 _Trr* operator->() {return &t_;} 1362 _LIBCPP_INLINE_VISIBILITY 1363 explicit __rv(_Trr& __t) : t_(__t) {} 1364}; 1365 1366#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1367 1368template <class _Tp> 1369struct _LIBCPP_VISIBLE decay 1370{ 1371private: 1372 typedef typename remove_reference<_Tp>::type _Up; 1373public: 1374 typedef typename conditional 1375 < 1376 is_array<_Up>::value, 1377 typename remove_extent<_Up>::type*, 1378 typename conditional 1379 < 1380 is_function<_Up>::value, 1381 typename add_pointer<_Up>::type, 1382 typename remove_cv<_Up>::type 1383 >::type 1384 >::type type; 1385}; 1386 1387#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1388 1389template <class _Tp> 1390inline _LIBCPP_INLINE_VISIBILITY 1391typename decay<_Tp>::type 1392__decay_copy(_Tp&& __t) 1393{ 1394 return _VSTD::forward<_Tp>(__t); 1395} 1396 1397#else 1398 1399template <class _Tp> 1400inline _LIBCPP_INLINE_VISIBILITY 1401typename decay<_Tp>::type 1402__decay_copy(const _Tp& __t) 1403{ 1404 return _VSTD::forward<_Tp>(__t); 1405} 1406 1407#endif 1408 1409template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr> 1410struct __member_pointer_traits_imp 1411{ 1412}; 1413 1414#ifndef _LIBCPP_HAS_NO_VARIADICS 1415 1416template <class _Rp, class _Class, class ..._Param> 1417struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> 1418{ 1419 typedef _Class _ClassType; 1420 typedef _Rp _ReturnType; 1421}; 1422 1423template <class _Rp, class _Class, class ..._Param> 1424struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> 1425{ 1426 typedef _Class const _ClassType; 1427 typedef _Rp _ReturnType; 1428}; 1429 1430template <class _Rp, class _Class, class ..._Param> 1431struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> 1432{ 1433 typedef _Class volatile _ClassType; 1434 typedef _Rp _ReturnType; 1435}; 1436 1437template <class _Rp, class _Class, class ..._Param> 1438struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> 1439{ 1440 typedef _Class const volatile _ClassType; 1441 typedef _Rp _ReturnType; 1442}; 1443 1444#if __has_feature(cxx_reference_qualified_functions) 1445 1446template <class _Rp, class _Class, class ..._Param> 1447struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> 1448{ 1449 typedef _Class& _ClassType; 1450 typedef _Rp _ReturnType; 1451}; 1452 1453template <class _Rp, class _Class, class ..._Param> 1454struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> 1455{ 1456 typedef _Class const& _ClassType; 1457 typedef _Rp _ReturnType; 1458}; 1459 1460template <class _Rp, class _Class, class ..._Param> 1461struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> 1462{ 1463 typedef _Class volatile& _ClassType; 1464 typedef _Rp _ReturnType; 1465}; 1466 1467template <class _Rp, class _Class, class ..._Param> 1468struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> 1469{ 1470 typedef _Class const volatile& _ClassType; 1471 typedef _Rp _ReturnType; 1472}; 1473 1474template <class _Rp, class _Class, class ..._Param> 1475struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> 1476{ 1477 typedef _Class&& _ClassType; 1478 typedef _Rp _ReturnType; 1479}; 1480 1481template <class _Rp, class _Class, class ..._Param> 1482struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> 1483{ 1484 typedef _Class const&& _ClassType; 1485 typedef _Rp _ReturnType; 1486}; 1487 1488template <class _Rp, class _Class, class ..._Param> 1489struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> 1490{ 1491 typedef _Class volatile&& _ClassType; 1492 typedef _Rp _ReturnType; 1493}; 1494 1495template <class _Rp, class _Class, class ..._Param> 1496struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> 1497{ 1498 typedef _Class const volatile&& _ClassType; 1499 typedef _Rp _ReturnType; 1500}; 1501 1502#endif // __has_feature(cxx_reference_qualified_functions) 1503 1504#else // _LIBCPP_HAS_NO_VARIADICS 1505 1506template <class _Rp, class _Class> 1507struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> 1508{ 1509 typedef _Class _ClassType; 1510 typedef _Rp _ReturnType; 1511}; 1512 1513template <class _Rp, class _Class, class _P0> 1514struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> 1515{ 1516 typedef _Class _ClassType; 1517 typedef _Rp _ReturnType; 1518}; 1519 1520template <class _Rp, class _Class, class _P0, class _P1> 1521struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> 1522{ 1523 typedef _Class _ClassType; 1524 typedef _Rp _ReturnType; 1525}; 1526 1527template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1528struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> 1529{ 1530 typedef _Class _ClassType; 1531 typedef _Rp _ReturnType; 1532}; 1533 1534template <class _Rp, class _Class> 1535struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> 1536{ 1537 typedef _Class const _ClassType; 1538 typedef _Rp _ReturnType; 1539}; 1540 1541template <class _Rp, class _Class, class _P0> 1542struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> 1543{ 1544 typedef _Class const _ClassType; 1545 typedef _Rp _ReturnType; 1546}; 1547 1548template <class _Rp, class _Class, class _P0, class _P1> 1549struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> 1550{ 1551 typedef _Class const _ClassType; 1552 typedef _Rp _ReturnType; 1553}; 1554 1555template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1556struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false> 1557{ 1558 typedef _Class const _ClassType; 1559 typedef _Rp _ReturnType; 1560}; 1561 1562template <class _Rp, class _Class> 1563struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> 1564{ 1565 typedef _Class volatile _ClassType; 1566 typedef _Rp _ReturnType; 1567}; 1568 1569template <class _Rp, class _Class, class _P0> 1570struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> 1571{ 1572 typedef _Class volatile _ClassType; 1573 typedef _Rp _ReturnType; 1574}; 1575 1576template <class _Rp, class _Class, class _P0, class _P1> 1577struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false> 1578{ 1579 typedef _Class volatile _ClassType; 1580 typedef _Rp _ReturnType; 1581}; 1582 1583template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1584struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false> 1585{ 1586 typedef _Class volatile _ClassType; 1587 typedef _Rp _ReturnType; 1588}; 1589 1590template <class _Rp, class _Class> 1591struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false> 1592{ 1593 typedef _Class const volatile _ClassType; 1594 typedef _Rp _ReturnType; 1595}; 1596 1597template <class _Rp, class _Class, class _P0> 1598struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false> 1599{ 1600 typedef _Class const volatile _ClassType; 1601 typedef _Rp _ReturnType; 1602}; 1603 1604template <class _Rp, class _Class, class _P0, class _P1> 1605struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false> 1606{ 1607 typedef _Class const volatile _ClassType; 1608 typedef _Rp _ReturnType; 1609}; 1610 1611template <class _Rp, class _Class, class _P0, class _P1, class _P2> 1612struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false> 1613{ 1614 typedef _Class const volatile _ClassType; 1615 typedef _Rp _ReturnType; 1616}; 1617 1618#endif // _LIBCPP_HAS_NO_VARIADICS 1619 1620template <class _Rp, class _Class> 1621struct __member_pointer_traits_imp<_Rp _Class::*, false, true> 1622{ 1623 typedef _Class _ClassType; 1624 typedef _Rp _ReturnType; 1625}; 1626 1627template <class _MP> 1628struct __member_pointer_traits 1629 : public __member_pointer_traits_imp<_MP, 1630 is_member_function_pointer<_MP>::value, 1631 is_member_object_pointer<_MP>::value> 1632{ 1633// typedef ... _ClassType; 1634// typedef ... _ReturnType; 1635}; 1636 1637// result_of 1638 1639template <class _Callable> class result_of; 1640 1641#ifdef _LIBCPP_HAS_NO_VARIADICS 1642 1643template <class _Fn, bool, bool> 1644class __result_of 1645{ 1646}; 1647 1648template <class _Fn> 1649class __result_of<_Fn(), true, false> 1650{ 1651public: 1652 typedef decltype(declval<_Fn>()()) type; 1653}; 1654 1655template <class _Fn, class _A0> 1656class __result_of<_Fn(_A0), true, false> 1657{ 1658public: 1659 typedef decltype(declval<_Fn>()(declval<_A0>())) type; 1660}; 1661 1662template <class _Fn, class _A0, class _A1> 1663class __result_of<_Fn(_A0, _A1), true, false> 1664{ 1665public: 1666 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; 1667}; 1668 1669template <class _Fn, class _A0, class _A1, class _A2> 1670class __result_of<_Fn(_A0, _A1, _A2), true, false> 1671{ 1672public: 1673 typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; 1674}; 1675 1676template <class _MP, class _Tp, bool _IsMemberFunctionPtr> 1677struct __result_of_mp; 1678 1679// member function pointer 1680 1681template <class _MP, class _Tp> 1682struct __result_of_mp<_MP, _Tp, true> 1683 : public common_type<typename __member_pointer_traits<_MP>::_ReturnType> 1684{ 1685}; 1686 1687// member data pointer 1688 1689template <class _MP, class _Tp, bool> 1690struct __result_of_mdp; 1691 1692template <class _Rp, class _Class, class _Tp> 1693struct __result_of_mdp<_Rp _Class::*, _Tp, false> 1694{ 1695 typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type; 1696}; 1697 1698template <class _Rp, class _Class, class _Tp> 1699struct __result_of_mdp<_Rp _Class::*, _Tp, true> 1700{ 1701 typedef typename __apply_cv<_Tp, _Rp>::type& type; 1702}; 1703 1704template <class _Rp, class _Class, class _Tp> 1705struct __result_of_mp<_Rp _Class::*, _Tp, false> 1706 : public __result_of_mdp<_Rp _Class::*, _Tp, 1707 is_base_of<_Class, typename remove_reference<_Tp>::type>::value> 1708{ 1709}; 1710 1711 1712 1713template <class _Fn, class _Tp> 1714class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer 1715 : public __result_of_mp<typename remove_reference<_Fn>::type, 1716 _Tp, 1717 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1718{ 1719}; 1720 1721template <class _Fn, class _Tp, class _A0> 1722class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer 1723 : public __result_of_mp<typename remove_reference<_Fn>::type, 1724 _Tp, 1725 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1726{ 1727}; 1728 1729template <class _Fn, class _Tp, class _A0, class _A1> 1730class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer 1731 : public __result_of_mp<typename remove_reference<_Fn>::type, 1732 _Tp, 1733 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1734{ 1735}; 1736 1737template <class _Fn, class _Tp, class _A0, class _A1, class _A2> 1738class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer 1739 : public __result_of_mp<typename remove_reference<_Fn>::type, 1740 _Tp, 1741 is_member_function_pointer<typename remove_reference<_Fn>::type>::value> 1742{ 1743}; 1744 1745// result_of 1746 1747template <class _Fn> 1748class _LIBCPP_VISIBLE result_of<_Fn()> 1749 : public __result_of<_Fn(), 1750 is_class<typename remove_reference<_Fn>::type>::value || 1751 is_function<typename remove_reference<_Fn>::type>::value, 1752 is_member_pointer<typename remove_reference<_Fn>::type>::value 1753 > 1754{ 1755}; 1756 1757template <class _Fn, class _A0> 1758class _LIBCPP_VISIBLE result_of<_Fn(_A0)> 1759 : public __result_of<_Fn(_A0), 1760 is_class<typename remove_reference<_Fn>::type>::value || 1761 is_function<typename remove_reference<_Fn>::type>::value, 1762 is_member_pointer<typename remove_reference<_Fn>::type>::value 1763 > 1764{ 1765}; 1766 1767template <class _Fn, class _A0, class _A1> 1768class _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1)> 1769 : public __result_of<_Fn(_A0, _A1), 1770 is_class<typename remove_reference<_Fn>::type>::value || 1771 is_function<typename remove_reference<_Fn>::type>::value, 1772 is_member_pointer<typename remove_reference<_Fn>::type>::value 1773 > 1774{ 1775}; 1776 1777template <class _Fn, class _A0, class _A1, class _A2> 1778class _LIBCPP_VISIBLE result_of<_Fn(_A0, _A1, _A2)> 1779 : public __result_of<_Fn(_A0, _A1, _A2), 1780 is_class<typename remove_reference<_Fn>::type>::value || 1781 is_function<typename remove_reference<_Fn>::type>::value, 1782 is_member_pointer<typename remove_reference<_Fn>::type>::value 1783 > 1784{ 1785}; 1786 1787#endif // _LIBCPP_HAS_NO_VARIADICS 1788 1789#ifndef _LIBCPP_HAS_NO_VARIADICS 1790 1791// template <class T, class... Args> struct is_constructible; 1792 1793// main is_constructible test 1794 1795template<typename, typename T> struct __select_2nd { typedef T type; }; 1796 1797template <class _Tp, class ..._Args> 1798typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type 1799__is_constructible_test(_Tp&&, _Args&& ...); 1800 1801template <class ..._Args> 1802false_type 1803__is_constructible_test(__any, _Args&& ...); 1804 1805template <bool, class _Tp, class... _Args> 1806struct __is_constructible // false, _Tp is not a scalar 1807 : public common_type 1808 < 1809 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...)) 1810 >::type 1811 {}; 1812 1813// function types are not constructible 1814 1815template <class _Rp, class... _A1, class... _A2> 1816struct __is_constructible<false, _Rp(_A1...), _A2...> 1817 : public false_type 1818 {}; 1819 1820// handle scalars and reference types 1821 1822// Scalars are default constructible, references are not 1823 1824template <class _Tp> 1825struct __is_constructible<true, _Tp> 1826 : public is_scalar<_Tp> 1827 {}; 1828 1829// Scalars and references are constructible from one arg if that arg is 1830// implicitly convertible to the scalar or reference. 1831 1832template <class _Tp> 1833struct __is_constructible_ref 1834{ 1835 true_type static __lxx(_Tp); 1836 false_type static __lxx(...); 1837}; 1838 1839template <class _Tp, class _A0> 1840struct __is_constructible<true, _Tp, _A0> 1841 : public common_type 1842 < 1843 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>())) 1844 >::type 1845 {}; 1846 1847// Scalars and references are not constructible from multiple args. 1848 1849template <class _Tp, class _A0, class ..._Args> 1850struct __is_constructible<true, _Tp, _A0, _Args...> 1851 : public false_type 1852 {}; 1853 1854// Treat scalars and reference types separately 1855 1856template <bool, class _Tp, class... _Args> 1857struct __is_constructible_void_check 1858 : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value, 1859 _Tp, _Args...> 1860 {}; 1861 1862// If any of T or Args is void, is_constructible should be false 1863 1864template <class _Tp, class... _Args> 1865struct __is_constructible_void_check<true, _Tp, _Args...> 1866 : public false_type 1867 {}; 1868 1869template <class ..._Args> struct __contains_void; 1870 1871template <> struct __contains_void<> : false_type {}; 1872 1873template <class _A0, class ..._Args> 1874struct __contains_void<_A0, _Args...> 1875{ 1876 static const bool value = is_void<_A0>::value || 1877 __contains_void<_Args...>::value; 1878}; 1879 1880// is_constructible entry point 1881 1882template <class _Tp, class... _Args> 1883struct _LIBCPP_VISIBLE is_constructible 1884 : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value 1885 || is_abstract<_Tp>::value, 1886 _Tp, _Args...> 1887 {}; 1888 1889// Array types are default constructible if their element type 1890// is default constructible 1891 1892template <class _Ap, size_t _Np> 1893struct __is_constructible<false, _Ap[_Np]> 1894 : public is_constructible<typename remove_all_extents<_Ap>::type> 1895 {}; 1896 1897// Otherwise array types are not constructible by this syntax 1898 1899template <class _Ap, size_t _Np, class ..._Args> 1900struct __is_constructible<false, _Ap[_Np], _Args...> 1901 : public false_type 1902 {}; 1903 1904// Incomplete array types are not constructible 1905 1906template <class _Ap, class ..._Args> 1907struct __is_constructible<false, _Ap[], _Args...> 1908 : public false_type 1909 {}; 1910 1911#else // _LIBCPP_HAS_NO_VARIADICS 1912 1913// template <class T> struct is_constructible0; 1914 1915// main is_constructible0 test 1916 1917template <class _Tp> 1918decltype((_Tp(), true_type())) 1919__is_constructible0_test(_Tp&); 1920 1921false_type 1922__is_constructible0_test(__any); 1923 1924template <class _Tp, class _A0> 1925decltype((_Tp(_VSTD::declval<_A0>()), true_type())) 1926__is_constructible1_test(_Tp&, _A0&); 1927 1928template <class _A0> 1929false_type 1930__is_constructible1_test(__any, _A0&); 1931 1932template <class _Tp, class _A0, class _A1> 1933decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) 1934__is_constructible2_test(_Tp&, _A0&, _A1&); 1935 1936template <class _A0, class _A1> 1937false_type 1938__is_constructible2_test(__any, _A0&, _A1&); 1939 1940template <bool, class _Tp> 1941struct __is_constructible0_imp // false, _Tp is not a scalar 1942 : public common_type 1943 < 1944 decltype(__is_constructible0_test(declval<_Tp&>())) 1945 >::type 1946 {}; 1947 1948template <bool, class _Tp, class _A0> 1949struct __is_constructible1_imp // false, _Tp is not a scalar 1950 : public common_type 1951 < 1952 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) 1953 >::type 1954 {}; 1955 1956template <bool, class _Tp, class _A0, class _A1> 1957struct __is_constructible2_imp // false, _Tp is not a scalar 1958 : public common_type 1959 < 1960 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) 1961 >::type 1962 {}; 1963 1964// handle scalars and reference types 1965 1966// Scalars are default constructible, references are not 1967 1968template <class _Tp> 1969struct __is_constructible0_imp<true, _Tp> 1970 : public is_scalar<_Tp> 1971 {}; 1972 1973template <class _Tp, class _A0> 1974struct __is_constructible1_imp<true, _Tp, _A0> 1975 : public is_convertible<_A0, _Tp> 1976 {}; 1977 1978template <class _Tp, class _A0, class _A1> 1979struct __is_constructible2_imp<true, _Tp, _A0, _A1> 1980 : public false_type 1981 {}; 1982 1983// Treat scalars and reference types separately 1984 1985template <bool, class _Tp> 1986struct __is_constructible0_void_check 1987 : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 1988 _Tp> 1989 {}; 1990 1991template <bool, class _Tp, class _A0> 1992struct __is_constructible1_void_check 1993 : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 1994 _Tp, _A0> 1995 {}; 1996 1997template <bool, class _Tp, class _A0, class _A1> 1998struct __is_constructible2_void_check 1999 : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value, 2000 _Tp, _A0, _A1> 2001 {}; 2002 2003// If any of T or Args is void, is_constructible should be false 2004 2005template <class _Tp> 2006struct __is_constructible0_void_check<true, _Tp> 2007 : public false_type 2008 {}; 2009 2010template <class _Tp, class _A0> 2011struct __is_constructible1_void_check<true, _Tp, _A0> 2012 : public false_type 2013 {}; 2014 2015template <class _Tp, class _A0, class _A1> 2016struct __is_constructible2_void_check<true, _Tp, _A0, _A1> 2017 : public false_type 2018 {}; 2019 2020// is_constructible entry point 2021 2022namespace __is_construct 2023{ 2024 2025struct __nat {}; 2026 2027} 2028 2029template <class _Tp, class _A0 = __is_construct::__nat, 2030 class _A1 = __is_construct::__nat> 2031struct _LIBCPP_VISIBLE is_constructible 2032 : public __is_constructible2_void_check<is_void<_Tp>::value 2033 || is_abstract<_Tp>::value 2034 || is_function<_Tp>::value 2035 || is_void<_A0>::value 2036 || is_void<_A1>::value, 2037 _Tp, _A0, _A1> 2038 {}; 2039 2040template <class _Tp> 2041struct _LIBCPP_VISIBLE is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> 2042 : public __is_constructible0_void_check<is_void<_Tp>::value 2043 || is_abstract<_Tp>::value 2044 || is_function<_Tp>::value, 2045 _Tp> 2046 {}; 2047 2048template <class _Tp, class _A0> 2049struct _LIBCPP_VISIBLE is_constructible<_Tp, _A0, __is_construct::__nat> 2050 : public __is_constructible1_void_check<is_void<_Tp>::value 2051 || is_abstract<_Tp>::value 2052 || is_function<_Tp>::value 2053 || is_void<_A0>::value, 2054 _Tp, _A0> 2055 {}; 2056 2057// Array types are default constructible if their element type 2058// is default constructible 2059 2060template <class _Ap, size_t _Np> 2061struct __is_constructible0_imp<false, _Ap[_Np]> 2062 : public is_constructible<typename remove_all_extents<_Ap>::type> 2063 {}; 2064 2065template <class _Ap, size_t _Np, class _A0> 2066struct __is_constructible1_imp<false, _Ap[_Np], _A0> 2067 : public false_type 2068 {}; 2069 2070template <class _Ap, size_t _Np, class _A0, class _A1> 2071struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1> 2072 : public false_type 2073 {}; 2074 2075// Incomplete array types are not constructible 2076 2077template <class _Ap> 2078struct __is_constructible0_imp<false, _Ap[]> 2079 : public false_type 2080 {}; 2081 2082template <class _Ap, class _A0> 2083struct __is_constructible1_imp<false, _Ap[], _A0> 2084 : public false_type 2085 {}; 2086 2087template <class _Ap, class _A0, class _A1> 2088struct __is_constructible2_imp<false, _Ap[], _A0, _A1> 2089 : public false_type 2090 {}; 2091 2092#endif // _LIBCPP_HAS_NO_VARIADICS 2093 2094// is_default_constructible 2095 2096template <class _Tp> 2097struct _LIBCPP_VISIBLE is_default_constructible 2098 : public is_constructible<_Tp> 2099 {}; 2100 2101// is_copy_constructible 2102 2103template <class _Tp> 2104struct _LIBCPP_VISIBLE is_copy_constructible 2105 : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2106 {}; 2107 2108// is_move_constructible 2109 2110template <class _Tp> 2111struct _LIBCPP_VISIBLE is_move_constructible 2112#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2113 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2114#else 2115 : public is_copy_constructible<_Tp> 2116#endif 2117 {}; 2118 2119// is_trivially_constructible 2120 2121#ifndef _LIBCPP_HAS_NO_VARIADICS 2122 2123#if __has_feature(is_trivially_constructible) 2124 2125template <class _Tp, class... _Args> 2126struct _LIBCPP_VISIBLE is_trivially_constructible 2127 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> 2128{ 2129}; 2130 2131#else // !__has_feature(is_trivially_constructible) 2132 2133template <class _Tp, class... _Args> 2134struct _LIBCPP_VISIBLE is_trivially_constructible 2135 : false_type 2136{ 2137}; 2138 2139template <class _Tp> 2140struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp> 2141#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2142 : integral_constant<bool, __has_trivial_constructor(_Tp)> 2143#else 2144 : integral_constant<bool, is_scalar<_Tp>::value> 2145#endif 2146{ 2147}; 2148 2149template <class _Tp> 2150#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2151struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&&> 2152#else 2153struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp> 2154#endif 2155 : integral_constant<bool, is_scalar<_Tp>::value> 2156{ 2157}; 2158 2159template <class _Tp> 2160struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&> 2161 : integral_constant<bool, is_scalar<_Tp>::value> 2162{ 2163}; 2164 2165template <class _Tp> 2166struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&> 2167 : integral_constant<bool, is_scalar<_Tp>::value> 2168{ 2169}; 2170 2171#endif // !__has_feature(is_trivially_constructible) 2172 2173#else // _LIBCPP_HAS_NO_VARIADICS 2174 2175template <class _Tp, class _A0 = __is_construct::__nat, 2176 class _A1 = __is_construct::__nat> 2177struct _LIBCPP_VISIBLE is_trivially_constructible 2178 : false_type 2179{ 2180}; 2181 2182#if __has_feature(is_trivially_constructible) 2183 2184template <class _Tp> 2185struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat, 2186 __is_construct::__nat> 2187 : integral_constant<bool, __is_trivially_constructible(_Tp)> 2188{ 2189}; 2190 2191template <class _Tp> 2192struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp, 2193 __is_construct::__nat> 2194 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)> 2195{ 2196}; 2197 2198template <class _Tp> 2199struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&, 2200 __is_construct::__nat> 2201 : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)> 2202{ 2203}; 2204 2205template <class _Tp> 2206struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&, 2207 __is_construct::__nat> 2208 : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)> 2209{ 2210}; 2211 2212#else // !__has_feature(is_trivially_constructible) 2213 2214template <class _Tp> 2215struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat, 2216 __is_construct::__nat> 2217 : integral_constant<bool, is_scalar<_Tp>::value> 2218{ 2219}; 2220 2221template <class _Tp> 2222struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp, 2223 __is_construct::__nat> 2224 : integral_constant<bool, is_scalar<_Tp>::value> 2225{ 2226}; 2227 2228template <class _Tp> 2229struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&, 2230 __is_construct::__nat> 2231 : integral_constant<bool, is_scalar<_Tp>::value> 2232{ 2233}; 2234 2235template <class _Tp> 2236struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&, 2237 __is_construct::__nat> 2238 : integral_constant<bool, is_scalar<_Tp>::value> 2239{ 2240}; 2241 2242#endif // !__has_feature(is_trivially_constructible) 2243 2244#endif // _LIBCPP_HAS_NO_VARIADICS 2245 2246// is_trivially_default_constructible 2247 2248template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_default_constructible 2249 : public is_trivially_constructible<_Tp> 2250 {}; 2251 2252// is_trivially_copy_constructible 2253 2254template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_constructible 2255 : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2256 {}; 2257 2258// is_trivially_move_constructible 2259 2260template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_constructible 2261#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2262 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2263#else 2264 : public is_trivially_copy_constructible<_Tp> 2265#endif 2266 {}; 2267 2268// is_trivially_assignable 2269 2270#if __has_feature(is_trivially_constructible) 2271 2272template <class _Tp, class _Arg> 2273struct is_trivially_assignable 2274 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> 2275{ 2276}; 2277 2278#else // !__has_feature(is_trivially_constructible) 2279 2280template <class _Tp, class _Arg> 2281struct is_trivially_assignable 2282 : public false_type {}; 2283 2284template <class _Tp> 2285struct is_trivially_assignable<_Tp&, _Tp> 2286 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2287 2288template <class _Tp> 2289struct is_trivially_assignable<_Tp&, _Tp&> 2290 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2291 2292template <class _Tp> 2293struct is_trivially_assignable<_Tp&, const _Tp&> 2294 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2295 2296#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2297 2298template <class _Tp> 2299struct is_trivially_assignable<_Tp&, _Tp&&> 2300 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2301 2302#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2303 2304#endif // !__has_feature(is_trivially_constructible) 2305 2306// is_trivially_copy_assignable 2307 2308template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_assignable 2309 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2310 const typename add_lvalue_reference<_Tp>::type> 2311 {}; 2312 2313// is_trivially_move_assignable 2314 2315template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_move_assignable 2316 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, 2317#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2318 typename add_rvalue_reference<_Tp>::type> 2319#else 2320 typename add_lvalue_reference<_Tp>::type> 2321#endif 2322 {}; 2323 2324// is_trivially_destructible 2325 2326#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2327 2328template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible 2329 : public integral_constant<bool, __has_trivial_destructor(_Tp)> {}; 2330 2331#else // _LIBCPP_HAS_TYPE_TRAITS 2332 2333template <class _Tp> struct __libcpp_trivial_destructor 2334 : public integral_constant<bool, is_scalar<_Tp>::value || 2335 is_reference<_Tp>::value> {}; 2336 2337template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible 2338 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; 2339 2340#endif // _LIBCPP_HAS_TYPE_TRAITS 2341 2342// is_nothrow_constructible 2343 2344#ifndef _LIBCPP_HAS_NO_VARIADICS 2345 2346#if __has_feature(cxx_noexcept) 2347 2348template <bool, class _Tp, class... _Args> struct __is_nothrow_constructible; 2349 2350template <class _Tp, class... _Args> 2351struct __is_nothrow_constructible<true, _Tp, _Args...> 2352 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 2353{ 2354}; 2355 2356template <class _Tp, class... _Args> 2357struct __is_nothrow_constructible<false, _Tp, _Args...> 2358 : public false_type 2359{ 2360}; 2361 2362template <class _Tp, class... _Args> 2363struct _LIBCPP_VISIBLE is_nothrow_constructible 2364 : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...> 2365{ 2366}; 2367 2368template <class _Tp, size_t _Ns> 2369struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp[_Ns]> 2370 : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp> 2371{ 2372}; 2373 2374#else // __has_feature(cxx_noexcept) 2375 2376template <class _Tp, class... _Args> 2377struct _LIBCPP_VISIBLE is_nothrow_constructible 2378 : false_type 2379{ 2380}; 2381 2382template <class _Tp> 2383struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp> 2384#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2385 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2386#else 2387 : integral_constant<bool, is_scalar<_Tp>::value> 2388#endif 2389{ 2390}; 2391 2392template <class _Tp> 2393#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2394struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&&> 2395#else 2396struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp> 2397#endif 2398#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2399 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2400#else 2401 : integral_constant<bool, is_scalar<_Tp>::value> 2402#endif 2403{ 2404}; 2405 2406template <class _Tp> 2407struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&> 2408#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2409 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2410#else 2411 : integral_constant<bool, is_scalar<_Tp>::value> 2412#endif 2413{ 2414}; 2415 2416template <class _Tp> 2417struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&> 2418#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2419 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2420#else 2421 : integral_constant<bool, is_scalar<_Tp>::value> 2422#endif 2423{ 2424}; 2425 2426#endif // __has_feature(cxx_noexcept) 2427 2428#else // _LIBCPP_HAS_NO_VARIADICS 2429 2430template <class _Tp, class _A0 = __is_construct::__nat, 2431 class _A1 = __is_construct::__nat> 2432struct _LIBCPP_VISIBLE is_nothrow_constructible 2433 : false_type 2434{ 2435}; 2436 2437template <class _Tp> 2438struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, __is_construct::__nat, 2439 __is_construct::__nat> 2440#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2441 : integral_constant<bool, __has_nothrow_constructor(_Tp)> 2442#else 2443 : integral_constant<bool, is_scalar<_Tp>::value> 2444#endif 2445{ 2446}; 2447 2448template <class _Tp> 2449struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp, 2450 __is_construct::__nat> 2451#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2452 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2453#else 2454 : integral_constant<bool, is_scalar<_Tp>::value> 2455#endif 2456{ 2457}; 2458 2459template <class _Tp> 2460struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&, 2461 __is_construct::__nat> 2462#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2463 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2464#else 2465 : integral_constant<bool, is_scalar<_Tp>::value> 2466#endif 2467{ 2468}; 2469 2470template <class _Tp> 2471struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&, 2472 __is_construct::__nat> 2473#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2474 : integral_constant<bool, __has_nothrow_copy(_Tp)> 2475#else 2476 : integral_constant<bool, is_scalar<_Tp>::value> 2477#endif 2478{ 2479}; 2480 2481#endif // _LIBCPP_HAS_NO_VARIADICS 2482 2483// is_nothrow_default_constructible 2484 2485template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_default_constructible 2486 : public is_nothrow_constructible<_Tp> 2487 {}; 2488 2489// is_nothrow_copy_constructible 2490 2491template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_constructible 2492 : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> 2493 {}; 2494 2495// is_nothrow_move_constructible 2496 2497template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_constructible 2498#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2499 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> 2500#else 2501 : public is_nothrow_copy_constructible<_Tp> 2502#endif 2503 {}; 2504 2505// is_nothrow_assignable 2506 2507#if __has_feature(cxx_noexcept) 2508 2509template <bool, class _Tp, class _Arg> struct __is_nothrow_assignable; 2510 2511template <class _Tp, class _Arg> 2512struct __is_nothrow_assignable<false, _Tp, _Arg> 2513 : public false_type 2514{ 2515}; 2516 2517template <class _Tp, class _Arg> 2518struct __is_nothrow_assignable<true, _Tp, _Arg> 2519 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) > 2520{ 2521}; 2522 2523template <class _Tp, class _Arg> 2524struct _LIBCPP_VISIBLE is_nothrow_assignable 2525 : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> 2526{ 2527}; 2528 2529#else // __has_feature(cxx_noexcept) 2530 2531template <class _Tp, class _Arg> 2532struct _LIBCPP_VISIBLE is_nothrow_assignable 2533 : public false_type {}; 2534 2535template <class _Tp> 2536struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp> 2537#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2538 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2539#else 2540 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2541#endif 2542 2543template <class _Tp> 2544struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp&> 2545#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2546 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2547#else 2548 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2549#endif 2550 2551template <class _Tp> 2552struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, const _Tp&> 2553#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2554 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2555#else 2556 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2557#endif 2558 2559#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2560 2561template <class _Tp> 2562struct is_nothrow_assignable<_Tp&, _Tp&&> 2563#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2564 : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; 2565#else 2566 : integral_constant<bool, is_scalar<_Tp>::value> {}; 2567#endif 2568 2569#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2570 2571#endif // __has_feature(cxx_noexcept) 2572 2573// is_nothrow_copy_assignable 2574 2575template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable 2576 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2577 const typename add_lvalue_reference<_Tp>::type> 2578 {}; 2579 2580// is_nothrow_move_assignable 2581 2582template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_assignable 2583 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, 2584#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2585 typename add_rvalue_reference<_Tp>::type> 2586#else 2587 typename add_lvalue_reference<_Tp>::type> 2588#endif 2589 {}; 2590 2591// is_nothrow_destructible 2592 2593#if __has_feature(cxx_noexcept) 2594 2595template <bool, class _Tp> struct __is_nothrow_destructible; 2596 2597template <class _Tp> 2598struct __is_nothrow_destructible<false, _Tp> 2599 : public false_type 2600{ 2601}; 2602 2603template <class _Tp> 2604struct __is_nothrow_destructible<true, _Tp> 2605 : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) > 2606{ 2607}; 2608 2609template <class _Tp> 2610struct _LIBCPP_VISIBLE is_nothrow_destructible 2611 : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> 2612{ 2613}; 2614 2615template <class _Tp, size_t _Ns> 2616struct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp[_Ns]> 2617 : public is_nothrow_destructible<_Tp> 2618{ 2619}; 2620 2621template <class _Tp> 2622struct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&> 2623 : public true_type 2624{ 2625}; 2626 2627#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2628 2629template <class _Tp> 2630struct _LIBCPP_VISIBLE is_nothrow_destructible<_Tp&&> 2631 : public true_type 2632{ 2633}; 2634 2635#endif 2636 2637#else 2638 2639template <class _Tp> struct __libcpp_nothrow_destructor 2640 : public integral_constant<bool, is_scalar<_Tp>::value || 2641 is_reference<_Tp>::value> {}; 2642 2643template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible 2644 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; 2645 2646#endif 2647 2648// is_pod 2649 2650#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 2651 2652template <class _Tp> struct _LIBCPP_VISIBLE is_pod 2653 : public integral_constant<bool, __is_pod(_Tp)> {}; 2654 2655#else // _LIBCPP_HAS_TYPE_TRAITS 2656 2657template <class _Tp> struct _LIBCPP_VISIBLE is_pod 2658 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && 2659 is_trivially_copy_constructible<_Tp>::value && 2660 is_trivially_copy_assignable<_Tp>::value && 2661 is_trivially_destructible<_Tp>::value> {}; 2662 2663#endif // _LIBCPP_HAS_TYPE_TRAITS 2664 2665// is_literal_type; 2666 2667template <class _Tp> struct _LIBCPP_VISIBLE is_literal_type 2668#if __has_feature(is_literal) 2669 : public integral_constant<bool, __is_literal(_Tp)> 2670#else 2671 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value || 2672 is_reference<typename remove_all_extents<_Tp>::type>::value> 2673#endif 2674 {}; 2675 2676// is_standard_layout; 2677 2678template <class _Tp> struct _LIBCPP_VISIBLE is_standard_layout 2679#if __has_feature(is_standard_layout) 2680 : public integral_constant<bool, __is_standard_layout(_Tp)> 2681#else 2682 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2683#endif 2684 {}; 2685 2686// is_trivially_copyable; 2687 2688template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copyable 2689#if __has_feature(is_trivially_copyable) 2690 : public integral_constant<bool, __is_trivially_copyable(_Tp)> 2691#else 2692 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> 2693#endif 2694 {}; 2695 2696// is_trivial; 2697 2698template <class _Tp> struct _LIBCPP_VISIBLE is_trivial 2699#if __has_feature(is_trivial) 2700 : public integral_constant<bool, __is_trivial(_Tp)> 2701#else 2702 : integral_constant<bool, is_trivially_copyable<_Tp>::value && 2703 is_trivially_default_constructible<_Tp>::value> 2704#endif 2705 {}; 2706 2707#ifndef _LIBCPP_HAS_NO_VARIADICS 2708 2709// Check for complete types 2710 2711template <class ..._Tp> struct __check_complete; 2712 2713template <> 2714struct __check_complete<> 2715{ 2716}; 2717 2718template <class _Hp, class _T0, class ..._Tp> 2719struct __check_complete<_Hp, _T0, _Tp...> 2720 : private __check_complete<_Hp>, 2721 private __check_complete<_T0, _Tp...> 2722{ 2723}; 2724 2725template <class _Hp> 2726struct __check_complete<_Hp, _Hp> 2727 : private __check_complete<_Hp> 2728{ 2729}; 2730 2731template <class _Tp> 2732struct __check_complete<_Tp> 2733{ 2734 static_assert(sizeof(_Tp) > 0, "Type must be complete."); 2735}; 2736 2737template <class _Tp> 2738struct __check_complete<_Tp&> 2739 : private __check_complete<_Tp> 2740{ 2741}; 2742 2743template <class _Tp> 2744struct __check_complete<_Tp&&> 2745 : private __check_complete<_Tp> 2746{ 2747}; 2748 2749template <class _Rp, class ..._Param> 2750struct __check_complete<_Rp (*)(_Param...)> 2751 : private __check_complete<_Rp> 2752{ 2753}; 2754 2755template <class _Rp, class ..._Param> 2756struct __check_complete<_Rp (_Param...)> 2757 : private __check_complete<_Rp> 2758{ 2759}; 2760 2761template <class _Rp, class _Class, class ..._Param> 2762struct __check_complete<_Rp (_Class::*)(_Param...)> 2763 : private __check_complete<_Class> 2764{ 2765}; 2766 2767template <class _Rp, class _Class, class ..._Param> 2768struct __check_complete<_Rp (_Class::*)(_Param...) const> 2769 : private __check_complete<_Class> 2770{ 2771}; 2772 2773template <class _Rp, class _Class, class ..._Param> 2774struct __check_complete<_Rp (_Class::*)(_Param...) volatile> 2775 : private __check_complete<_Class> 2776{ 2777}; 2778 2779template <class _Rp, class _Class, class ..._Param> 2780struct __check_complete<_Rp (_Class::*)(_Param...) const volatile> 2781 : private __check_complete<_Class> 2782{ 2783}; 2784 2785#if __has_feature(cxx_reference_qualified_functions) 2786 2787template <class _Rp, class _Class, class ..._Param> 2788struct __check_complete<_Rp (_Class::*)(_Param...) &> 2789 : private __check_complete<_Class> 2790{ 2791}; 2792 2793template <class _Rp, class _Class, class ..._Param> 2794struct __check_complete<_Rp (_Class::*)(_Param...) const&> 2795 : private __check_complete<_Class> 2796{ 2797}; 2798 2799template <class _Rp, class _Class, class ..._Param> 2800struct __check_complete<_Rp (_Class::*)(_Param...) volatile&> 2801 : private __check_complete<_Class> 2802{ 2803}; 2804 2805template <class _Rp, class _Class, class ..._Param> 2806struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&> 2807 : private __check_complete<_Class> 2808{ 2809}; 2810 2811template <class _Rp, class _Class, class ..._Param> 2812struct __check_complete<_Rp (_Class::*)(_Param...) &&> 2813 : private __check_complete<_Class> 2814{ 2815}; 2816 2817template <class _Rp, class _Class, class ..._Param> 2818struct __check_complete<_Rp (_Class::*)(_Param...) const&&> 2819 : private __check_complete<_Class> 2820{ 2821}; 2822 2823template <class _Rp, class _Class, class ..._Param> 2824struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&> 2825 : private __check_complete<_Class> 2826{ 2827}; 2828 2829template <class _Rp, class _Class, class ..._Param> 2830struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&> 2831 : private __check_complete<_Class> 2832{ 2833}; 2834 2835#endif 2836 2837template <class _Rp, class _Class> 2838struct __check_complete<_Rp _Class::*> 2839 : private __check_complete<_Class> 2840{ 2841}; 2842 2843// __invoke forward declarations 2844 2845// fall back - none of the bullets 2846 2847template <class ..._Args> 2848auto 2849__invoke(__any, _Args&& ...__args) 2850 -> __nat; 2851 2852// bullets 1 and 2 2853 2854template <class _Fp, class _A0, class ..._Args> 2855_LIBCPP_INLINE_VISIBILITY 2856auto 2857__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 2858 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)); 2859 2860template <class _Fp, class _A0, class ..._Args> 2861_LIBCPP_INLINE_VISIBILITY 2862auto 2863__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) 2864 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)); 2865 2866// bullets 3 and 4 2867 2868template <class _Fp, class _A0> 2869_LIBCPP_INLINE_VISIBILITY 2870auto 2871__invoke(_Fp&& __f, _A0&& __a0) 2872 -> decltype(_VSTD::forward<_A0>(__a0).*__f); 2873 2874template <class _Fp, class _A0> 2875_LIBCPP_INLINE_VISIBILITY 2876auto 2877__invoke(_Fp&& __f, _A0&& __a0) 2878 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f); 2879 2880// bullet 5 2881 2882template <class _Fp, class ..._Args> 2883_LIBCPP_INLINE_VISIBILITY 2884auto 2885__invoke(_Fp&& __f, _Args&& ...__args) 2886 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)); 2887 2888// __invokable 2889 2890template <class _Fp, class ..._Args> 2891struct __invokable_imp 2892 : private __check_complete<_Fp> 2893{ 2894 typedef decltype( 2895 __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...) 2896 ) type; 2897 static const bool value = !is_same<type, __nat>::value; 2898}; 2899 2900template <class _Fp, class ..._Args> 2901struct __invokable 2902 : public integral_constant<bool, 2903 __invokable_imp<_Fp, _Args...>::value> 2904{ 2905}; 2906 2907// __invoke_of 2908 2909template <bool _Invokable, class _Fp, class ..._Args> 2910struct __invoke_of_imp // false 2911{ 2912}; 2913 2914template <class _Fp, class ..._Args> 2915struct __invoke_of_imp<true, _Fp, _Args...> 2916{ 2917 typedef typename __invokable_imp<_Fp, _Args...>::type type; 2918}; 2919 2920template <class _Fp, class ..._Args> 2921struct __invoke_of 2922 : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...> 2923{ 2924}; 2925 2926template <class _Fp, class ..._Args> 2927class _LIBCPP_VISIBLE result_of<_Fp(_Args...)> 2928 : public __invoke_of<_Fp, _Args...> 2929{ 2930}; 2931 2932#endif // _LIBCPP_HAS_NO_VARIADICS 2933 2934template <class _Tp> 2935inline _LIBCPP_INLINE_VISIBILITY 2936#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 2937typename enable_if 2938< 2939 is_move_constructible<_Tp>::value && 2940 is_move_assignable<_Tp>::value 2941>::type 2942#else 2943void 2944#endif 2945swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && 2946 is_nothrow_move_assignable<_Tp>::value) 2947{ 2948 _Tp __t(_VSTD::move(__x)); 2949 __x = _VSTD::move(__y); 2950 __y = _VSTD::move(__t); 2951} 2952 2953template <class _ForwardIterator1, class _ForwardIterator2> 2954inline _LIBCPP_INLINE_VISIBILITY 2955void 2956iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) 2957 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) 2958 _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), 2959 *_VSTD::declval<_ForwardIterator2>()))) 2960{ 2961 swap(*__a, *__b); 2962} 2963 2964// __swappable 2965 2966namespace __detail 2967{ 2968 2969using _VSTD::swap; 2970__nat swap(__any, __any); 2971 2972template <class _Tp> 2973struct __swappable 2974{ 2975 typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type; 2976 static const bool value = !is_same<type, __nat>::value; 2977}; 2978 2979} // __detail 2980 2981template <class _Tp> 2982struct __is_swappable 2983 : public integral_constant<bool, __detail::__swappable<_Tp>::value> 2984{ 2985}; 2986 2987#if __has_feature(cxx_noexcept) 2988 2989template <bool, class _Tp> 2990struct __is_nothrow_swappable_imp 2991 : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(), 2992 _VSTD::declval<_Tp&>()))> 2993{ 2994}; 2995 2996template <class _Tp> 2997struct __is_nothrow_swappable_imp<false, _Tp> 2998 : public false_type 2999{ 3000}; 3001 3002template <class _Tp> 3003struct __is_nothrow_swappable 3004 : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp> 3005{ 3006}; 3007 3008#else // __has_feature(cxx_noexcept) 3009 3010template <class _Tp> 3011struct __is_nothrow_swappable 3012 : public false_type 3013{ 3014}; 3015 3016#endif // __has_feature(cxx_noexcept) 3017 3018#ifdef _LIBCXX_UNDERLYING_TYPE 3019 3020template <class _Tp> 3021struct underlying_type 3022{ 3023 typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; 3024}; 3025 3026#else // _LIBCXX_UNDERLYING_TYPE 3027 3028template <class _Tp, bool _Support = false> 3029struct underlying_type 3030{ 3031 static_assert(_Support, "The underyling_type trait requires compiler " 3032 "support. Either no such support exists or " 3033 "libc++ does not know how to use it."); 3034}; 3035 3036#endif // _LIBCXX_UNDERLYING_TYPE 3037 3038_LIBCPP_END_NAMESPACE_STD 3039 3040#endif // _LIBCPP_TYPE_TRAITS 3041