1// -*- C++ -*- 2//===------------------------ functional ----------------------------------===// 3// 4// The LLVM Compiler Infrastructure 5// 6// This file is dual licensed under the MIT and the University of Illinois Open 7// Source Licenses. See LICENSE.TXT for details. 8// 9//===----------------------------------------------------------------------===// 10 11#ifndef _LIBCPP_FUNCTIONAL 12#define _LIBCPP_FUNCTIONAL 13 14/* 15 functional synopsis 16 17namespace std 18{ 19 20template <class Arg, class Result> 21struct unary_function 22{ 23 typedef Arg argument_type; 24 typedef Result result_type; 25}; 26 27template <class Arg1, class Arg2, class Result> 28struct binary_function 29{ 30 typedef Arg1 first_argument_type; 31 typedef Arg2 second_argument_type; 32 typedef Result result_type; 33}; 34 35template <class T> 36class reference_wrapper 37 : public unary_function<T1, R> // if wrapping a unary functor 38 : public binary_function<T1, T2, R> // if wraping a binary functor 39{ 40public: 41 // types 42 typedef T type; 43 typedef see below result_type; // Not always defined 44 45 // construct/copy/destroy 46 reference_wrapper(T&) noexcept; 47 reference_wrapper(T&&) = delete; // do not bind to temps 48 reference_wrapper(const reference_wrapper<T>& x) noexcept; 49 50 // assignment 51 reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept; 52 53 // access 54 operator T& () const noexcept; 55 T& get() const noexcept; 56 57 // invoke 58 template <class... ArgTypes> 59 typename result_of<T&(ArgTypes&&...)>::type 60 operator() (ArgTypes&&...) const; 61}; 62 63template <class T> reference_wrapper<T> ref(T& t) noexcept; 64template <class T> void ref(const T&& t) = delete; 65template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept; 66 67template <class T> reference_wrapper<const T> cref(const T& t) noexcept; 68template <class T> void cref(const T&& t) = delete; 69template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept; 70 71template <class T> // <class T=void> in C++14 72struct plus : binary_function<T, T, T> 73{ 74 T operator()(const T& x, const T& y) const; 75}; 76 77template <class T> // <class T=void> in C++14 78struct minus : binary_function<T, T, T> 79{ 80 T operator()(const T& x, const T& y) const; 81}; 82 83template <class T> // <class T=void> in C++14 84struct multiplies : binary_function<T, T, T> 85{ 86 T operator()(const T& x, const T& y) const; 87}; 88 89template <class T> // <class T=void> in C++14 90struct divides : binary_function<T, T, T> 91{ 92 T operator()(const T& x, const T& y) const; 93}; 94 95template <class T> // <class T=void> in C++14 96struct modulus : binary_function<T, T, T> 97{ 98 T operator()(const T& x, const T& y) const; 99}; 100 101template <class T> // <class T=void> in C++14 102struct negate : unary_function<T, T> 103{ 104 T operator()(const T& x) const; 105}; 106 107template <class T> // <class T=void> in C++14 108struct equal_to : binary_function<T, T, bool> 109{ 110 bool operator()(const T& x, const T& y) const; 111}; 112 113template <class T> // <class T=void> in C++14 114struct not_equal_to : binary_function<T, T, bool> 115{ 116 bool operator()(const T& x, const T& y) const; 117}; 118 119template <class T> // <class T=void> in C++14 120struct greater : binary_function<T, T, bool> 121{ 122 bool operator()(const T& x, const T& y) const; 123}; 124 125template <class T> // <class T=void> in C++14 126struct less : binary_function<T, T, bool> 127{ 128 bool operator()(const T& x, const T& y) const; 129}; 130 131template <class T> // <class T=void> in C++14 132struct greater_equal : binary_function<T, T, bool> 133{ 134 bool operator()(const T& x, const T& y) const; 135}; 136 137template <class T> // <class T=void> in C++14 138struct less_equal : binary_function<T, T, bool> 139{ 140 bool operator()(const T& x, const T& y) const; 141}; 142 143template <class T> // <class T=void> in C++14 144struct logical_and : binary_function<T, T, bool> 145{ 146 bool operator()(const T& x, const T& y) const; 147}; 148 149template <class T> // <class T=void> in C++14 150struct logical_or : binary_function<T, T, bool> 151{ 152 bool operator()(const T& x, const T& y) const; 153}; 154 155template <class T> // <class T=void> in C++14 156struct logical_not : unary_function<T, bool> 157{ 158 bool operator()(const T& x) const; 159}; 160 161template <class T> // <class T=void> in C++14 162struct bit_and : unary_function<T, bool> 163{ 164 bool operator()(const T& x, const T& y) const; 165}; 166 167template <class T> // <class T=void> in C++14 168struct bit_or : unary_function<T, bool> 169{ 170 bool operator()(const T& x, const T& y) const; 171}; 172 173template <class T> // <class T=void> in C++14 174struct bit_xor : unary_function<T, bool> 175{ 176 bool operator()(const T& x, const T& y) const; 177}; 178 179template <class T=void> // C++14 180struct bit_xor : unary_function<T, bool> 181{ 182 bool operator()(const T& x) const; 183}; 184 185template <class Predicate> 186class unary_negate 187 : public unary_function<typename Predicate::argument_type, bool> 188{ 189public: 190 explicit unary_negate(const Predicate& pred); 191 bool operator()(const typename Predicate::argument_type& x) const; 192}; 193 194template <class Predicate> unary_negate<Predicate> not1(const Predicate& pred); 195 196template <class Predicate> 197class binary_negate 198 : public binary_function<typename Predicate::first_argument_type, 199 typename Predicate::second_argument_type, 200 bool> 201{ 202public: 203 explicit binary_negate(const Predicate& pred); 204 bool operator()(const typename Predicate::first_argument_type& x, 205 const typename Predicate::second_argument_type& y) const; 206}; 207 208template <class Predicate> binary_negate<Predicate> not2(const Predicate& pred); 209 210template <class F> unspecified not_fn(F&& f); // C++17 211 212template<class T> struct is_bind_expression; 213template<class T> struct is_placeholder; 214 215 // See C++14 20.9.9, Function object binders 216template <class T> constexpr bool is_bind_expression_v 217 = is_bind_expression<T>::value; // C++17 218template <class T> constexpr int is_placeholder_v 219 = is_placeholder<T>::value; // C++17 220 221 222template<class Fn, class... BoundArgs> 223 unspecified bind(Fn&&, BoundArgs&&...); 224template<class R, class Fn, class... BoundArgs> 225 unspecified bind(Fn&&, BoundArgs&&...); 226 227namespace placeholders { 228 // M is the implementation-defined number of placeholders 229 extern unspecified _1; 230 extern unspecified _2; 231 . 232 . 233 . 234 extern unspecified _Mp; 235} 236 237template <class Operation> 238class binder1st 239 : public unary_function<typename Operation::second_argument_type, 240 typename Operation::result_type> 241{ 242protected: 243 Operation op; 244 typename Operation::first_argument_type value; 245public: 246 binder1st(const Operation& x, const typename Operation::first_argument_type y); 247 typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; 248 typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; 249}; 250 251template <class Operation, class T> 252binder1st<Operation> bind1st(const Operation& op, const T& x); 253 254template <class Operation> 255class binder2nd 256 : public unary_function<typename Operation::first_argument_type, 257 typename Operation::result_type> 258{ 259protected: 260 Operation op; 261 typename Operation::second_argument_type value; 262public: 263 binder2nd(const Operation& x, const typename Operation::second_argument_type y); 264 typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; 265 typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; 266}; 267 268template <class Operation, class T> 269binder2nd<Operation> bind2nd(const Operation& op, const T& x); 270 271template <class Arg, class Result> 272class pointer_to_unary_function : public unary_function<Arg, Result> 273{ 274public: 275 explicit pointer_to_unary_function(Result (*f)(Arg)); 276 Result operator()(Arg x) const; 277}; 278 279template <class Arg, class Result> 280pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); 281 282template <class Arg1, class Arg2, class Result> 283class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> 284{ 285public: 286 explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); 287 Result operator()(Arg1 x, Arg2 y) const; 288}; 289 290template <class Arg1, class Arg2, class Result> 291pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); 292 293template<class S, class T> 294class mem_fun_t : public unary_function<T*, S> 295{ 296public: 297 explicit mem_fun_t(S (T::*p)()); 298 S operator()(T* p) const; 299}; 300 301template<class S, class T, class A> 302class mem_fun1_t : public binary_function<T*, A, S> 303{ 304public: 305 explicit mem_fun1_t(S (T::*p)(A)); 306 S operator()(T* p, A x) const; 307}; 308 309template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); 310template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); 311 312template<class S, class T> 313class mem_fun_ref_t : public unary_function<T, S> 314{ 315public: 316 explicit mem_fun_ref_t(S (T::*p)()); 317 S operator()(T& p) const; 318}; 319 320template<class S, class T, class A> 321class mem_fun1_ref_t : public binary_function<T, A, S> 322{ 323public: 324 explicit mem_fun1_ref_t(S (T::*p)(A)); 325 S operator()(T& p, A x) const; 326}; 327 328template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); 329template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); 330 331template <class S, class T> 332class const_mem_fun_t : public unary_function<const T*, S> 333{ 334public: 335 explicit const_mem_fun_t(S (T::*p)() const); 336 S operator()(const T* p) const; 337}; 338 339template <class S, class T, class A> 340class const_mem_fun1_t : public binary_function<const T*, A, S> 341{ 342public: 343 explicit const_mem_fun1_t(S (T::*p)(A) const); 344 S operator()(const T* p, A x) const; 345}; 346 347template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); 348template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); 349 350template <class S, class T> 351class const_mem_fun_ref_t : public unary_function<T, S> 352{ 353public: 354 explicit const_mem_fun_ref_t(S (T::*p)() const); 355 S operator()(const T& p) const; 356}; 357 358template <class S, class T, class A> 359class const_mem_fun1_ref_t : public binary_function<T, A, S> 360{ 361public: 362 explicit const_mem_fun1_ref_t(S (T::*p)(A) const); 363 S operator()(const T& p, A x) const; 364}; 365 366template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); 367template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); 368 369template<class R, class T> unspecified mem_fn(R T::*); 370 371class bad_function_call 372 : public exception 373{ 374}; 375 376template<class> class function; // undefined 377 378template<class R, class... ArgTypes> 379class function<R(ArgTypes...)> 380 : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and 381 // ArgTypes contains T1 382 : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and 383 // ArgTypes contains T1 and T2 384{ 385public: 386 typedef R result_type; 387 388 // construct/copy/destroy: 389 function() noexcept; 390 function(nullptr_t) noexcept; 391 function(const function&); 392 function(function&&) noexcept; 393 template<class F> 394 function(F); 395 template<Allocator Alloc> 396 function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17 397 template<Allocator Alloc> 398 function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17 399 template<Allocator Alloc> 400 function(allocator_arg_t, const Alloc&, const function&); // removed in C++17 401 template<Allocator Alloc> 402 function(allocator_arg_t, const Alloc&, function&&); // removed in C++17 403 template<class F, Allocator Alloc> 404 function(allocator_arg_t, const Alloc&, F); // removed in C++17 405 406 function& operator=(const function&); 407 function& operator=(function&&) noexcept; 408 function& operator=(nullptr_t) noexcept; 409 template<class F> 410 function& operator=(F&&); 411 template<class F> 412 function& operator=(reference_wrapper<F>) noexcept; 413 414 ~function(); 415 416 // function modifiers: 417 void swap(function&) noexcept; 418 template<class F, class Alloc> 419 void assign(F&&, const Alloc&); // Removed in C++17 420 421 // function capacity: 422 explicit operator bool() const noexcept; 423 424 // function invocation: 425 R operator()(ArgTypes...) const; 426 427 // function target access: 428 const std::type_info& target_type() const noexcept; 429 template <typename T> T* target() noexcept; 430 template <typename T> const T* target() const noexcept; 431}; 432 433// Null pointer comparisons: 434template <class R, class ... ArgTypes> 435 bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 436 437template <class R, class ... ArgTypes> 438 bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 439 440template <class R, class ... ArgTypes> 441 bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 442 443template <class R, class ... ArgTypes> 444 bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 445 446// specialized algorithms: 447template <class R, class ... ArgTypes> 448 void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept; 449 450template <class T> struct hash; 451 452template <> struct hash<bool>; 453template <> struct hash<char>; 454template <> struct hash<signed char>; 455template <> struct hash<unsigned char>; 456template <> struct hash<char16_t>; 457template <> struct hash<char32_t>; 458template <> struct hash<wchar_t>; 459template <> struct hash<short>; 460template <> struct hash<unsigned short>; 461template <> struct hash<int>; 462template <> struct hash<unsigned int>; 463template <> struct hash<long>; 464template <> struct hash<long long>; 465template <> struct hash<unsigned long>; 466template <> struct hash<unsigned long long>; 467 468template <> struct hash<float>; 469template <> struct hash<double>; 470template <> struct hash<long double>; 471 472template<class T> struct hash<T*>; 473 474} // std 475 476POLICY: For non-variadic implementations, the number of arguments is limited 477 to 3. It is hoped that the need for non-variadic implementations 478 will be minimal. 479 480*/ 481 482#include <__config> 483#include <type_traits> 484#include <typeinfo> 485#include <exception> 486#include <memory> 487#include <tuple> 488#include <utility> 489 490#include <__functional_base> 491 492#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 493#pragma GCC system_header 494#endif 495 496_LIBCPP_BEGIN_NAMESPACE_STD 497 498#if _LIBCPP_STD_VER > 11 499template <class _Tp = void> 500#else 501template <class _Tp> 502#endif 503struct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp> 504{ 505 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 506 _Tp operator()(const _Tp& __x, const _Tp& __y) const 507 {return __x + __y;} 508}; 509 510#if _LIBCPP_STD_VER > 11 511template <> 512struct _LIBCPP_TEMPLATE_VIS plus<void> 513{ 514 template <class _T1, class _T2> 515 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 516 auto operator()(_T1&& __t, _T2&& __u) const 517 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) 518 -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) 519 { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } 520 typedef void is_transparent; 521}; 522#endif 523 524 525#if _LIBCPP_STD_VER > 11 526template <class _Tp = void> 527#else 528template <class _Tp> 529#endif 530struct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp> 531{ 532 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 533 _Tp operator()(const _Tp& __x, const _Tp& __y) const 534 {return __x - __y;} 535}; 536 537#if _LIBCPP_STD_VER > 11 538template <> 539struct _LIBCPP_TEMPLATE_VIS minus<void> 540{ 541 template <class _T1, class _T2> 542 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 543 auto operator()(_T1&& __t, _T2&& __u) const 544 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) 545 -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) 546 { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } 547 typedef void is_transparent; 548}; 549#endif 550 551 552#if _LIBCPP_STD_VER > 11 553template <class _Tp = void> 554#else 555template <class _Tp> 556#endif 557struct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp> 558{ 559 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 560 _Tp operator()(const _Tp& __x, const _Tp& __y) const 561 {return __x * __y;} 562}; 563 564#if _LIBCPP_STD_VER > 11 565template <> 566struct _LIBCPP_TEMPLATE_VIS multiplies<void> 567{ 568 template <class _T1, class _T2> 569 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 570 auto operator()(_T1&& __t, _T2&& __u) const 571 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) 572 -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) 573 { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } 574 typedef void is_transparent; 575}; 576#endif 577 578 579#if _LIBCPP_STD_VER > 11 580template <class _Tp = void> 581#else 582template <class _Tp> 583#endif 584struct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp> 585{ 586 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 587 _Tp operator()(const _Tp& __x, const _Tp& __y) const 588 {return __x / __y;} 589}; 590 591#if _LIBCPP_STD_VER > 11 592template <> 593struct _LIBCPP_TEMPLATE_VIS divides<void> 594{ 595 template <class _T1, class _T2> 596 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 597 auto operator()(_T1&& __t, _T2&& __u) const 598 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) 599 -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) 600 { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } 601 typedef void is_transparent; 602}; 603#endif 604 605 606#if _LIBCPP_STD_VER > 11 607template <class _Tp = void> 608#else 609template <class _Tp> 610#endif 611struct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp> 612{ 613 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 614 _Tp operator()(const _Tp& __x, const _Tp& __y) const 615 {return __x % __y;} 616}; 617 618#if _LIBCPP_STD_VER > 11 619template <> 620struct _LIBCPP_TEMPLATE_VIS modulus<void> 621{ 622 template <class _T1, class _T2> 623 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 624 auto operator()(_T1&& __t, _T2&& __u) const 625 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) 626 -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) 627 { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } 628 typedef void is_transparent; 629}; 630#endif 631 632 633#if _LIBCPP_STD_VER > 11 634template <class _Tp = void> 635#else 636template <class _Tp> 637#endif 638struct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp> 639{ 640 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 641 _Tp operator()(const _Tp& __x) const 642 {return -__x;} 643}; 644 645#if _LIBCPP_STD_VER > 11 646template <> 647struct _LIBCPP_TEMPLATE_VIS negate<void> 648{ 649 template <class _Tp> 650 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 651 auto operator()(_Tp&& __x) const 652 _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) 653 -> decltype (- _VSTD::forward<_Tp>(__x)) 654 { return - _VSTD::forward<_Tp>(__x); } 655 typedef void is_transparent; 656}; 657#endif 658 659 660#if _LIBCPP_STD_VER > 11 661template <class _Tp = void> 662#else 663template <class _Tp> 664#endif 665struct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool> 666{ 667 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 668 bool operator()(const _Tp& __x, const _Tp& __y) const 669 {return __x == __y;} 670}; 671 672#if _LIBCPP_STD_VER > 11 673template <> 674struct _LIBCPP_TEMPLATE_VIS equal_to<void> 675{ 676 template <class _T1, class _T2> 677 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 678 auto operator()(_T1&& __t, _T2&& __u) const 679 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) 680 -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) 681 { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } 682 typedef void is_transparent; 683}; 684#endif 685 686 687#if _LIBCPP_STD_VER > 11 688template <class _Tp = void> 689#else 690template <class _Tp> 691#endif 692struct _LIBCPP_TEMPLATE_VIS not_equal_to : binary_function<_Tp, _Tp, bool> 693{ 694 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 695 bool operator()(const _Tp& __x, const _Tp& __y) const 696 {return __x != __y;} 697}; 698 699#if _LIBCPP_STD_VER > 11 700template <> 701struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> 702{ 703 template <class _T1, class _T2> 704 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 705 auto operator()(_T1&& __t, _T2&& __u) const 706 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) 707 -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) 708 { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } 709 typedef void is_transparent; 710}; 711#endif 712 713 714#if _LIBCPP_STD_VER > 11 715template <class _Tp = void> 716#else 717template <class _Tp> 718#endif 719struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool> 720{ 721 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 722 bool operator()(const _Tp& __x, const _Tp& __y) const 723 {return __x > __y;} 724}; 725 726#if _LIBCPP_STD_VER > 11 727template <> 728struct _LIBCPP_TEMPLATE_VIS greater<void> 729{ 730 template <class _T1, class _T2> 731 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 732 auto operator()(_T1&& __t, _T2&& __u) const 733 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) 734 -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) 735 { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } 736 typedef void is_transparent; 737}; 738#endif 739 740 741// less in <__functional_base> 742 743#if _LIBCPP_STD_VER > 11 744template <class _Tp = void> 745#else 746template <class _Tp> 747#endif 748struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool> 749{ 750 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 751 bool operator()(const _Tp& __x, const _Tp& __y) const 752 {return __x >= __y;} 753}; 754 755#if _LIBCPP_STD_VER > 11 756template <> 757struct _LIBCPP_TEMPLATE_VIS greater_equal<void> 758{ 759 template <class _T1, class _T2> 760 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 761 auto operator()(_T1&& __t, _T2&& __u) const 762 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) 763 -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) 764 { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } 765 typedef void is_transparent; 766}; 767#endif 768 769 770#if _LIBCPP_STD_VER > 11 771template <class _Tp = void> 772#else 773template <class _Tp> 774#endif 775struct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool> 776{ 777 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 778 bool operator()(const _Tp& __x, const _Tp& __y) const 779 {return __x <= __y;} 780}; 781 782#if _LIBCPP_STD_VER > 11 783template <> 784struct _LIBCPP_TEMPLATE_VIS less_equal<void> 785{ 786 template <class _T1, class _T2> 787 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 788 auto operator()(_T1&& __t, _T2&& __u) const 789 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) 790 -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) 791 { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } 792 typedef void is_transparent; 793}; 794#endif 795 796 797#if _LIBCPP_STD_VER > 11 798template <class _Tp = void> 799#else 800template <class _Tp> 801#endif 802struct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool> 803{ 804 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 805 bool operator()(const _Tp& __x, const _Tp& __y) const 806 {return __x && __y;} 807}; 808 809#if _LIBCPP_STD_VER > 11 810template <> 811struct _LIBCPP_TEMPLATE_VIS logical_and<void> 812{ 813 template <class _T1, class _T2> 814 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 815 auto operator()(_T1&& __t, _T2&& __u) const 816 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) 817 -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) 818 { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } 819 typedef void is_transparent; 820}; 821#endif 822 823 824#if _LIBCPP_STD_VER > 11 825template <class _Tp = void> 826#else 827template <class _Tp> 828#endif 829struct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool> 830{ 831 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 832 bool operator()(const _Tp& __x, const _Tp& __y) const 833 {return __x || __y;} 834}; 835 836#if _LIBCPP_STD_VER > 11 837template <> 838struct _LIBCPP_TEMPLATE_VIS logical_or<void> 839{ 840 template <class _T1, class _T2> 841 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 842 auto operator()(_T1&& __t, _T2&& __u) const 843 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) 844 -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) 845 { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } 846 typedef void is_transparent; 847}; 848#endif 849 850 851#if _LIBCPP_STD_VER > 11 852template <class _Tp = void> 853#else 854template <class _Tp> 855#endif 856struct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool> 857{ 858 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 859 bool operator()(const _Tp& __x) const 860 {return !__x;} 861}; 862 863#if _LIBCPP_STD_VER > 11 864template <> 865struct _LIBCPP_TEMPLATE_VIS logical_not<void> 866{ 867 template <class _Tp> 868 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 869 auto operator()(_Tp&& __x) const 870 _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) 871 -> decltype (!_VSTD::forward<_Tp>(__x)) 872 { return !_VSTD::forward<_Tp>(__x); } 873 typedef void is_transparent; 874}; 875#endif 876 877 878#if _LIBCPP_STD_VER > 11 879template <class _Tp = void> 880#else 881template <class _Tp> 882#endif 883struct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp> 884{ 885 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 886 _Tp operator()(const _Tp& __x, const _Tp& __y) const 887 {return __x & __y;} 888}; 889 890#if _LIBCPP_STD_VER > 11 891template <> 892struct _LIBCPP_TEMPLATE_VIS bit_and<void> 893{ 894 template <class _T1, class _T2> 895 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 896 auto operator()(_T1&& __t, _T2&& __u) const 897 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) 898 -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) 899 { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } 900 typedef void is_transparent; 901}; 902#endif 903 904 905#if _LIBCPP_STD_VER > 11 906template <class _Tp = void> 907#else 908template <class _Tp> 909#endif 910struct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp> 911{ 912 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 913 _Tp operator()(const _Tp& __x, const _Tp& __y) const 914 {return __x | __y;} 915}; 916 917#if _LIBCPP_STD_VER > 11 918template <> 919struct _LIBCPP_TEMPLATE_VIS bit_or<void> 920{ 921 template <class _T1, class _T2> 922 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 923 auto operator()(_T1&& __t, _T2&& __u) const 924 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) 925 -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) 926 { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } 927 typedef void is_transparent; 928}; 929#endif 930 931 932#if _LIBCPP_STD_VER > 11 933template <class _Tp = void> 934#else 935template <class _Tp> 936#endif 937struct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp> 938{ 939 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 940 _Tp operator()(const _Tp& __x, const _Tp& __y) const 941 {return __x ^ __y;} 942}; 943 944#if _LIBCPP_STD_VER > 11 945template <> 946struct _LIBCPP_TEMPLATE_VIS bit_xor<void> 947{ 948 template <class _T1, class _T2> 949 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 950 auto operator()(_T1&& __t, _T2&& __u) const 951 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) 952 -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) 953 { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } 954 typedef void is_transparent; 955}; 956#endif 957 958 959#if _LIBCPP_STD_VER > 11 960template <class _Tp = void> 961struct _LIBCPP_TEMPLATE_VIS bit_not : unary_function<_Tp, _Tp> 962{ 963 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 964 _Tp operator()(const _Tp& __x) const 965 {return ~__x;} 966}; 967 968template <> 969struct _LIBCPP_TEMPLATE_VIS bit_not<void> 970{ 971 template <class _Tp> 972 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 973 auto operator()(_Tp&& __x) const 974 _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) 975 -> decltype (~_VSTD::forward<_Tp>(__x)) 976 { return ~_VSTD::forward<_Tp>(__x); } 977 typedef void is_transparent; 978}; 979#endif 980 981template <class _Predicate> 982class _LIBCPP_TEMPLATE_VIS unary_negate 983 : public unary_function<typename _Predicate::argument_type, bool> 984{ 985 _Predicate __pred_; 986public: 987 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 988 explicit unary_negate(const _Predicate& __pred) 989 : __pred_(__pred) {} 990 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 991 bool operator()(const typename _Predicate::argument_type& __x) const 992 {return !__pred_(__x);} 993}; 994 995template <class _Predicate> 996inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 997unary_negate<_Predicate> 998not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} 999 1000template <class _Predicate> 1001class _LIBCPP_TEMPLATE_VIS binary_negate 1002 : public binary_function<typename _Predicate::first_argument_type, 1003 typename _Predicate::second_argument_type, 1004 bool> 1005{ 1006 _Predicate __pred_; 1007public: 1008 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 1009 binary_negate(const _Predicate& __pred) : __pred_(__pred) {} 1010 1011 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1012 bool operator()(const typename _Predicate::first_argument_type& __x, 1013 const typename _Predicate::second_argument_type& __y) const 1014 {return !__pred_(__x, __y);} 1015}; 1016 1017template <class _Predicate> 1018inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1019binary_negate<_Predicate> 1020not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} 1021 1022template <class __Operation> 1023class _LIBCPP_TEMPLATE_VIS binder1st 1024 : public unary_function<typename __Operation::second_argument_type, 1025 typename __Operation::result_type> 1026{ 1027protected: 1028 __Operation op; 1029 typename __Operation::first_argument_type value; 1030public: 1031 _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, 1032 const typename __Operation::first_argument_type __y) 1033 : op(__x), value(__y) {} 1034 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1035 (typename __Operation::second_argument_type& __x) const 1036 {return op(value, __x);} 1037 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1038 (const typename __Operation::second_argument_type& __x) const 1039 {return op(value, __x);} 1040}; 1041 1042template <class __Operation, class _Tp> 1043inline _LIBCPP_INLINE_VISIBILITY 1044binder1st<__Operation> 1045bind1st(const __Operation& __op, const _Tp& __x) 1046 {return binder1st<__Operation>(__op, __x);} 1047 1048template <class __Operation> 1049class _LIBCPP_TEMPLATE_VIS binder2nd 1050 : public unary_function<typename __Operation::first_argument_type, 1051 typename __Operation::result_type> 1052{ 1053protected: 1054 __Operation op; 1055 typename __Operation::second_argument_type value; 1056public: 1057 _LIBCPP_INLINE_VISIBILITY 1058 binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) 1059 : op(__x), value(__y) {} 1060 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1061 ( typename __Operation::first_argument_type& __x) const 1062 {return op(__x, value);} 1063 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1064 (const typename __Operation::first_argument_type& __x) const 1065 {return op(__x, value);} 1066}; 1067 1068template <class __Operation, class _Tp> 1069inline _LIBCPP_INLINE_VISIBILITY 1070binder2nd<__Operation> 1071bind2nd(const __Operation& __op, const _Tp& __x) 1072 {return binder2nd<__Operation>(__op, __x);} 1073 1074template <class _Arg, class _Result> 1075class _LIBCPP_TEMPLATE_VIS pointer_to_unary_function 1076 : public unary_function<_Arg, _Result> 1077{ 1078 _Result (*__f_)(_Arg); 1079public: 1080 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) 1081 : __f_(__f) {} 1082 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const 1083 {return __f_(__x);} 1084}; 1085 1086template <class _Arg, class _Result> 1087inline _LIBCPP_INLINE_VISIBILITY 1088pointer_to_unary_function<_Arg,_Result> 1089ptr_fun(_Result (*__f)(_Arg)) 1090 {return pointer_to_unary_function<_Arg,_Result>(__f);} 1091 1092template <class _Arg1, class _Arg2, class _Result> 1093class _LIBCPP_TEMPLATE_VIS pointer_to_binary_function 1094 : public binary_function<_Arg1, _Arg2, _Result> 1095{ 1096 _Result (*__f_)(_Arg1, _Arg2); 1097public: 1098 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) 1099 : __f_(__f) {} 1100 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const 1101 {return __f_(__x, __y);} 1102}; 1103 1104template <class _Arg1, class _Arg2, class _Result> 1105inline _LIBCPP_INLINE_VISIBILITY 1106pointer_to_binary_function<_Arg1,_Arg2,_Result> 1107ptr_fun(_Result (*__f)(_Arg1,_Arg2)) 1108 {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} 1109 1110template<class _Sp, class _Tp> 1111class _LIBCPP_TEMPLATE_VIS mem_fun_t : public unary_function<_Tp*, _Sp> 1112{ 1113 _Sp (_Tp::*__p_)(); 1114public: 1115 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) 1116 : __p_(__p) {} 1117 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const 1118 {return (__p->*__p_)();} 1119}; 1120 1121template<class _Sp, class _Tp, class _Ap> 1122class _LIBCPP_TEMPLATE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> 1123{ 1124 _Sp (_Tp::*__p_)(_Ap); 1125public: 1126 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) 1127 : __p_(__p) {} 1128 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const 1129 {return (__p->*__p_)(__x);} 1130}; 1131 1132template<class _Sp, class _Tp> 1133inline _LIBCPP_INLINE_VISIBILITY 1134mem_fun_t<_Sp,_Tp> 1135mem_fun(_Sp (_Tp::*__f)()) 1136 {return mem_fun_t<_Sp,_Tp>(__f);} 1137 1138template<class _Sp, class _Tp, class _Ap> 1139inline _LIBCPP_INLINE_VISIBILITY 1140mem_fun1_t<_Sp,_Tp,_Ap> 1141mem_fun(_Sp (_Tp::*__f)(_Ap)) 1142 {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 1143 1144template<class _Sp, class _Tp> 1145class _LIBCPP_TEMPLATE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp> 1146{ 1147 _Sp (_Tp::*__p_)(); 1148public: 1149 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) 1150 : __p_(__p) {} 1151 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const 1152 {return (__p.*__p_)();} 1153}; 1154 1155template<class _Sp, class _Tp, class _Ap> 1156class _LIBCPP_TEMPLATE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> 1157{ 1158 _Sp (_Tp::*__p_)(_Ap); 1159public: 1160 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) 1161 : __p_(__p) {} 1162 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const 1163 {return (__p.*__p_)(__x);} 1164}; 1165 1166template<class _Sp, class _Tp> 1167inline _LIBCPP_INLINE_VISIBILITY 1168mem_fun_ref_t<_Sp,_Tp> 1169mem_fun_ref(_Sp (_Tp::*__f)()) 1170 {return mem_fun_ref_t<_Sp,_Tp>(__f);} 1171 1172template<class _Sp, class _Tp, class _Ap> 1173inline _LIBCPP_INLINE_VISIBILITY 1174mem_fun1_ref_t<_Sp,_Tp,_Ap> 1175mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) 1176 {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 1177 1178template <class _Sp, class _Tp> 1179class _LIBCPP_TEMPLATE_VIS const_mem_fun_t : public unary_function<const _Tp*, _Sp> 1180{ 1181 _Sp (_Tp::*__p_)() const; 1182public: 1183 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) 1184 : __p_(__p) {} 1185 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const 1186 {return (__p->*__p_)();} 1187}; 1188 1189template <class _Sp, class _Tp, class _Ap> 1190class _LIBCPP_TEMPLATE_VIS const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp> 1191{ 1192 _Sp (_Tp::*__p_)(_Ap) const; 1193public: 1194 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) 1195 : __p_(__p) {} 1196 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const 1197 {return (__p->*__p_)(__x);} 1198}; 1199 1200template <class _Sp, class _Tp> 1201inline _LIBCPP_INLINE_VISIBILITY 1202const_mem_fun_t<_Sp,_Tp> 1203mem_fun(_Sp (_Tp::*__f)() const) 1204 {return const_mem_fun_t<_Sp,_Tp>(__f);} 1205 1206template <class _Sp, class _Tp, class _Ap> 1207inline _LIBCPP_INLINE_VISIBILITY 1208const_mem_fun1_t<_Sp,_Tp,_Ap> 1209mem_fun(_Sp (_Tp::*__f)(_Ap) const) 1210 {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 1211 1212template <class _Sp, class _Tp> 1213class _LIBCPP_TEMPLATE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp> 1214{ 1215 _Sp (_Tp::*__p_)() const; 1216public: 1217 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) 1218 : __p_(__p) {} 1219 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const 1220 {return (__p.*__p_)();} 1221}; 1222 1223template <class _Sp, class _Tp, class _Ap> 1224class _LIBCPP_TEMPLATE_VIS const_mem_fun1_ref_t 1225 : public binary_function<_Tp, _Ap, _Sp> 1226{ 1227 _Sp (_Tp::*__p_)(_Ap) const; 1228public: 1229 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) 1230 : __p_(__p) {} 1231 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const 1232 {return (__p.*__p_)(__x);} 1233}; 1234 1235template <class _Sp, class _Tp> 1236inline _LIBCPP_INLINE_VISIBILITY 1237const_mem_fun_ref_t<_Sp,_Tp> 1238mem_fun_ref(_Sp (_Tp::*__f)() const) 1239 {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} 1240 1241template <class _Sp, class _Tp, class _Ap> 1242inline _LIBCPP_INLINE_VISIBILITY 1243const_mem_fun1_ref_t<_Sp,_Tp,_Ap> 1244mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) 1245 {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 1246 1247//////////////////////////////////////////////////////////////////////////////// 1248// MEMFUN 1249//============================================================================== 1250 1251template <class _Tp> 1252class __mem_fn 1253 : public __weak_result_type<_Tp> 1254{ 1255public: 1256 // types 1257 typedef _Tp type; 1258private: 1259 type __f_; 1260 1261public: 1262 _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} 1263 1264#ifndef _LIBCPP_HAS_NO_VARIADICS 1265 // invoke 1266 template <class... _ArgTypes> 1267 _LIBCPP_INLINE_VISIBILITY 1268 typename __invoke_return<type, _ArgTypes...>::type 1269 operator() (_ArgTypes&&... __args) const { 1270 return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); 1271 } 1272#else 1273 1274 template <class _A0> 1275 _LIBCPP_INLINE_VISIBILITY 1276 typename __invoke_return0<type, _A0>::type 1277 operator() (_A0& __a0) const { 1278 return __invoke(__f_, __a0); 1279 } 1280 1281 template <class _A0> 1282 _LIBCPP_INLINE_VISIBILITY 1283 typename __invoke_return0<type, _A0 const>::type 1284 operator() (_A0 const& __a0) const { 1285 return __invoke(__f_, __a0); 1286 } 1287 1288 template <class _A0, class _A1> 1289 _LIBCPP_INLINE_VISIBILITY 1290 typename __invoke_return1<type, _A0, _A1>::type 1291 operator() (_A0& __a0, _A1& __a1) const { 1292 return __invoke(__f_, __a0, __a1); 1293 } 1294 1295 template <class _A0, class _A1> 1296 _LIBCPP_INLINE_VISIBILITY 1297 typename __invoke_return1<type, _A0 const, _A1>::type 1298 operator() (_A0 const& __a0, _A1& __a1) const { 1299 return __invoke(__f_, __a0, __a1); 1300 } 1301 1302 template <class _A0, class _A1> 1303 _LIBCPP_INLINE_VISIBILITY 1304 typename __invoke_return1<type, _A0, _A1 const>::type 1305 operator() (_A0& __a0, _A1 const& __a1) const { 1306 return __invoke(__f_, __a0, __a1); 1307 } 1308 1309 template <class _A0, class _A1> 1310 _LIBCPP_INLINE_VISIBILITY 1311 typename __invoke_return1<type, _A0 const, _A1 const>::type 1312 operator() (_A0 const& __a0, _A1 const& __a1) const { 1313 return __invoke(__f_, __a0, __a1); 1314 } 1315 1316 template <class _A0, class _A1, class _A2> 1317 _LIBCPP_INLINE_VISIBILITY 1318 typename __invoke_return2<type, _A0, _A1, _A2>::type 1319 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { 1320 return __invoke(__f_, __a0, __a1, __a2); 1321 } 1322 1323 template <class _A0, class _A1, class _A2> 1324 _LIBCPP_INLINE_VISIBILITY 1325 typename __invoke_return2<type, _A0 const, _A1, _A2>::type 1326 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { 1327 return __invoke(__f_, __a0, __a1, __a2); 1328 } 1329 1330 template <class _A0, class _A1, class _A2> 1331 _LIBCPP_INLINE_VISIBILITY 1332 typename __invoke_return2<type, _A0, _A1 const, _A2>::type 1333 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { 1334 return __invoke(__f_, __a0, __a1, __a2); 1335 } 1336 1337 template <class _A0, class _A1, class _A2> 1338 _LIBCPP_INLINE_VISIBILITY 1339 typename __invoke_return2<type, _A0, _A1, _A2 const>::type 1340 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { 1341 return __invoke(__f_, __a0, __a1, __a2); 1342 } 1343 1344 template <class _A0, class _A1, class _A2> 1345 _LIBCPP_INLINE_VISIBILITY 1346 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type 1347 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { 1348 return __invoke(__f_, __a0, __a1, __a2); 1349 } 1350 1351 template <class _A0, class _A1, class _A2> 1352 _LIBCPP_INLINE_VISIBILITY 1353 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type 1354 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { 1355 return __invoke(__f_, __a0, __a1, __a2); 1356 } 1357 1358 template <class _A0, class _A1, class _A2> 1359 _LIBCPP_INLINE_VISIBILITY 1360 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type 1361 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { 1362 return __invoke(__f_, __a0, __a1, __a2); 1363 } 1364 1365 template <class _A0, class _A1, class _A2> 1366 _LIBCPP_INLINE_VISIBILITY 1367 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type 1368 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { 1369 return __invoke(__f_, __a0, __a1, __a2); 1370 } 1371#endif 1372}; 1373 1374template<class _Rp, class _Tp> 1375inline _LIBCPP_INLINE_VISIBILITY 1376__mem_fn<_Rp _Tp::*> 1377mem_fn(_Rp _Tp::* __pm) _NOEXCEPT 1378{ 1379 return __mem_fn<_Rp _Tp::*>(__pm); 1380} 1381 1382//////////////////////////////////////////////////////////////////////////////// 1383// FUNCTION 1384//============================================================================== 1385 1386// bad_function_call 1387 1388class _LIBCPP_EXCEPTION_ABI bad_function_call 1389 : public exception 1390{ 1391}; 1392 1393_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE 1394void __throw_bad_function_call() 1395{ 1396#ifndef _LIBCPP_NO_EXCEPTIONS 1397 throw bad_function_call(); 1398#else 1399 _VSTD::abort(); 1400#endif 1401} 1402 1403template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined 1404 1405namespace __function 1406{ 1407 1408template<class _Rp> 1409struct __maybe_derive_from_unary_function 1410{ 1411}; 1412 1413template<class _Rp, class _A1> 1414struct __maybe_derive_from_unary_function<_Rp(_A1)> 1415 : public unary_function<_A1, _Rp> 1416{ 1417}; 1418 1419template<class _Rp> 1420struct __maybe_derive_from_binary_function 1421{ 1422}; 1423 1424template<class _Rp, class _A1, class _A2> 1425struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> 1426 : public binary_function<_A1, _A2, _Rp> 1427{ 1428}; 1429 1430template <class _Fp> 1431_LIBCPP_INLINE_VISIBILITY 1432bool __not_null(_Fp const&) { return true; } 1433 1434template <class _Fp> 1435_LIBCPP_INLINE_VISIBILITY 1436bool __not_null(_Fp* __ptr) { return __ptr; } 1437 1438template <class _Ret, class _Class> 1439_LIBCPP_INLINE_VISIBILITY 1440bool __not_null(_Ret _Class::*__ptr) { return __ptr; } 1441 1442template <class _Fp> 1443_LIBCPP_INLINE_VISIBILITY 1444bool __not_null(function<_Fp> const& __f) { return !!__f; } 1445 1446} // namespace __function 1447 1448#ifndef _LIBCPP_HAS_NO_VARIADICS 1449 1450namespace __function { 1451 1452template<class _Fp> class __base; 1453 1454template<class _Rp, class ..._ArgTypes> 1455class __base<_Rp(_ArgTypes...)> 1456{ 1457 __base(const __base&); 1458 __base& operator=(const __base&); 1459public: 1460 _LIBCPP_INLINE_VISIBILITY __base() {} 1461 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} 1462 virtual __base* __clone() const = 0; 1463 virtual void __clone(__base*) const = 0; 1464 virtual void destroy() _NOEXCEPT = 0; 1465 virtual void destroy_deallocate() _NOEXCEPT = 0; 1466 virtual _Rp operator()(_ArgTypes&& ...) = 0; 1467#ifndef _LIBCPP_NO_RTTI 1468 virtual const void* target(const type_info&) const _NOEXCEPT = 0; 1469 virtual const std::type_info& target_type() const _NOEXCEPT = 0; 1470#endif // _LIBCPP_NO_RTTI 1471}; 1472 1473template<class _FD, class _Alloc, class _FB> class __func; 1474 1475template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1476class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> 1477 : public __base<_Rp(_ArgTypes...)> 1478{ 1479 __compressed_pair<_Fp, _Alloc> __f_; 1480public: 1481 _LIBCPP_INLINE_VISIBILITY 1482 explicit __func(_Fp&& __f) 1483 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1484 _VSTD::forward_as_tuple()) {} 1485 _LIBCPP_INLINE_VISIBILITY 1486 explicit __func(const _Fp& __f, const _Alloc& __a) 1487 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1488 _VSTD::forward_as_tuple(__a)) {} 1489 1490 _LIBCPP_INLINE_VISIBILITY 1491 explicit __func(const _Fp& __f, _Alloc&& __a) 1492 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1493 _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1494 1495 _LIBCPP_INLINE_VISIBILITY 1496 explicit __func(_Fp&& __f, _Alloc&& __a) 1497 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1498 _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1499 virtual __base<_Rp(_ArgTypes...)>* __clone() const; 1500 virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; 1501 virtual void destroy() _NOEXCEPT; 1502 virtual void destroy_deallocate() _NOEXCEPT; 1503 virtual _Rp operator()(_ArgTypes&& ... __arg); 1504#ifndef _LIBCPP_NO_RTTI 1505 virtual const void* target(const type_info&) const _NOEXCEPT; 1506 virtual const std::type_info& target_type() const _NOEXCEPT; 1507#endif // _LIBCPP_NO_RTTI 1508}; 1509 1510template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1511__base<_Rp(_ArgTypes...)>* 1512__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const 1513{ 1514 typedef allocator_traits<_Alloc> __alloc_traits; 1515 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; 1516 _Ap __a(__f_.second()); 1517 typedef __allocator_destructor<_Ap> _Dp; 1518 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1519 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); 1520 return __hold.release(); 1521} 1522 1523template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1524void 1525__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const 1526{ 1527 ::new (__p) __func(__f_.first(), __f_.second()); 1528} 1529 1530template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1531void 1532__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT 1533{ 1534 __f_.~__compressed_pair<_Fp, _Alloc>(); 1535} 1536 1537template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1538void 1539__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT 1540{ 1541 typedef allocator_traits<_Alloc> __alloc_traits; 1542 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; 1543 _Ap __a(__f_.second()); 1544 __f_.~__compressed_pair<_Fp, _Alloc>(); 1545 __a.deallocate(this, 1); 1546} 1547 1548template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1549_Rp 1550__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) 1551{ 1552 typedef __invoke_void_return_wrapper<_Rp> _Invoker; 1553 return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); 1554} 1555 1556#ifndef _LIBCPP_NO_RTTI 1557 1558template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1559const void* 1560__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT 1561{ 1562 if (__ti == typeid(_Fp)) 1563 return &__f_.first(); 1564 return (const void*)0; 1565} 1566 1567template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1568const std::type_info& 1569__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1570{ 1571 return typeid(_Fp); 1572} 1573 1574#endif // _LIBCPP_NO_RTTI 1575 1576} // __function 1577 1578template<class _Rp, class ..._ArgTypes> 1579class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> 1580 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, 1581 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> 1582{ 1583 typedef __function::__base<_Rp(_ArgTypes...)> __base; 1584 typename aligned_storage<3*sizeof(void*)>::type __buf_; 1585 __base* __f_; 1586 1587 _LIBCPP_NO_CFI static __base *__as_base(void *p) { 1588 return reinterpret_cast<__base*>(p); 1589 } 1590 1591 template <class _Fp, bool = !is_same<_Fp, function>::value && 1592 __invokable<_Fp&, _ArgTypes...>::value> 1593 struct __callable; 1594 template <class _Fp> 1595 struct __callable<_Fp, true> 1596 { 1597 static const bool value = is_same<void, _Rp>::value || 1598 is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type, 1599 _Rp>::value; 1600 }; 1601 template <class _Fp> 1602 struct __callable<_Fp, false> 1603 { 1604 static const bool value = false; 1605 }; 1606public: 1607 typedef _Rp result_type; 1608 1609 // construct/copy/destroy: 1610 _LIBCPP_INLINE_VISIBILITY 1611 function() _NOEXCEPT : __f_(0) {} 1612 _LIBCPP_INLINE_VISIBILITY 1613 function(nullptr_t) _NOEXCEPT : __f_(0) {} 1614 function(const function&); 1615 function(function&&) _NOEXCEPT; 1616 template<class _Fp, class = typename enable_if< 1617 __callable<_Fp>::value && !is_same<_Fp, function>::value 1618 >::type> 1619 function(_Fp); 1620 1621#if _LIBCPP_STD_VER <= 14 1622 template<class _Alloc> 1623 _LIBCPP_INLINE_VISIBILITY 1624 function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} 1625 template<class _Alloc> 1626 _LIBCPP_INLINE_VISIBILITY 1627 function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {} 1628 template<class _Alloc> 1629 function(allocator_arg_t, const _Alloc&, const function&); 1630 template<class _Alloc> 1631 function(allocator_arg_t, const _Alloc&, function&&); 1632 template<class _Fp, class _Alloc, class = typename enable_if<__callable<_Fp>::value>::type> 1633 function(allocator_arg_t, const _Alloc& __a, _Fp __f); 1634#endif 1635 1636 function& operator=(const function&); 1637 function& operator=(function&&) _NOEXCEPT; 1638 function& operator=(nullptr_t) _NOEXCEPT; 1639 template<class _Fp> 1640 typename enable_if 1641 < 1642 __callable<typename decay<_Fp>::type>::value && 1643 !is_same<typename remove_reference<_Fp>::type, function>::value, 1644 function& 1645 >::type 1646 operator=(_Fp&&); 1647 1648 ~function(); 1649 1650 // function modifiers: 1651 void swap(function&) _NOEXCEPT; 1652 1653#if _LIBCPP_STD_VER <= 14 1654 template<class _Fp, class _Alloc> 1655 _LIBCPP_INLINE_VISIBILITY 1656 void assign(_Fp&& __f, const _Alloc& __a) 1657 {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} 1658#endif 1659 1660 // function capacity: 1661 _LIBCPP_INLINE_VISIBILITY 1662 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;} 1663 1664 // deleted overloads close possible hole in the type system 1665 template<class _R2, class... _ArgTypes2> 1666 bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; 1667 template<class _R2, class... _ArgTypes2> 1668 bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; 1669public: 1670 // function invocation: 1671 _Rp operator()(_ArgTypes...) const; 1672 1673#ifndef _LIBCPP_NO_RTTI 1674 // function target access: 1675 const std::type_info& target_type() const _NOEXCEPT; 1676 template <typename _Tp> _Tp* target() _NOEXCEPT; 1677 template <typename _Tp> const _Tp* target() const _NOEXCEPT; 1678#endif // _LIBCPP_NO_RTTI 1679}; 1680 1681template<class _Rp, class ..._ArgTypes> 1682function<_Rp(_ArgTypes...)>::function(const function& __f) 1683{ 1684 if (__f.__f_ == 0) 1685 __f_ = 0; 1686 else if ((void *)__f.__f_ == &__f.__buf_) 1687 { 1688 __f_ = __as_base(&__buf_); 1689 __f.__f_->__clone(__f_); 1690 } 1691 else 1692 __f_ = __f.__f_->__clone(); 1693} 1694 1695#if _LIBCPP_STD_VER <= 14 1696template<class _Rp, class ..._ArgTypes> 1697template <class _Alloc> 1698function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1699 const function& __f) 1700{ 1701 if (__f.__f_ == 0) 1702 __f_ = 0; 1703 else if ((void *)__f.__f_ == &__f.__buf_) 1704 { 1705 __f_ = __as_base(&__buf_); 1706 __f.__f_->__clone(__f_); 1707 } 1708 else 1709 __f_ = __f.__f_->__clone(); 1710} 1711#endif 1712 1713template<class _Rp, class ..._ArgTypes> 1714function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT 1715{ 1716 if (__f.__f_ == 0) 1717 __f_ = 0; 1718 else if ((void *)__f.__f_ == &__f.__buf_) 1719 { 1720 __f_ = __as_base(&__buf_); 1721 __f.__f_->__clone(__f_); 1722 } 1723 else 1724 { 1725 __f_ = __f.__f_; 1726 __f.__f_ = 0; 1727 } 1728} 1729 1730#if _LIBCPP_STD_VER <= 14 1731template<class _Rp, class ..._ArgTypes> 1732template <class _Alloc> 1733function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1734 function&& __f) 1735{ 1736 if (__f.__f_ == 0) 1737 __f_ = 0; 1738 else if ((void *)__f.__f_ == &__f.__buf_) 1739 { 1740 __f_ = __as_base(&__buf_); 1741 __f.__f_->__clone(__f_); 1742 } 1743 else 1744 { 1745 __f_ = __f.__f_; 1746 __f.__f_ = 0; 1747 } 1748} 1749#endif 1750 1751template<class _Rp, class ..._ArgTypes> 1752template <class _Fp, class> 1753function<_Rp(_ArgTypes...)>::function(_Fp __f) 1754 : __f_(0) 1755{ 1756 if (__function::__not_null(__f)) 1757 { 1758 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; 1759 if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) 1760 { 1761 __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f)); 1762 } 1763 else 1764 { 1765 typedef allocator<_FF> _Ap; 1766 _Ap __a; 1767 typedef __allocator_destructor<_Ap> _Dp; 1768 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1769 ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a)); 1770 __f_ = __hold.release(); 1771 } 1772 } 1773} 1774 1775#if _LIBCPP_STD_VER <= 14 1776template<class _Rp, class ..._ArgTypes> 1777template <class _Fp, class _Alloc, class> 1778function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f) 1779 : __f_(0) 1780{ 1781 typedef allocator_traits<_Alloc> __alloc_traits; 1782 if (__function::__not_null(__f)) 1783 { 1784 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; 1785 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; 1786 _Ap __a(__a0); 1787 if (sizeof(_FF) <= sizeof(__buf_) && 1788 is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value) 1789 { 1790 __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a)); 1791 } 1792 else 1793 { 1794 typedef __allocator_destructor<_Ap> _Dp; 1795 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1796 ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); 1797 __f_ = __hold.release(); 1798 } 1799 } 1800} 1801#endif 1802 1803template<class _Rp, class ..._ArgTypes> 1804function<_Rp(_ArgTypes...)>& 1805function<_Rp(_ArgTypes...)>::operator=(const function& __f) 1806{ 1807 function(__f).swap(*this); 1808 return *this; 1809} 1810 1811template<class _Rp, class ..._ArgTypes> 1812function<_Rp(_ArgTypes...)>& 1813function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT 1814{ 1815 if ((void *)__f_ == &__buf_) 1816 __f_->destroy(); 1817 else if (__f_) 1818 __f_->destroy_deallocate(); 1819 __f_ = 0; 1820 if (__f.__f_ == 0) 1821 __f_ = 0; 1822 else if ((void *)__f.__f_ == &__f.__buf_) 1823 { 1824 __f_ = __as_base(&__buf_); 1825 __f.__f_->__clone(__f_); 1826 } 1827 else 1828 { 1829 __f_ = __f.__f_; 1830 __f.__f_ = 0; 1831 } 1832 return *this; 1833} 1834 1835template<class _Rp, class ..._ArgTypes> 1836function<_Rp(_ArgTypes...)>& 1837function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT 1838{ 1839 if ((void *)__f_ == &__buf_) 1840 __f_->destroy(); 1841 else if (__f_) 1842 __f_->destroy_deallocate(); 1843 __f_ = 0; 1844 return *this; 1845} 1846 1847template<class _Rp, class ..._ArgTypes> 1848template <class _Fp> 1849typename enable_if 1850< 1851 function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value && 1852 !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value, 1853 function<_Rp(_ArgTypes...)>& 1854>::type 1855function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) 1856{ 1857 function(_VSTD::forward<_Fp>(__f)).swap(*this); 1858 return *this; 1859} 1860 1861template<class _Rp, class ..._ArgTypes> 1862function<_Rp(_ArgTypes...)>::~function() 1863{ 1864 if ((void *)__f_ == &__buf_) 1865 __f_->destroy(); 1866 else if (__f_) 1867 __f_->destroy_deallocate(); 1868} 1869 1870template<class _Rp, class ..._ArgTypes> 1871void 1872function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT 1873{ 1874 if (_VSTD::addressof(__f) == this) 1875 return; 1876 if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_) 1877 { 1878 typename aligned_storage<sizeof(__buf_)>::type __tempbuf; 1879 __base* __t = __as_base(&__tempbuf); 1880 __f_->__clone(__t); 1881 __f_->destroy(); 1882 __f_ = 0; 1883 __f.__f_->__clone(__as_base(&__buf_)); 1884 __f.__f_->destroy(); 1885 __f.__f_ = 0; 1886 __f_ = __as_base(&__buf_); 1887 __t->__clone(__as_base(&__f.__buf_)); 1888 __t->destroy(); 1889 __f.__f_ = __as_base(&__f.__buf_); 1890 } 1891 else if ((void *)__f_ == &__buf_) 1892 { 1893 __f_->__clone(__as_base(&__f.__buf_)); 1894 __f_->destroy(); 1895 __f_ = __f.__f_; 1896 __f.__f_ = __as_base(&__f.__buf_); 1897 } 1898 else if ((void *)__f.__f_ == &__f.__buf_) 1899 { 1900 __f.__f_->__clone(__as_base(&__buf_)); 1901 __f.__f_->destroy(); 1902 __f.__f_ = __f_; 1903 __f_ = __as_base(&__buf_); 1904 } 1905 else 1906 _VSTD::swap(__f_, __f.__f_); 1907} 1908 1909template<class _Rp, class ..._ArgTypes> 1910_Rp 1911function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const 1912{ 1913 if (__f_ == 0) 1914 __throw_bad_function_call(); 1915 return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); 1916} 1917 1918#ifndef _LIBCPP_NO_RTTI 1919 1920template<class _Rp, class ..._ArgTypes> 1921const std::type_info& 1922function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1923{ 1924 if (__f_ == 0) 1925 return typeid(void); 1926 return __f_->target_type(); 1927} 1928 1929template<class _Rp, class ..._ArgTypes> 1930template <typename _Tp> 1931_Tp* 1932function<_Rp(_ArgTypes...)>::target() _NOEXCEPT 1933{ 1934 if (__f_ == 0) 1935 return (_Tp*)0; 1936 return (_Tp*)__f_->target(typeid(_Tp)); 1937} 1938 1939template<class _Rp, class ..._ArgTypes> 1940template <typename _Tp> 1941const _Tp* 1942function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT 1943{ 1944 if (__f_ == 0) 1945 return (const _Tp*)0; 1946 return (const _Tp*)__f_->target(typeid(_Tp)); 1947} 1948 1949#endif // _LIBCPP_NO_RTTI 1950 1951template <class _Rp, class... _ArgTypes> 1952inline _LIBCPP_INLINE_VISIBILITY 1953bool 1954operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} 1955 1956template <class _Rp, class... _ArgTypes> 1957inline _LIBCPP_INLINE_VISIBILITY 1958bool 1959operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} 1960 1961template <class _Rp, class... _ArgTypes> 1962inline _LIBCPP_INLINE_VISIBILITY 1963bool 1964operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} 1965 1966template <class _Rp, class... _ArgTypes> 1967inline _LIBCPP_INLINE_VISIBILITY 1968bool 1969operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} 1970 1971template <class _Rp, class... _ArgTypes> 1972inline _LIBCPP_INLINE_VISIBILITY 1973void 1974swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT 1975{return __x.swap(__y);} 1976 1977#else // _LIBCPP_HAS_NO_VARIADICS 1978 1979#include <__functional_03> 1980 1981#endif 1982 1983//////////////////////////////////////////////////////////////////////////////// 1984// BIND 1985//============================================================================== 1986 1987template<class _Tp> struct __is_bind_expression : public false_type {}; 1988template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression 1989 : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; 1990 1991#if _LIBCPP_STD_VER > 14 1992template <class _Tp> 1993constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; 1994#endif 1995 1996template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; 1997template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder 1998 : public __is_placeholder<typename remove_cv<_Tp>::type> {}; 1999 2000#if _LIBCPP_STD_VER > 14 2001template <class _Tp> 2002constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; 2003#endif 2004 2005namespace placeholders 2006{ 2007 2008template <int _Np> struct __ph {}; 2009 2010#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND) 2011_LIBCPP_FUNC_VIS extern const __ph<1> _1; 2012_LIBCPP_FUNC_VIS extern const __ph<2> _2; 2013_LIBCPP_FUNC_VIS extern const __ph<3> _3; 2014_LIBCPP_FUNC_VIS extern const __ph<4> _4; 2015_LIBCPP_FUNC_VIS extern const __ph<5> _5; 2016_LIBCPP_FUNC_VIS extern const __ph<6> _6; 2017_LIBCPP_FUNC_VIS extern const __ph<7> _7; 2018_LIBCPP_FUNC_VIS extern const __ph<8> _8; 2019_LIBCPP_FUNC_VIS extern const __ph<9> _9; 2020_LIBCPP_FUNC_VIS extern const __ph<10> _10; 2021#else 2022constexpr __ph<1> _1{}; 2023constexpr __ph<2> _2{}; 2024constexpr __ph<3> _3{}; 2025constexpr __ph<4> _4{}; 2026constexpr __ph<5> _5{}; 2027constexpr __ph<6> _6{}; 2028constexpr __ph<7> _7{}; 2029constexpr __ph<8> _8{}; 2030constexpr __ph<9> _9{}; 2031constexpr __ph<10> _10{}; 2032#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND) 2033 2034} // placeholders 2035 2036template<int _Np> 2037struct __is_placeholder<placeholders::__ph<_Np> > 2038 : public integral_constant<int, _Np> {}; 2039 2040 2041#ifndef _LIBCPP_HAS_NO_VARIADICS 2042 2043template <class _Tp, class _Uj> 2044inline _LIBCPP_INLINE_VISIBILITY 2045_Tp& 2046__mu(reference_wrapper<_Tp> __t, _Uj&) 2047{ 2048 return __t.get(); 2049} 2050 2051template <class _Ti, class ..._Uj, size_t ..._Indx> 2052inline _LIBCPP_INLINE_VISIBILITY 2053typename __invoke_of<_Ti&, _Uj...>::type 2054__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) 2055{ 2056 return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); 2057} 2058 2059template <class _Ti, class ..._Uj> 2060inline _LIBCPP_INLINE_VISIBILITY 2061typename __lazy_enable_if 2062< 2063 is_bind_expression<_Ti>::value, 2064 __invoke_of<_Ti&, _Uj...> 2065>::type 2066__mu(_Ti& __ti, tuple<_Uj...>& __uj) 2067{ 2068 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; 2069 return __mu_expand(__ti, __uj, __indices()); 2070} 2071 2072template <bool IsPh, class _Ti, class _Uj> 2073struct __mu_return2 {}; 2074 2075template <class _Ti, class _Uj> 2076struct __mu_return2<true, _Ti, _Uj> 2077{ 2078 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; 2079}; 2080 2081template <class _Ti, class _Uj> 2082inline _LIBCPP_INLINE_VISIBILITY 2083typename enable_if 2084< 2085 0 < is_placeholder<_Ti>::value, 2086 typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type 2087>::type 2088__mu(_Ti&, _Uj& __uj) 2089{ 2090 const size_t _Indx = is_placeholder<_Ti>::value - 1; 2091 return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj)); 2092} 2093 2094template <class _Ti, class _Uj> 2095inline _LIBCPP_INLINE_VISIBILITY 2096typename enable_if 2097< 2098 !is_bind_expression<_Ti>::value && 2099 is_placeholder<_Ti>::value == 0 && 2100 !__is_reference_wrapper<_Ti>::value, 2101 _Ti& 2102>::type 2103__mu(_Ti& __ti, _Uj&) 2104{ 2105 return __ti; 2106} 2107 2108template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, 2109 class _TupleUj> 2110struct ____mu_return; 2111 2112template <bool _Invokable, class _Ti, class ..._Uj> 2113struct ____mu_return_invokable // false 2114{ 2115 typedef __nat type; 2116}; 2117 2118template <class _Ti, class ..._Uj> 2119struct ____mu_return_invokable<true, _Ti, _Uj...> 2120{ 2121 typedef typename __invoke_of<_Ti&, _Uj...>::type type; 2122}; 2123 2124template <class _Ti, class ..._Uj> 2125struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> > 2126 : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> 2127{ 2128}; 2129 2130template <class _Ti, class _TupleUj> 2131struct ____mu_return<_Ti, false, false, true, _TupleUj> 2132{ 2133 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, 2134 _TupleUj>::type&& type; 2135}; 2136 2137template <class _Ti, class _TupleUj> 2138struct ____mu_return<_Ti, true, false, false, _TupleUj> 2139{ 2140 typedef typename _Ti::type& type; 2141}; 2142 2143template <class _Ti, class _TupleUj> 2144struct ____mu_return<_Ti, false, false, false, _TupleUj> 2145{ 2146 typedef _Ti& type; 2147}; 2148 2149template <class _Ti, class _TupleUj> 2150struct __mu_return 2151 : public ____mu_return<_Ti, 2152 __is_reference_wrapper<_Ti>::value, 2153 is_bind_expression<_Ti>::value, 2154 0 < is_placeholder<_Ti>::value && 2155 is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, 2156 _TupleUj> 2157{ 2158}; 2159 2160template <class _Fp, class _BoundArgs, class _TupleUj> 2161struct __is_valid_bind_return 2162{ 2163 static const bool value = false; 2164}; 2165 2166template <class _Fp, class ..._BoundArgs, class _TupleUj> 2167struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> 2168{ 2169 static const bool value = __invokable<_Fp, 2170 typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; 2171}; 2172 2173template <class _Fp, class ..._BoundArgs, class _TupleUj> 2174struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> 2175{ 2176 static const bool value = __invokable<_Fp, 2177 typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; 2178}; 2179 2180template <class _Fp, class _BoundArgs, class _TupleUj, 2181 bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> 2182struct __bind_return; 2183 2184template <class _Fp, class ..._BoundArgs, class _TupleUj> 2185struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> 2186{ 2187 typedef typename __invoke_of 2188 < 2189 _Fp&, 2190 typename __mu_return 2191 < 2192 _BoundArgs, 2193 _TupleUj 2194 >::type... 2195 >::type type; 2196}; 2197 2198template <class _Fp, class ..._BoundArgs, class _TupleUj> 2199struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> 2200{ 2201 typedef typename __invoke_of 2202 < 2203 _Fp&, 2204 typename __mu_return 2205 < 2206 const _BoundArgs, 2207 _TupleUj 2208 >::type... 2209 >::type type; 2210}; 2211 2212template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> 2213inline _LIBCPP_INLINE_VISIBILITY 2214typename __bind_return<_Fp, _BoundArgs, _Args>::type 2215__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, 2216 _Args&& __args) 2217{ 2218 return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...); 2219} 2220 2221template<class _Fp, class ..._BoundArgs> 2222class __bind 2223 : public __weak_result_type<typename decay<_Fp>::type> 2224{ 2225protected: 2226 typedef typename decay<_Fp>::type _Fd; 2227 typedef tuple<typename decay<_BoundArgs>::type...> _Td; 2228private: 2229 _Fd __f_; 2230 _Td __bound_args_; 2231 2232 typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; 2233public: 2234 template <class _Gp, class ..._BA, 2235 class = typename enable_if 2236 < 2237 is_constructible<_Fd, _Gp>::value && 2238 !is_same<typename remove_reference<_Gp>::type, 2239 __bind>::value 2240 >::type> 2241 _LIBCPP_INLINE_VISIBILITY 2242 explicit __bind(_Gp&& __f, _BA&& ...__bound_args) 2243 : __f_(_VSTD::forward<_Gp>(__f)), 2244 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} 2245 2246 template <class ..._Args> 2247 _LIBCPP_INLINE_VISIBILITY 2248 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 2249 operator()(_Args&& ...__args) 2250 { 2251 return __apply_functor(__f_, __bound_args_, __indices(), 2252 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 2253 } 2254 2255 template <class ..._Args> 2256 _LIBCPP_INLINE_VISIBILITY 2257 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type 2258 operator()(_Args&& ...__args) const 2259 { 2260 return __apply_functor(__f_, __bound_args_, __indices(), 2261 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 2262 } 2263}; 2264 2265template<class _Fp, class ..._BoundArgs> 2266struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; 2267 2268template<class _Rp, class _Fp, class ..._BoundArgs> 2269class __bind_r 2270 : public __bind<_Fp, _BoundArgs...> 2271{ 2272 typedef __bind<_Fp, _BoundArgs...> base; 2273 typedef typename base::_Fd _Fd; 2274 typedef typename base::_Td _Td; 2275public: 2276 typedef _Rp result_type; 2277 2278 2279 template <class _Gp, class ..._BA, 2280 class = typename enable_if 2281 < 2282 is_constructible<_Fd, _Gp>::value && 2283 !is_same<typename remove_reference<_Gp>::type, 2284 __bind_r>::value 2285 >::type> 2286 _LIBCPP_INLINE_VISIBILITY 2287 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) 2288 : base(_VSTD::forward<_Gp>(__f), 2289 _VSTD::forward<_BA>(__bound_args)...) {} 2290 2291 template <class ..._Args> 2292 _LIBCPP_INLINE_VISIBILITY 2293 typename enable_if 2294 < 2295 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, 2296 result_type>::value || is_void<_Rp>::value, 2297 result_type 2298 >::type 2299 operator()(_Args&& ...__args) 2300 { 2301 typedef __invoke_void_return_wrapper<_Rp> _Invoker; 2302 return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...); 2303 } 2304 2305 template <class ..._Args> 2306 _LIBCPP_INLINE_VISIBILITY 2307 typename enable_if 2308 < 2309 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, 2310 result_type>::value || is_void<_Rp>::value, 2311 result_type 2312 >::type 2313 operator()(_Args&& ...__args) const 2314 { 2315 typedef __invoke_void_return_wrapper<_Rp> _Invoker; 2316 return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...); 2317 } 2318}; 2319 2320template<class _Rp, class _Fp, class ..._BoundArgs> 2321struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; 2322 2323template<class _Fp, class ..._BoundArgs> 2324inline _LIBCPP_INLINE_VISIBILITY 2325__bind<_Fp, _BoundArgs...> 2326bind(_Fp&& __f, _BoundArgs&&... __bound_args) 2327{ 2328 typedef __bind<_Fp, _BoundArgs...> type; 2329 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 2330} 2331 2332template<class _Rp, class _Fp, class ..._BoundArgs> 2333inline _LIBCPP_INLINE_VISIBILITY 2334__bind_r<_Rp, _Fp, _BoundArgs...> 2335bind(_Fp&& __f, _BoundArgs&&... __bound_args) 2336{ 2337 typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; 2338 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 2339} 2340 2341#endif // _LIBCPP_HAS_NO_VARIADICS 2342 2343#if _LIBCPP_STD_VER > 14 2344 2345#define __cpp_lib_invoke 201411 2346 2347template <class _Fn, class ..._Args> 2348result_of_t<_Fn&&(_Args&&...)> 2349invoke(_Fn&& __f, _Args&&... __args) 2350 noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...))) 2351{ 2352 return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); 2353} 2354 2355template <class _DecayFunc> 2356class _LIBCPP_TEMPLATE_VIS __not_fn_imp { 2357 _DecayFunc __fd; 2358 2359public: 2360 __not_fn_imp() = delete; 2361 2362 template <class ..._Args> 2363 _LIBCPP_INLINE_VISIBILITY 2364 auto operator()(_Args&& ...__args) & 2365 noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))) 2366 -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)) 2367 { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); } 2368 2369 template <class ..._Args> 2370 _LIBCPP_INLINE_VISIBILITY 2371 auto operator()(_Args&& ...__args) && 2372 noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))) 2373 -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)) 2374 { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); } 2375 2376 template <class ..._Args> 2377 _LIBCPP_INLINE_VISIBILITY 2378 auto operator()(_Args&& ...__args) const& 2379 noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))) 2380 -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)) 2381 { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); } 2382 2383 2384 template <class ..._Args> 2385 _LIBCPP_INLINE_VISIBILITY 2386 auto operator()(_Args&& ...__args) const&& 2387 noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))) 2388 -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)) 2389 { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); } 2390 2391private: 2392 template <class _RawFunc, 2393 class = enable_if_t<!is_same<decay_t<_RawFunc>, __not_fn_imp>::value>> 2394 _LIBCPP_INLINE_VISIBILITY 2395 explicit __not_fn_imp(_RawFunc&& __rf) 2396 : __fd(_VSTD::forward<_RawFunc>(__rf)) {} 2397 2398 template <class _RawFunc> 2399 friend inline _LIBCPP_INLINE_VISIBILITY 2400 __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&&); 2401}; 2402 2403template <class _RawFunc> 2404inline _LIBCPP_INLINE_VISIBILITY 2405__not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) { 2406 return __not_fn_imp<decay_t<_RawFunc>>(_VSTD::forward<_RawFunc>(__fn)); 2407} 2408 2409#endif 2410 2411// struct hash<T*> in <memory> 2412 2413_LIBCPP_END_NAMESPACE_STD 2414 2415#endif // _LIBCPP_FUNCTIONAL 2416