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