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