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