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