1// -*- C++ -*- 2//===------------------------ functional ----------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_FUNCTIONAL 11#define _LIBCPP_FUNCTIONAL 12 13/* 14 functional synopsis 15 16namespace std 17{ 18 19template <class Arg, class Result> 20struct unary_function 21{ 22 typedef Arg argument_type; 23 typedef Result result_type; 24}; 25 26template <class Arg1, class Arg2, class Result> 27struct binary_function 28{ 29 typedef Arg1 first_argument_type; 30 typedef Arg2 second_argument_type; 31 typedef Result result_type; 32}; 33 34template <class T> 35class reference_wrapper 36 : public unary_function<T1, R> // if wrapping a unary functor 37 : public binary_function<T1, T2, R> // if wraping a binary functor 38{ 39public: 40 // types 41 typedef T type; 42 typedef see below result_type; // Not always defined 43 44 // construct/copy/destroy 45 template<class U> 46 reference_wrapper(U&&); 47 reference_wrapper(const reference_wrapper<T>& x) noexcept; 48 49 // assignment 50 reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept; 51 52 // access 53 operator T& () const noexcept; 54 T& get() const noexcept; 55 56 // invoke 57 template <class... ArgTypes> 58 typename result_of<T&(ArgTypes&&...)>::type 59 operator() (ArgTypes&&...) const; 60}; 61 62template <class T> 63 reference_wrapper(T&) -> reference_wrapper<T>; 64 65template <class T> reference_wrapper<T> ref(T& t) noexcept; 66template <class T> void ref(const T&& t) = delete; 67template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept; 68 69template <class T> reference_wrapper<const T> cref(const T& t) noexcept; 70template <class T> void cref(const T&& t) = delete; 71template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept; 72 73template <class T> struct unwrap_reference; // since C++20 74template <class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> { }; // since C++20 75template <class T> using unwrap_reference_t = typename unwrap_reference<T>::type; // since C++20 76template <class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; // since C++20 77 78template <class T> // <class T=void> in C++14 79struct plus { 80 T operator()(const T& x, const T& y) const; 81}; 82 83template <class T> // <class T=void> in C++14 84struct minus { 85 T operator()(const T& x, const T& y) const; 86}; 87 88template <class T> // <class T=void> in C++14 89struct multiplies { 90 T operator()(const T& x, const T& y) const; 91}; 92 93template <class T> // <class T=void> in C++14 94struct divides { 95 T operator()(const T& x, const T& y) const; 96}; 97 98template <class T> // <class T=void> in C++14 99struct modulus { 100 T operator()(const T& x, const T& y) const; 101}; 102 103template <class T> // <class T=void> in C++14 104struct negate { 105 T operator()(const T& x) const; 106}; 107 108template <class T> // <class T=void> in C++14 109struct equal_to { 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 { 115 bool operator()(const T& x, const T& y) const; 116}; 117 118template <class T> // <class T=void> in C++14 119struct greater { 120 bool operator()(const T& x, const T& y) const; 121}; 122 123template <class T> // <class T=void> in C++14 124struct less { 125 bool operator()(const T& x, const T& y) const; 126}; 127 128template <class T> // <class T=void> in C++14 129struct greater_equal { 130 bool operator()(const T& x, const T& y) const; 131}; 132 133template <class T> // <class T=void> in C++14 134struct less_equal { 135 bool operator()(const T& x, const T& y) const; 136}; 137 138template <class T> // <class T=void> in C++14 139struct logical_and { 140 bool operator()(const T& x, const T& y) const; 141}; 142 143template <class T> // <class T=void> in C++14 144struct logical_or { 145 bool operator()(const T& x, const T& y) const; 146}; 147 148template <class T> // <class T=void> in C++14 149struct logical_not { 150 bool operator()(const T& x) const; 151}; 152 153template <class T> // <class T=void> in C++14 154struct bit_and { 155 T operator()(const T& x, const T& y) const; 156}; 157 158template <class T> // <class T=void> in C++14 159struct bit_or { 160 T operator()(const T& x, const T& y) const; 161}; 162 163template <class T> // <class T=void> in C++14 164struct bit_xor { 165 T operator()(const T& x, const T& y) const; 166}; 167 168template <class T=void> // C++14 169struct bit_not { 170 T operator()(const T& x) const; 171}; 172 173struct identity; // C++20 174 175template <class Predicate> 176class unary_negate // deprecated in C++17, removed in C++20 177 : public unary_function<typename Predicate::argument_type, bool> 178{ 179public: 180 explicit unary_negate(const Predicate& pred); 181 bool operator()(const typename Predicate::argument_type& x) const; 182}; 183 184template <class Predicate> // deprecated in C++17, removed in C++20 185unary_negate<Predicate> not1(const Predicate& pred); 186 187template <class Predicate> 188class binary_negate // deprecated in C++17, removed in C++20 189 : public binary_function<typename Predicate::first_argument_type, 190 typename Predicate::second_argument_type, 191 bool> 192{ 193public: 194 explicit binary_negate(const Predicate& pred); 195 bool operator()(const typename Predicate::first_argument_type& x, 196 const typename Predicate::second_argument_type& y) const; 197}; 198 199template <class Predicate> // deprecated in C++17, removed in C++20 200binary_negate<Predicate> not2(const Predicate& pred); 201 202template <class F> 203constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20 204 205template<class T> struct is_bind_expression; 206template<class T> struct is_placeholder; 207 208 // See C++14 20.9.9, Function object binders 209template <class T> inline constexpr bool is_bind_expression_v 210 = is_bind_expression<T>::value; // C++17 211template <class T> inline constexpr int is_placeholder_v 212 = is_placeholder<T>::value; // C++17 213 214 215template<class Fn, class... BoundArgs> 216 constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20 217template<class R, class Fn, class... BoundArgs> 218 constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20 219 220template<class F, class... Args> 221 constexpr // constexpr in C++20 222 invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) // C++17 223 noexcept(is_nothrow_invocable_v<F, Args...>); 224 225namespace placeholders { 226 // M is the implementation-defined number of placeholders 227 extern unspecified _1; 228 extern unspecified _2; 229 . 230 . 231 . 232 extern unspecified _Mp; 233} 234 235template <class Operation> 236class binder1st // deprecated in C++11, removed in C++17 237 : public unary_function<typename Operation::second_argument_type, 238 typename Operation::result_type> 239{ 240protected: 241 Operation op; 242 typename Operation::first_argument_type value; 243public: 244 binder1st(const Operation& x, const typename Operation::first_argument_type y); 245 typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; 246 typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; 247}; 248 249template <class Operation, class T> 250binder1st<Operation> bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 251 252template <class Operation> 253class binder2nd // deprecated in C++11, removed in C++17 254 : public unary_function<typename Operation::first_argument_type, 255 typename Operation::result_type> 256{ 257protected: 258 Operation op; 259 typename Operation::second_argument_type value; 260public: 261 binder2nd(const Operation& x, const typename Operation::second_argument_type y); 262 typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; 263 typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; 264}; 265 266template <class Operation, class T> 267binder2nd<Operation> bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 268 269template <class Arg, class Result> // deprecated in C++11, removed in C++17 270class pointer_to_unary_function : public unary_function<Arg, Result> 271{ 272public: 273 explicit pointer_to_unary_function(Result (*f)(Arg)); 274 Result operator()(Arg x) const; 275}; 276 277template <class Arg, class Result> 278pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17 279 280template <class Arg1, class Arg2, class Result> // deprecated in C++11, removed in C++17 281class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> 282{ 283public: 284 explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); 285 Result operator()(Arg1 x, Arg2 y) const; 286}; 287 288template <class Arg1, class Arg2, class Result> 289pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17 290 291template<class S, class T> // deprecated in C++11, removed in C++17 292class mem_fun_t : public unary_function<T*, S> 293{ 294public: 295 explicit mem_fun_t(S (T::*p)()); 296 S operator()(T* p) const; 297}; 298 299template<class S, class T, class A> 300class mem_fun1_t : public binary_function<T*, A, S> // deprecated in C++11, removed in C++17 301{ 302public: 303 explicit mem_fun1_t(S (T::*p)(A)); 304 S operator()(T* p, A x) const; 305}; 306 307template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17 308template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17 309 310template<class S, class T> 311class mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17 312{ 313public: 314 explicit mem_fun_ref_t(S (T::*p)()); 315 S operator()(T& p) const; 316}; 317 318template<class S, class T, class A> 319class mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17 320{ 321public: 322 explicit mem_fun1_ref_t(S (T::*p)(A)); 323 S operator()(T& p, A x) const; 324}; 325 326template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17 327template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17 328 329template <class S, class T> 330class const_mem_fun_t : public unary_function<const T*, S> // deprecated in C++11, removed in C++17 331{ 332public: 333 explicit const_mem_fun_t(S (T::*p)() const); 334 S operator()(const T* p) const; 335}; 336 337template <class S, class T, class A> 338class const_mem_fun1_t : public binary_function<const T*, A, S> // deprecated in C++11, removed in C++17 339{ 340public: 341 explicit const_mem_fun1_t(S (T::*p)(A) const); 342 S operator()(const T* p, A x) const; 343}; 344 345template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17 346template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 347 348template <class S, class T> 349class const_mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17 350{ 351public: 352 explicit const_mem_fun_ref_t(S (T::*p)() const); 353 S operator()(const T& p) const; 354}; 355 356template <class S, class T, class A> 357class const_mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17 358{ 359public: 360 explicit const_mem_fun1_ref_t(S (T::*p)(A) const); 361 S operator()(const T& p, A x) const; 362}; 363 364template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17 365template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 366 367template<class R, class T> 368constexpr unspecified mem_fn(R T::*); // constexpr in C++20 369 370class bad_function_call 371 : public exception 372{ 373}; 374 375template<class> class function; // undefined 376 377template<class R, class... ArgTypes> 378class function<R(ArgTypes...)> 379 : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and 380 // ArgTypes contains T1 381 : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and 382 // ArgTypes contains T1 and T2 383{ 384public: 385 typedef R result_type; 386 387 // construct/copy/destroy: 388 function() noexcept; 389 function(nullptr_t) noexcept; 390 function(const function&); 391 function(function&&) noexcept; 392 template<class F> 393 function(F); 394 template<Allocator Alloc> 395 function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17 396 template<Allocator Alloc> 397 function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17 398 template<Allocator Alloc> 399 function(allocator_arg_t, const Alloc&, const function&); // removed in C++17 400 template<Allocator Alloc> 401 function(allocator_arg_t, const Alloc&, function&&); // removed in C++17 402 template<class F, Allocator Alloc> 403 function(allocator_arg_t, const Alloc&, F); // removed in C++17 404 405 function& operator=(const function&); 406 function& operator=(function&&) noexcept; 407 function& operator=(nullptr_t) noexcept; 408 template<class F> 409 function& operator=(F&&); 410 template<class F> 411 function& operator=(reference_wrapper<F>) noexcept; 412 413 ~function(); 414 415 // function modifiers: 416 void swap(function&) noexcept; 417 template<class F, class Alloc> 418 void assign(F&&, const Alloc&); // Removed in C++17 419 420 // function capacity: 421 explicit operator bool() const noexcept; 422 423 // function invocation: 424 R operator()(ArgTypes...) const; 425 426 // function target access: 427 const std::type_info& target_type() const noexcept; 428 template <typename T> T* target() noexcept; 429 template <typename T> const T* target() const noexcept; 430}; 431 432// Deduction guides 433template<class R, class ...Args> 434function(R(*)(Args...)) -> function<R(Args...)>; // since C++17 435 436template<class F> 437function(F) -> function<see-below>; // since C++17 438 439// Null pointer comparisons: 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 446template <class R, class ... ArgTypes> 447 bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 448 449template <class R, class ... ArgTypes> 450 bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 451 452// specialized algorithms: 453template <class R, class ... ArgTypes> 454 void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept; 455 456template <class T> struct hash; 457 458template <> struct hash<bool>; 459template <> struct hash<char>; 460template <> struct hash<signed char>; 461template <> struct hash<unsigned char>; 462template <> struct hash<char8_t>; // since C++20 463template <> struct hash<char16_t>; 464template <> struct hash<char32_t>; 465template <> struct hash<wchar_t>; 466template <> struct hash<short>; 467template <> struct hash<unsigned short>; 468template <> struct hash<int>; 469template <> struct hash<unsigned int>; 470template <> struct hash<long>; 471template <> struct hash<long long>; 472template <> struct hash<unsigned long>; 473template <> struct hash<unsigned long long>; 474 475template <> struct hash<float>; 476template <> struct hash<double>; 477template <> struct hash<long double>; 478 479template<class T> struct hash<T*>; 480template <> struct hash<nullptr_t>; // C++17 481 482} // std 483 484POLICY: For non-variadic implementations, the number of arguments is limited 485 to 3. It is hoped that the need for non-variadic implementations 486 will be minimal. 487 488*/ 489 490#include <__config> 491#include <__debug> 492#include <__functional_base> 493#include <__functional/search.h> 494#include <concepts> 495#include <exception> 496#include <memory> 497#include <tuple> 498#include <type_traits> 499#include <typeinfo> 500#include <utility> 501#include <version> 502 503#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 504#pragma GCC system_header 505#endif 506 507_LIBCPP_BEGIN_NAMESPACE_STD 508 509_LIBCPP_SUPPRESS_DEPRECATED_PUSH 510#if _LIBCPP_STD_VER > 11 511template <class _Tp = void> 512#else 513template <class _Tp> 514#endif 515struct _LIBCPP_TEMPLATE_VIS plus 516#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 517 : binary_function<_Tp, _Tp, _Tp> 518#endif 519{ 520_LIBCPP_SUPPRESS_DEPRECATED_POP 521 typedef _Tp __result_type; // used by valarray 522#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 523 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 524 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 525 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 526#endif 527 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 528 _Tp operator()(const _Tp& __x, const _Tp& __y) const 529 {return __x + __y;} 530}; 531 532#if _LIBCPP_STD_VER > 11 533template <> 534struct _LIBCPP_TEMPLATE_VIS plus<void> 535{ 536 template <class _T1, class _T2> 537 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 538 auto operator()(_T1&& __t, _T2&& __u) const 539 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) 540 -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) 541 { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } 542 typedef void is_transparent; 543}; 544#endif 545 546 547_LIBCPP_SUPPRESS_DEPRECATED_PUSH 548#if _LIBCPP_STD_VER > 11 549template <class _Tp = void> 550#else 551template <class _Tp> 552#endif 553struct _LIBCPP_TEMPLATE_VIS minus 554#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 555 : binary_function<_Tp, _Tp, _Tp> 556#endif 557{ 558_LIBCPP_SUPPRESS_DEPRECATED_POP 559 typedef _Tp __result_type; // used by valarray 560#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 561 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 562 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 563 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 564#endif 565 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 566 _Tp operator()(const _Tp& __x, const _Tp& __y) const 567 {return __x - __y;} 568}; 569 570#if _LIBCPP_STD_VER > 11 571template <> 572struct _LIBCPP_TEMPLATE_VIS minus<void> 573{ 574 template <class _T1, class _T2> 575 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 576 auto operator()(_T1&& __t, _T2&& __u) const 577 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) 578 -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) 579 { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } 580 typedef void is_transparent; 581}; 582#endif 583 584 585_LIBCPP_SUPPRESS_DEPRECATED_PUSH 586#if _LIBCPP_STD_VER > 11 587template <class _Tp = void> 588#else 589template <class _Tp> 590#endif 591struct _LIBCPP_TEMPLATE_VIS multiplies 592#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 593 : binary_function<_Tp, _Tp, _Tp> 594#endif 595{ 596_LIBCPP_SUPPRESS_DEPRECATED_POP 597 typedef _Tp __result_type; // used by valarray 598#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 599 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 600 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 601 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 602#endif 603 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 604 _Tp operator()(const _Tp& __x, const _Tp& __y) const 605 {return __x * __y;} 606}; 607 608#if _LIBCPP_STD_VER > 11 609template <> 610struct _LIBCPP_TEMPLATE_VIS multiplies<void> 611{ 612 template <class _T1, class _T2> 613 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 614 auto operator()(_T1&& __t, _T2&& __u) const 615 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) 616 -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) 617 { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } 618 typedef void is_transparent; 619}; 620#endif 621 622 623_LIBCPP_SUPPRESS_DEPRECATED_PUSH 624#if _LIBCPP_STD_VER > 11 625template <class _Tp = void> 626#else 627template <class _Tp> 628#endif 629struct _LIBCPP_TEMPLATE_VIS divides 630#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 631 : binary_function<_Tp, _Tp, _Tp> 632#endif 633{ 634_LIBCPP_SUPPRESS_DEPRECATED_POP 635 typedef _Tp __result_type; // used by valarray 636#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 637 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 638 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 639 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 640#endif 641 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 642 _Tp operator()(const _Tp& __x, const _Tp& __y) const 643 {return __x / __y;} 644}; 645 646#if _LIBCPP_STD_VER > 11 647template <> 648struct _LIBCPP_TEMPLATE_VIS divides<void> 649{ 650 template <class _T1, class _T2> 651 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 652 auto operator()(_T1&& __t, _T2&& __u) const 653 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) 654 -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) 655 { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } 656 typedef void is_transparent; 657}; 658#endif 659 660 661_LIBCPP_SUPPRESS_DEPRECATED_PUSH 662#if _LIBCPP_STD_VER > 11 663template <class _Tp = void> 664#else 665template <class _Tp> 666#endif 667struct _LIBCPP_TEMPLATE_VIS modulus 668#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 669 : binary_function<_Tp, _Tp, _Tp> 670#endif 671{ 672_LIBCPP_SUPPRESS_DEPRECATED_POP 673 typedef _Tp __result_type; // used by valarray 674#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 675 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 676 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 677 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 678#endif 679 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 680 _Tp operator()(const _Tp& __x, const _Tp& __y) const 681 {return __x % __y;} 682}; 683 684#if _LIBCPP_STD_VER > 11 685template <> 686struct _LIBCPP_TEMPLATE_VIS modulus<void> 687{ 688 template <class _T1, class _T2> 689 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 690 auto operator()(_T1&& __t, _T2&& __u) const 691 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) 692 -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) 693 { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } 694 typedef void is_transparent; 695}; 696#endif 697 698 699_LIBCPP_SUPPRESS_DEPRECATED_PUSH 700#if _LIBCPP_STD_VER > 11 701template <class _Tp = void> 702#else 703template <class _Tp> 704#endif 705struct _LIBCPP_TEMPLATE_VIS negate 706#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 707 : unary_function<_Tp, _Tp> 708#endif 709{ 710_LIBCPP_SUPPRESS_DEPRECATED_POP 711 typedef _Tp __result_type; // used by valarray 712#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 713 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 714 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; 715#endif 716 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 717 _Tp operator()(const _Tp& __x) const 718 {return -__x;} 719}; 720 721#if _LIBCPP_STD_VER > 11 722template <> 723struct _LIBCPP_TEMPLATE_VIS negate<void> 724{ 725 template <class _Tp> 726 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 727 auto operator()(_Tp&& __x) const 728 _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) 729 -> decltype (- _VSTD::forward<_Tp>(__x)) 730 { return - _VSTD::forward<_Tp>(__x); } 731 typedef void is_transparent; 732}; 733#endif 734 735 736_LIBCPP_SUPPRESS_DEPRECATED_PUSH 737#if _LIBCPP_STD_VER > 11 738template <class _Tp = void> 739#else 740template <class _Tp> 741#endif 742struct _LIBCPP_TEMPLATE_VIS equal_to 743#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 744 : binary_function<_Tp, _Tp, bool> 745#endif 746{ 747_LIBCPP_SUPPRESS_DEPRECATED_POP 748 typedef bool __result_type; // used by valarray 749#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 750 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; 751 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 752 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 753#endif 754 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 755 bool operator()(const _Tp& __x, const _Tp& __y) const 756 {return __x == __y;} 757}; 758 759#if _LIBCPP_STD_VER > 11 760template <> 761struct _LIBCPP_TEMPLATE_VIS equal_to<void> 762{ 763 template <class _T1, class _T2> 764 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 765 auto operator()(_T1&& __t, _T2&& __u) const 766 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) 767 -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) 768 { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } 769 typedef void is_transparent; 770}; 771#endif 772 773 774_LIBCPP_SUPPRESS_DEPRECATED_PUSH 775#if _LIBCPP_STD_VER > 11 776template <class _Tp = void> 777#else 778template <class _Tp> 779#endif 780struct _LIBCPP_TEMPLATE_VIS not_equal_to 781#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 782 : binary_function<_Tp, _Tp, bool> 783#endif 784{ 785_LIBCPP_SUPPRESS_DEPRECATED_POP 786 typedef bool __result_type; // used by valarray 787#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 788 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; 789 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 790 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 791#endif 792 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 793 bool operator()(const _Tp& __x, const _Tp& __y) const 794 {return __x != __y;} 795}; 796 797#if _LIBCPP_STD_VER > 11 798template <> 799struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> 800{ 801 template <class _T1, class _T2> 802 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 803 auto operator()(_T1&& __t, _T2&& __u) const 804 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) 805 -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) 806 { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } 807 typedef void is_transparent; 808}; 809#endif 810 811 812_LIBCPP_SUPPRESS_DEPRECATED_PUSH 813#if _LIBCPP_STD_VER > 11 814template <class _Tp = void> 815#else 816template <class _Tp> 817#endif 818struct _LIBCPP_TEMPLATE_VIS greater 819#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 820 : binary_function<_Tp, _Tp, bool> 821#endif 822{ 823_LIBCPP_SUPPRESS_DEPRECATED_POP 824 typedef bool __result_type; // used by valarray 825#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 826 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; 827 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 828 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 829#endif 830 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 831 bool operator()(const _Tp& __x, const _Tp& __y) const 832 {return __x > __y;} 833}; 834 835#if _LIBCPP_STD_VER > 11 836template <> 837struct _LIBCPP_TEMPLATE_VIS greater<void> 838{ 839 template <class _T1, class _T2> 840 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 841 auto operator()(_T1&& __t, _T2&& __u) const 842 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) 843 -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) 844 { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } 845 typedef void is_transparent; 846}; 847#endif 848 849 850// less in <__functional_base> 851 852 853_LIBCPP_SUPPRESS_DEPRECATED_PUSH 854#if _LIBCPP_STD_VER > 11 855template <class _Tp = void> 856#else 857template <class _Tp> 858#endif 859struct _LIBCPP_TEMPLATE_VIS greater_equal 860#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 861 : binary_function<_Tp, _Tp, bool> 862#endif 863{ 864_LIBCPP_SUPPRESS_DEPRECATED_POP 865 typedef bool __result_type; // used by valarray 866#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 867 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; 868 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 869 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 870#endif 871 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 872 bool operator()(const _Tp& __x, const _Tp& __y) const 873 {return __x >= __y;} 874}; 875 876#if _LIBCPP_STD_VER > 11 877template <> 878struct _LIBCPP_TEMPLATE_VIS greater_equal<void> 879{ 880 template <class _T1, class _T2> 881 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 882 auto operator()(_T1&& __t, _T2&& __u) const 883 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) 884 -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) 885 { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } 886 typedef void is_transparent; 887}; 888#endif 889 890 891_LIBCPP_SUPPRESS_DEPRECATED_PUSH 892#if _LIBCPP_STD_VER > 11 893template <class _Tp = void> 894#else 895template <class _Tp> 896#endif 897struct _LIBCPP_TEMPLATE_VIS less_equal 898#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 899 : binary_function<_Tp, _Tp, bool> 900#endif 901{ 902_LIBCPP_SUPPRESS_DEPRECATED_POP 903 typedef bool __result_type; // used by valarray 904#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 905 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; 906 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 907 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 908#endif 909 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 910 bool operator()(const _Tp& __x, const _Tp& __y) const 911 {return __x <= __y;} 912}; 913 914#if _LIBCPP_STD_VER > 11 915template <> 916struct _LIBCPP_TEMPLATE_VIS less_equal<void> 917{ 918 template <class _T1, class _T2> 919 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 920 auto operator()(_T1&& __t, _T2&& __u) const 921 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) 922 -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) 923 { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } 924 typedef void is_transparent; 925}; 926#endif 927 928 929_LIBCPP_SUPPRESS_DEPRECATED_PUSH 930#if _LIBCPP_STD_VER > 11 931template <class _Tp = void> 932#else 933template <class _Tp> 934#endif 935struct _LIBCPP_TEMPLATE_VIS logical_and 936#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 937 : binary_function<_Tp, _Tp, bool> 938#endif 939{ 940_LIBCPP_SUPPRESS_DEPRECATED_POP 941 typedef bool __result_type; // used by valarray 942#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 943 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; 944 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 945 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 946#endif 947 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 948 bool operator()(const _Tp& __x, const _Tp& __y) const 949 {return __x && __y;} 950}; 951 952#if _LIBCPP_STD_VER > 11 953template <> 954struct _LIBCPP_TEMPLATE_VIS logical_and<void> 955{ 956 template <class _T1, class _T2> 957 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 958 auto operator()(_T1&& __t, _T2&& __u) const 959 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) 960 -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) 961 { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } 962 typedef void is_transparent; 963}; 964#endif 965 966 967_LIBCPP_SUPPRESS_DEPRECATED_PUSH 968#if _LIBCPP_STD_VER > 11 969template <class _Tp = void> 970#else 971template <class _Tp> 972#endif 973struct _LIBCPP_TEMPLATE_VIS logical_or 974#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 975 : binary_function<_Tp, _Tp, bool> 976#endif 977{ 978_LIBCPP_SUPPRESS_DEPRECATED_POP 979 typedef bool __result_type; // used by valarray 980#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 981 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; 982 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 983 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 984#endif 985 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 986 bool operator()(const _Tp& __x, const _Tp& __y) const 987 {return __x || __y;} 988}; 989 990#if _LIBCPP_STD_VER > 11 991template <> 992struct _LIBCPP_TEMPLATE_VIS logical_or<void> 993{ 994 template <class _T1, class _T2> 995 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 996 auto operator()(_T1&& __t, _T2&& __u) const 997 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) 998 -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) 999 { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } 1000 typedef void is_transparent; 1001}; 1002#endif 1003 1004 1005_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1006#if _LIBCPP_STD_VER > 11 1007template <class _Tp = void> 1008#else 1009template <class _Tp> 1010#endif 1011struct _LIBCPP_TEMPLATE_VIS logical_not 1012#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 1013 : unary_function<_Tp, bool> 1014#endif 1015{ 1016_LIBCPP_SUPPRESS_DEPRECATED_POP 1017 typedef bool __result_type; // used by valarray 1018#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 1019 _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; 1020 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; 1021#endif 1022 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1023 bool operator()(const _Tp& __x) const 1024 {return !__x;} 1025}; 1026 1027#if _LIBCPP_STD_VER > 11 1028template <> 1029struct _LIBCPP_TEMPLATE_VIS logical_not<void> 1030{ 1031 template <class _Tp> 1032 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1033 auto operator()(_Tp&& __x) const 1034 _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) 1035 -> decltype (!_VSTD::forward<_Tp>(__x)) 1036 { return !_VSTD::forward<_Tp>(__x); } 1037 typedef void is_transparent; 1038}; 1039#endif 1040 1041 1042_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1043#if _LIBCPP_STD_VER > 11 1044template <class _Tp = void> 1045#else 1046template <class _Tp> 1047#endif 1048struct _LIBCPP_TEMPLATE_VIS bit_and 1049#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 1050 : binary_function<_Tp, _Tp, _Tp> 1051#endif 1052{ 1053_LIBCPP_SUPPRESS_DEPRECATED_POP 1054 typedef _Tp __result_type; // used by valarray 1055#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 1056 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 1057 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 1058 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 1059#endif 1060 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1061 _Tp operator()(const _Tp& __x, const _Tp& __y) const 1062 {return __x & __y;} 1063}; 1064 1065#if _LIBCPP_STD_VER > 11 1066template <> 1067struct _LIBCPP_TEMPLATE_VIS bit_and<void> 1068{ 1069 template <class _T1, class _T2> 1070 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1071 auto operator()(_T1&& __t, _T2&& __u) const 1072 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) 1073 -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) 1074 { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } 1075 typedef void is_transparent; 1076}; 1077#endif 1078 1079 1080_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1081#if _LIBCPP_STD_VER > 11 1082template <class _Tp = void> 1083#else 1084template <class _Tp> 1085#endif 1086struct _LIBCPP_TEMPLATE_VIS bit_or 1087#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 1088 : binary_function<_Tp, _Tp, _Tp> 1089#endif 1090{ 1091_LIBCPP_SUPPRESS_DEPRECATED_POP 1092 typedef _Tp __result_type; // used by valarray 1093#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 1094 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 1095 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 1096 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 1097#endif 1098 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1099 _Tp operator()(const _Tp& __x, const _Tp& __y) const 1100 {return __x | __y;} 1101}; 1102 1103#if _LIBCPP_STD_VER > 11 1104template <> 1105struct _LIBCPP_TEMPLATE_VIS bit_or<void> 1106{ 1107 template <class _T1, class _T2> 1108 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1109 auto operator()(_T1&& __t, _T2&& __u) const 1110 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) 1111 -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) 1112 { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } 1113 typedef void is_transparent; 1114}; 1115#endif 1116 1117 1118_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1119#if _LIBCPP_STD_VER > 11 1120template <class _Tp = void> 1121#else 1122template <class _Tp> 1123#endif 1124struct _LIBCPP_TEMPLATE_VIS bit_xor 1125#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 1126 : binary_function<_Tp, _Tp, _Tp> 1127#endif 1128{ 1129_LIBCPP_SUPPRESS_DEPRECATED_POP 1130 typedef _Tp __result_type; // used by valarray 1131#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 1132 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 1133 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; 1134 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; 1135#endif 1136 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1137 _Tp operator()(const _Tp& __x, const _Tp& __y) const 1138 {return __x ^ __y;} 1139}; 1140 1141#if _LIBCPP_STD_VER > 11 1142template <> 1143struct _LIBCPP_TEMPLATE_VIS bit_xor<void> 1144{ 1145 template <class _T1, class _T2> 1146 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1147 auto operator()(_T1&& __t, _T2&& __u) const 1148 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) 1149 -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) 1150 { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } 1151 typedef void is_transparent; 1152}; 1153#endif 1154 1155 1156#if _LIBCPP_STD_VER > 11 1157_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1158template <class _Tp = void> 1159struct _LIBCPP_TEMPLATE_VIS bit_not 1160#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) 1161 : unary_function<_Tp, _Tp> 1162#endif 1163{ 1164_LIBCPP_SUPPRESS_DEPRECATED_POP 1165#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) 1166 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; 1167 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; 1168#endif 1169 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1170 _Tp operator()(const _Tp& __x) const 1171 {return ~__x;} 1172}; 1173 1174template <> 1175struct _LIBCPP_TEMPLATE_VIS bit_not<void> 1176{ 1177 template <class _Tp> 1178 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1179 auto operator()(_Tp&& __x) const 1180 _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) 1181 -> decltype (~_VSTD::forward<_Tp>(__x)) 1182 { return ~_VSTD::forward<_Tp>(__x); } 1183 typedef void is_transparent; 1184}; 1185#endif 1186 1187#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) 1188template <class _Predicate> 1189class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate 1190 : public unary_function<typename _Predicate::argument_type, bool> 1191{ 1192 _Predicate __pred_; 1193public: 1194 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1195 explicit unary_negate(const _Predicate& __pred) 1196 : __pred_(__pred) {} 1197 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1198 bool operator()(const typename _Predicate::argument_type& __x) const 1199 {return !__pred_(__x);} 1200}; 1201 1202template <class _Predicate> 1203_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1204unary_negate<_Predicate> 1205not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} 1206 1207template <class _Predicate> 1208class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate 1209 : public binary_function<typename _Predicate::first_argument_type, 1210 typename _Predicate::second_argument_type, 1211 bool> 1212{ 1213 _Predicate __pred_; 1214public: 1215 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 1216 binary_negate(const _Predicate& __pred) : __pred_(__pred) {} 1217 1218 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1219 bool operator()(const typename _Predicate::first_argument_type& __x, 1220 const typename _Predicate::second_argument_type& __y) const 1221 {return !__pred_(__x, __y);} 1222}; 1223 1224template <class _Predicate> 1225_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1226binary_negate<_Predicate> 1227not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} 1228#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) 1229 1230#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) 1231template <class __Operation> 1232class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st 1233 : public unary_function<typename __Operation::second_argument_type, 1234 typename __Operation::result_type> 1235{ 1236protected: 1237 __Operation op; 1238 typename __Operation::first_argument_type value; 1239public: 1240 _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, 1241 const typename __Operation::first_argument_type __y) 1242 : op(__x), value(__y) {} 1243 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1244 (typename __Operation::second_argument_type& __x) const 1245 {return op(value, __x);} 1246 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1247 (const typename __Operation::second_argument_type& __x) const 1248 {return op(value, __x);} 1249}; 1250 1251template <class __Operation, class _Tp> 1252_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1253binder1st<__Operation> 1254bind1st(const __Operation& __op, const _Tp& __x) 1255 {return binder1st<__Operation>(__op, __x);} 1256 1257template <class __Operation> 1258class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd 1259 : public unary_function<typename __Operation::first_argument_type, 1260 typename __Operation::result_type> 1261{ 1262protected: 1263 __Operation op; 1264 typename __Operation::second_argument_type value; 1265public: 1266 _LIBCPP_INLINE_VISIBILITY 1267 binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) 1268 : op(__x), value(__y) {} 1269 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1270 ( typename __Operation::first_argument_type& __x) const 1271 {return op(__x, value);} 1272 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1273 (const typename __Operation::first_argument_type& __x) const 1274 {return op(__x, value);} 1275}; 1276 1277template <class __Operation, class _Tp> 1278_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1279binder2nd<__Operation> 1280bind2nd(const __Operation& __op, const _Tp& __x) 1281 {return binder2nd<__Operation>(__op, __x);} 1282 1283template <class _Arg, class _Result> 1284class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function 1285 : public unary_function<_Arg, _Result> 1286{ 1287 _Result (*__f_)(_Arg); 1288public: 1289 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) 1290 : __f_(__f) {} 1291 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const 1292 {return __f_(__x);} 1293}; 1294 1295template <class _Arg, class _Result> 1296_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1297pointer_to_unary_function<_Arg,_Result> 1298ptr_fun(_Result (*__f)(_Arg)) 1299 {return pointer_to_unary_function<_Arg,_Result>(__f);} 1300 1301template <class _Arg1, class _Arg2, class _Result> 1302class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function 1303 : public binary_function<_Arg1, _Arg2, _Result> 1304{ 1305 _Result (*__f_)(_Arg1, _Arg2); 1306public: 1307 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) 1308 : __f_(__f) {} 1309 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const 1310 {return __f_(__x, __y);} 1311}; 1312 1313template <class _Arg1, class _Arg2, class _Result> 1314_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1315pointer_to_binary_function<_Arg1,_Arg2,_Result> 1316ptr_fun(_Result (*__f)(_Arg1,_Arg2)) 1317 {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} 1318 1319template<class _Sp, class _Tp> 1320class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t 1321 : public unary_function<_Tp*, _Sp> 1322{ 1323 _Sp (_Tp::*__p_)(); 1324public: 1325 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) 1326 : __p_(__p) {} 1327 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const 1328 {return (__p->*__p_)();} 1329}; 1330 1331template<class _Sp, class _Tp, class _Ap> 1332class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t 1333 : public binary_function<_Tp*, _Ap, _Sp> 1334{ 1335 _Sp (_Tp::*__p_)(_Ap); 1336public: 1337 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) 1338 : __p_(__p) {} 1339 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const 1340 {return (__p->*__p_)(__x);} 1341}; 1342 1343template<class _Sp, class _Tp> 1344_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1345mem_fun_t<_Sp,_Tp> 1346mem_fun(_Sp (_Tp::*__f)()) 1347 {return mem_fun_t<_Sp,_Tp>(__f);} 1348 1349template<class _Sp, class _Tp, class _Ap> 1350_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1351mem_fun1_t<_Sp,_Tp,_Ap> 1352mem_fun(_Sp (_Tp::*__f)(_Ap)) 1353 {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 1354 1355template<class _Sp, class _Tp> 1356class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t 1357 : public unary_function<_Tp, _Sp> 1358{ 1359 _Sp (_Tp::*__p_)(); 1360public: 1361 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) 1362 : __p_(__p) {} 1363 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const 1364 {return (__p.*__p_)();} 1365}; 1366 1367template<class _Sp, class _Tp, class _Ap> 1368class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t 1369 : public binary_function<_Tp, _Ap, _Sp> 1370{ 1371 _Sp (_Tp::*__p_)(_Ap); 1372public: 1373 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) 1374 : __p_(__p) {} 1375 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const 1376 {return (__p.*__p_)(__x);} 1377}; 1378 1379template<class _Sp, class _Tp> 1380_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1381mem_fun_ref_t<_Sp,_Tp> 1382mem_fun_ref(_Sp (_Tp::*__f)()) 1383 {return mem_fun_ref_t<_Sp,_Tp>(__f);} 1384 1385template<class _Sp, class _Tp, class _Ap> 1386_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1387mem_fun1_ref_t<_Sp,_Tp,_Ap> 1388mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) 1389 {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 1390 1391template <class _Sp, class _Tp> 1392class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t 1393 : public unary_function<const _Tp*, _Sp> 1394{ 1395 _Sp (_Tp::*__p_)() const; 1396public: 1397 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) 1398 : __p_(__p) {} 1399 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const 1400 {return (__p->*__p_)();} 1401}; 1402 1403template <class _Sp, class _Tp, class _Ap> 1404class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t 1405 : public binary_function<const _Tp*, _Ap, _Sp> 1406{ 1407 _Sp (_Tp::*__p_)(_Ap) const; 1408public: 1409 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) 1410 : __p_(__p) {} 1411 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const 1412 {return (__p->*__p_)(__x);} 1413}; 1414 1415template <class _Sp, class _Tp> 1416_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1417const_mem_fun_t<_Sp,_Tp> 1418mem_fun(_Sp (_Tp::*__f)() const) 1419 {return const_mem_fun_t<_Sp,_Tp>(__f);} 1420 1421template <class _Sp, class _Tp, class _Ap> 1422_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1423const_mem_fun1_t<_Sp,_Tp,_Ap> 1424mem_fun(_Sp (_Tp::*__f)(_Ap) const) 1425 {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 1426 1427template <class _Sp, class _Tp> 1428class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t 1429 : public unary_function<_Tp, _Sp> 1430{ 1431 _Sp (_Tp::*__p_)() const; 1432public: 1433 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) 1434 : __p_(__p) {} 1435 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const 1436 {return (__p.*__p_)();} 1437}; 1438 1439template <class _Sp, class _Tp, class _Ap> 1440class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t 1441 : public binary_function<_Tp, _Ap, _Sp> 1442{ 1443 _Sp (_Tp::*__p_)(_Ap) const; 1444public: 1445 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) 1446 : __p_(__p) {} 1447 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const 1448 {return (__p.*__p_)(__x);} 1449}; 1450 1451template <class _Sp, class _Tp> 1452_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1453const_mem_fun_ref_t<_Sp,_Tp> 1454mem_fun_ref(_Sp (_Tp::*__f)() const) 1455 {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} 1456 1457template <class _Sp, class _Tp, class _Ap> 1458_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 1459const_mem_fun1_ref_t<_Sp,_Tp,_Ap> 1460mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) 1461 {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 1462#endif 1463 1464//////////////////////////////////////////////////////////////////////////////// 1465// MEMFUN 1466//============================================================================== 1467 1468template <class _Tp> 1469class __mem_fn 1470#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) 1471 : public __weak_result_type<_Tp> 1472#endif 1473{ 1474public: 1475 // types 1476 typedef _Tp type; 1477private: 1478 type __f_; 1479 1480public: 1481 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 1482 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} 1483 1484#ifndef _LIBCPP_CXX03_LANG 1485 // invoke 1486 template <class... _ArgTypes> 1487 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 1488 typename __invoke_return<type, _ArgTypes...>::type 1489 operator() (_ArgTypes&&... __args) const { 1490 return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); 1491 } 1492#else 1493 1494 template <class _A0> 1495 _LIBCPP_INLINE_VISIBILITY 1496 typename __invoke_return0<type, _A0>::type 1497 operator() (_A0& __a0) const { 1498 return _VSTD::__invoke(__f_, __a0); 1499 } 1500 1501 template <class _A0> 1502 _LIBCPP_INLINE_VISIBILITY 1503 typename __invoke_return0<type, _A0 const>::type 1504 operator() (_A0 const& __a0) const { 1505 return _VSTD::__invoke(__f_, __a0); 1506 } 1507 1508 template <class _A0, class _A1> 1509 _LIBCPP_INLINE_VISIBILITY 1510 typename __invoke_return1<type, _A0, _A1>::type 1511 operator() (_A0& __a0, _A1& __a1) const { 1512 return _VSTD::__invoke(__f_, __a0, __a1); 1513 } 1514 1515 template <class _A0, class _A1> 1516 _LIBCPP_INLINE_VISIBILITY 1517 typename __invoke_return1<type, _A0 const, _A1>::type 1518 operator() (_A0 const& __a0, _A1& __a1) const { 1519 return _VSTD::__invoke(__f_, __a0, __a1); 1520 } 1521 1522 template <class _A0, class _A1> 1523 _LIBCPP_INLINE_VISIBILITY 1524 typename __invoke_return1<type, _A0, _A1 const>::type 1525 operator() (_A0& __a0, _A1 const& __a1) const { 1526 return _VSTD::__invoke(__f_, __a0, __a1); 1527 } 1528 1529 template <class _A0, class _A1> 1530 _LIBCPP_INLINE_VISIBILITY 1531 typename __invoke_return1<type, _A0 const, _A1 const>::type 1532 operator() (_A0 const& __a0, _A1 const& __a1) const { 1533 return _VSTD::__invoke(__f_, __a0, __a1); 1534 } 1535 1536 template <class _A0, class _A1, class _A2> 1537 _LIBCPP_INLINE_VISIBILITY 1538 typename __invoke_return2<type, _A0, _A1, _A2>::type 1539 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { 1540 return _VSTD::__invoke(__f_, __a0, __a1, __a2); 1541 } 1542 1543 template <class _A0, class _A1, class _A2> 1544 _LIBCPP_INLINE_VISIBILITY 1545 typename __invoke_return2<type, _A0 const, _A1, _A2>::type 1546 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { 1547 return _VSTD::__invoke(__f_, __a0, __a1, __a2); 1548 } 1549 1550 template <class _A0, class _A1, class _A2> 1551 _LIBCPP_INLINE_VISIBILITY 1552 typename __invoke_return2<type, _A0, _A1 const, _A2>::type 1553 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { 1554 return _VSTD::__invoke(__f_, __a0, __a1, __a2); 1555 } 1556 1557 template <class _A0, class _A1, class _A2> 1558 _LIBCPP_INLINE_VISIBILITY 1559 typename __invoke_return2<type, _A0, _A1, _A2 const>::type 1560 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { 1561 return _VSTD::__invoke(__f_, __a0, __a1, __a2); 1562 } 1563 1564 template <class _A0, class _A1, class _A2> 1565 _LIBCPP_INLINE_VISIBILITY 1566 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type 1567 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { 1568 return _VSTD::__invoke(__f_, __a0, __a1, __a2); 1569 } 1570 1571 template <class _A0, class _A1, class _A2> 1572 _LIBCPP_INLINE_VISIBILITY 1573 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type 1574 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { 1575 return _VSTD::__invoke(__f_, __a0, __a1, __a2); 1576 } 1577 1578 template <class _A0, class _A1, class _A2> 1579 _LIBCPP_INLINE_VISIBILITY 1580 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type 1581 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { 1582 return _VSTD::__invoke(__f_, __a0, __a1, __a2); 1583 } 1584 1585 template <class _A0, class _A1, class _A2> 1586 _LIBCPP_INLINE_VISIBILITY 1587 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type 1588 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { 1589 return _VSTD::__invoke(__f_, __a0, __a1, __a2); 1590 } 1591#endif 1592}; 1593 1594template<class _Rp, class _Tp> 1595inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 1596__mem_fn<_Rp _Tp::*> 1597mem_fn(_Rp _Tp::* __pm) _NOEXCEPT 1598{ 1599 return __mem_fn<_Rp _Tp::*>(__pm); 1600} 1601 1602//////////////////////////////////////////////////////////////////////////////// 1603// FUNCTION 1604//============================================================================== 1605 1606// bad_function_call 1607 1608class _LIBCPP_EXCEPTION_ABI bad_function_call 1609 : public exception 1610{ 1611#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 1612public: 1613 virtual ~bad_function_call() _NOEXCEPT; 1614 1615 virtual const char* what() const _NOEXCEPT; 1616#endif 1617}; 1618 1619_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY 1620void __throw_bad_function_call() 1621{ 1622#ifndef _LIBCPP_NO_EXCEPTIONS 1623 throw bad_function_call(); 1624#else 1625 _VSTD::abort(); 1626#endif 1627} 1628 1629#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && __has_attribute(deprecated) 1630# define _LIBCPP_DEPRECATED_CXX03_FUNCTION \ 1631 __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type"))) 1632#else 1633# define _LIBCPP_DEPRECATED_CXX03_FUNCTION /* nothing */ 1634#endif 1635 1636template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined 1637 1638namespace __function 1639{ 1640 1641template<class _Rp> 1642struct __maybe_derive_from_unary_function 1643{ 1644}; 1645 1646template<class _Rp, class _A1> 1647struct __maybe_derive_from_unary_function<_Rp(_A1)> 1648 : public unary_function<_A1, _Rp> 1649{ 1650}; 1651 1652template<class _Rp> 1653struct __maybe_derive_from_binary_function 1654{ 1655}; 1656 1657template<class _Rp, class _A1, class _A2> 1658struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> 1659 : public binary_function<_A1, _A2, _Rp> 1660{ 1661}; 1662 1663template <class _Fp> 1664_LIBCPP_INLINE_VISIBILITY 1665bool __not_null(_Fp const&) { return true; } 1666 1667template <class _Fp> 1668_LIBCPP_INLINE_VISIBILITY 1669bool __not_null(_Fp* __ptr) { return __ptr; } 1670 1671template <class _Ret, class _Class> 1672_LIBCPP_INLINE_VISIBILITY 1673bool __not_null(_Ret _Class::*__ptr) { return __ptr; } 1674 1675template <class _Fp> 1676_LIBCPP_INLINE_VISIBILITY 1677bool __not_null(function<_Fp> const& __f) { return !!__f; } 1678 1679#ifdef _LIBCPP_HAS_EXTENSION_BLOCKS 1680template <class _Rp, class ..._Args> 1681_LIBCPP_INLINE_VISIBILITY 1682bool __not_null(_Rp (^__p)(_Args...)) { return __p; } 1683#endif 1684 1685} // namespace __function 1686 1687#ifndef _LIBCPP_CXX03_LANG 1688 1689namespace __function { 1690 1691// __alloc_func holds a functor and an allocator. 1692 1693template <class _Fp, class _Ap, class _FB> class __alloc_func; 1694template <class _Fp, class _FB> 1695class __default_alloc_func; 1696 1697template <class _Fp, class _Ap, class _Rp, class... _ArgTypes> 1698class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> 1699{ 1700 __compressed_pair<_Fp, _Ap> __f_; 1701 1702 public: 1703 typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; 1704 typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc; 1705 1706 _LIBCPP_INLINE_VISIBILITY 1707 const _Target& __target() const { return __f_.first(); } 1708 1709 // WIN32 APIs may define __allocator, so use __get_allocator instead. 1710 _LIBCPP_INLINE_VISIBILITY 1711 const _Alloc& __get_allocator() const { return __f_.second(); } 1712 1713 _LIBCPP_INLINE_VISIBILITY 1714 explicit __alloc_func(_Target&& __f) 1715 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1716 _VSTD::forward_as_tuple()) 1717 { 1718 } 1719 1720 _LIBCPP_INLINE_VISIBILITY 1721 explicit __alloc_func(const _Target& __f, const _Alloc& __a) 1722 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1723 _VSTD::forward_as_tuple(__a)) 1724 { 1725 } 1726 1727 _LIBCPP_INLINE_VISIBILITY 1728 explicit __alloc_func(const _Target& __f, _Alloc&& __a) 1729 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1730 _VSTD::forward_as_tuple(_VSTD::move(__a))) 1731 { 1732 } 1733 1734 _LIBCPP_INLINE_VISIBILITY 1735 explicit __alloc_func(_Target&& __f, _Alloc&& __a) 1736 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1737 _VSTD::forward_as_tuple(_VSTD::move(__a))) 1738 { 1739 } 1740 1741 _LIBCPP_INLINE_VISIBILITY 1742 _Rp operator()(_ArgTypes&&... __arg) 1743 { 1744 typedef __invoke_void_return_wrapper<_Rp> _Invoker; 1745 return _Invoker::__call(__f_.first(), 1746 _VSTD::forward<_ArgTypes>(__arg)...); 1747 } 1748 1749 _LIBCPP_INLINE_VISIBILITY 1750 __alloc_func* __clone() const 1751 { 1752 typedef allocator_traits<_Alloc> __alloc_traits; 1753 typedef 1754 typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type 1755 _AA; 1756 _AA __a(__f_.second()); 1757 typedef __allocator_destructor<_AA> _Dp; 1758 unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1759 ::new ((void*)__hold.get()) __alloc_func(__f_.first(), _Alloc(__a)); 1760 return __hold.release(); 1761 } 1762 1763 _LIBCPP_INLINE_VISIBILITY 1764 void destroy() _NOEXCEPT { __f_.~__compressed_pair<_Target, _Alloc>(); } 1765 1766 static void __destroy_and_delete(__alloc_func* __f) { 1767 typedef allocator_traits<_Alloc> __alloc_traits; 1768 typedef typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type 1769 _FunAlloc; 1770 _FunAlloc __a(__f->__get_allocator()); 1771 __f->destroy(); 1772 __a.deallocate(__f, 1); 1773 } 1774}; 1775 1776template <class _Fp, class _Rp, class... _ArgTypes> 1777class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> { 1778 _Fp __f_; 1779 1780public: 1781 typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; 1782 1783 _LIBCPP_INLINE_VISIBILITY 1784 const _Target& __target() const { return __f_; } 1785 1786 _LIBCPP_INLINE_VISIBILITY 1787 explicit __default_alloc_func(_Target&& __f) : __f_(_VSTD::move(__f)) {} 1788 1789 _LIBCPP_INLINE_VISIBILITY 1790 explicit __default_alloc_func(const _Target& __f) : __f_(__f) {} 1791 1792 _LIBCPP_INLINE_VISIBILITY 1793 _Rp operator()(_ArgTypes&&... __arg) { 1794 typedef __invoke_void_return_wrapper<_Rp> _Invoker; 1795 return _Invoker::__call(__f_, _VSTD::forward<_ArgTypes>(__arg)...); 1796 } 1797 1798 _LIBCPP_INLINE_VISIBILITY 1799 __default_alloc_func* __clone() const { 1800 __builtin_new_allocator::__holder_t __hold = 1801 __builtin_new_allocator::__allocate_type<__default_alloc_func>(1); 1802 __default_alloc_func* __res = 1803 ::new ((void*)__hold.get()) __default_alloc_func(__f_); 1804 (void)__hold.release(); 1805 return __res; 1806 } 1807 1808 _LIBCPP_INLINE_VISIBILITY 1809 void destroy() _NOEXCEPT { __f_.~_Target(); } 1810 1811 static void __destroy_and_delete(__default_alloc_func* __f) { 1812 __f->destroy(); 1813 __builtin_new_allocator::__deallocate_type<__default_alloc_func>(__f, 1); 1814 } 1815}; 1816 1817// __base provides an abstract interface for copyable functors. 1818 1819template<class _Fp> class _LIBCPP_TEMPLATE_VIS __base; 1820 1821template<class _Rp, class ..._ArgTypes> 1822class __base<_Rp(_ArgTypes...)> 1823{ 1824 __base(const __base&); 1825 __base& operator=(const __base&); 1826public: 1827 _LIBCPP_INLINE_VISIBILITY __base() {} 1828 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} 1829 virtual __base* __clone() const = 0; 1830 virtual void __clone(__base*) const = 0; 1831 virtual void destroy() _NOEXCEPT = 0; 1832 virtual void destroy_deallocate() _NOEXCEPT = 0; 1833 virtual _Rp operator()(_ArgTypes&& ...) = 0; 1834#ifndef _LIBCPP_NO_RTTI 1835 virtual const void* target(const type_info&) const _NOEXCEPT = 0; 1836 virtual const std::type_info& target_type() const _NOEXCEPT = 0; 1837#endif // _LIBCPP_NO_RTTI 1838}; 1839 1840// __func implements __base for a given functor type. 1841 1842template<class _FD, class _Alloc, class _FB> class __func; 1843 1844template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1845class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> 1846 : public __base<_Rp(_ArgTypes...)> 1847{ 1848 __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_; 1849public: 1850 _LIBCPP_INLINE_VISIBILITY 1851 explicit __func(_Fp&& __f) 1852 : __f_(_VSTD::move(__f)) {} 1853 1854 _LIBCPP_INLINE_VISIBILITY 1855 explicit __func(const _Fp& __f, const _Alloc& __a) 1856 : __f_(__f, __a) {} 1857 1858 _LIBCPP_INLINE_VISIBILITY 1859 explicit __func(const _Fp& __f, _Alloc&& __a) 1860 : __f_(__f, _VSTD::move(__a)) {} 1861 1862 _LIBCPP_INLINE_VISIBILITY 1863 explicit __func(_Fp&& __f, _Alloc&& __a) 1864 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} 1865 1866 virtual __base<_Rp(_ArgTypes...)>* __clone() const; 1867 virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; 1868 virtual void destroy() _NOEXCEPT; 1869 virtual void destroy_deallocate() _NOEXCEPT; 1870 virtual _Rp operator()(_ArgTypes&&... __arg); 1871#ifndef _LIBCPP_NO_RTTI 1872 virtual const void* target(const type_info&) const _NOEXCEPT; 1873 virtual const std::type_info& target_type() const _NOEXCEPT; 1874#endif // _LIBCPP_NO_RTTI 1875}; 1876 1877template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1878__base<_Rp(_ArgTypes...)>* 1879__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const 1880{ 1881 typedef allocator_traits<_Alloc> __alloc_traits; 1882 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; 1883 _Ap __a(__f_.__get_allocator()); 1884 typedef __allocator_destructor<_Ap> _Dp; 1885 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1886 ::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a)); 1887 return __hold.release(); 1888} 1889 1890template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1891void 1892__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const 1893{ 1894 ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator()); 1895} 1896 1897template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1898void 1899__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT 1900{ 1901 __f_.destroy(); 1902} 1903 1904template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1905void 1906__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT 1907{ 1908 typedef allocator_traits<_Alloc> __alloc_traits; 1909 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; 1910 _Ap __a(__f_.__get_allocator()); 1911 __f_.destroy(); 1912 __a.deallocate(this, 1); 1913} 1914 1915template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1916_Rp 1917__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) 1918{ 1919 return __f_(_VSTD::forward<_ArgTypes>(__arg)...); 1920} 1921 1922#ifndef _LIBCPP_NO_RTTI 1923 1924template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1925const void* 1926__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT 1927{ 1928 if (__ti == typeid(_Fp)) 1929 return &__f_.__target(); 1930 return nullptr; 1931} 1932 1933template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1934const std::type_info& 1935__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1936{ 1937 return typeid(_Fp); 1938} 1939 1940#endif // _LIBCPP_NO_RTTI 1941 1942// __value_func creates a value-type from a __func. 1943 1944template <class _Fp> class __value_func; 1945 1946template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)> 1947{ 1948 typename aligned_storage<3 * sizeof(void*)>::type __buf_; 1949 1950 typedef __base<_Rp(_ArgTypes...)> __func; 1951 __func* __f_; 1952 1953 _LIBCPP_NO_CFI static __func* __as_base(void* p) 1954 { 1955 return reinterpret_cast<__func*>(p); 1956 } 1957 1958 public: 1959 _LIBCPP_INLINE_VISIBILITY 1960 __value_func() _NOEXCEPT : __f_(nullptr) {} 1961 1962 template <class _Fp, class _Alloc> 1963 _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a) 1964 : __f_(nullptr) 1965 { 1966 typedef allocator_traits<_Alloc> __alloc_traits; 1967 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun; 1968 typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type 1969 _FunAlloc; 1970 1971 if (__function::__not_null(__f)) 1972 { 1973 _FunAlloc __af(__a); 1974 if (sizeof(_Fun) <= sizeof(__buf_) && 1975 is_nothrow_copy_constructible<_Fp>::value && 1976 is_nothrow_copy_constructible<_FunAlloc>::value) 1977 { 1978 __f_ = 1979 ::new ((void*)&__buf_) _Fun(_VSTD::move(__f), _Alloc(__af)); 1980 } 1981 else 1982 { 1983 typedef __allocator_destructor<_FunAlloc> _Dp; 1984 unique_ptr<__func, _Dp> __hold(__af.allocate(1), _Dp(__af, 1)); 1985 ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f), _Alloc(__a)); 1986 __f_ = __hold.release(); 1987 } 1988 } 1989 } 1990 1991 template <class _Fp, 1992 class = typename enable_if<!is_same<typename decay<_Fp>::type, __value_func>::value>::type> 1993 _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f) 1994 : __value_func(_VSTD::forward<_Fp>(__f), allocator<_Fp>()) {} 1995 1996 _LIBCPP_INLINE_VISIBILITY 1997 __value_func(const __value_func& __f) 1998 { 1999 if (__f.__f_ == nullptr) 2000 __f_ = nullptr; 2001 else if ((void*)__f.__f_ == &__f.__buf_) 2002 { 2003 __f_ = __as_base(&__buf_); 2004 __f.__f_->__clone(__f_); 2005 } 2006 else 2007 __f_ = __f.__f_->__clone(); 2008 } 2009 2010 _LIBCPP_INLINE_VISIBILITY 2011 __value_func(__value_func&& __f) _NOEXCEPT 2012 { 2013 if (__f.__f_ == nullptr) 2014 __f_ = nullptr; 2015 else if ((void*)__f.__f_ == &__f.__buf_) 2016 { 2017 __f_ = __as_base(&__buf_); 2018 __f.__f_->__clone(__f_); 2019 } 2020 else 2021 { 2022 __f_ = __f.__f_; 2023 __f.__f_ = nullptr; 2024 } 2025 } 2026 2027 _LIBCPP_INLINE_VISIBILITY 2028 ~__value_func() 2029 { 2030 if ((void*)__f_ == &__buf_) 2031 __f_->destroy(); 2032 else if (__f_) 2033 __f_->destroy_deallocate(); 2034 } 2035 2036 _LIBCPP_INLINE_VISIBILITY 2037 __value_func& operator=(__value_func&& __f) 2038 { 2039 *this = nullptr; 2040 if (__f.__f_ == nullptr) 2041 __f_ = nullptr; 2042 else if ((void*)__f.__f_ == &__f.__buf_) 2043 { 2044 __f_ = __as_base(&__buf_); 2045 __f.__f_->__clone(__f_); 2046 } 2047 else 2048 { 2049 __f_ = __f.__f_; 2050 __f.__f_ = nullptr; 2051 } 2052 return *this; 2053 } 2054 2055 _LIBCPP_INLINE_VISIBILITY 2056 __value_func& operator=(nullptr_t) 2057 { 2058 __func* __f = __f_; 2059 __f_ = nullptr; 2060 if ((void*)__f == &__buf_) 2061 __f->destroy(); 2062 else if (__f) 2063 __f->destroy_deallocate(); 2064 return *this; 2065 } 2066 2067 _LIBCPP_INLINE_VISIBILITY 2068 _Rp operator()(_ArgTypes&&... __args) const 2069 { 2070 if (__f_ == nullptr) 2071 __throw_bad_function_call(); 2072 return (*__f_)(_VSTD::forward<_ArgTypes>(__args)...); 2073 } 2074 2075 _LIBCPP_INLINE_VISIBILITY 2076 void swap(__value_func& __f) _NOEXCEPT 2077 { 2078 if (&__f == this) 2079 return; 2080 if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) 2081 { 2082 typename aligned_storage<sizeof(__buf_)>::type __tempbuf; 2083 __func* __t = __as_base(&__tempbuf); 2084 __f_->__clone(__t); 2085 __f_->destroy(); 2086 __f_ = nullptr; 2087 __f.__f_->__clone(__as_base(&__buf_)); 2088 __f.__f_->destroy(); 2089 __f.__f_ = nullptr; 2090 __f_ = __as_base(&__buf_); 2091 __t->__clone(__as_base(&__f.__buf_)); 2092 __t->destroy(); 2093 __f.__f_ = __as_base(&__f.__buf_); 2094 } 2095 else if ((void*)__f_ == &__buf_) 2096 { 2097 __f_->__clone(__as_base(&__f.__buf_)); 2098 __f_->destroy(); 2099 __f_ = __f.__f_; 2100 __f.__f_ = __as_base(&__f.__buf_); 2101 } 2102 else if ((void*)__f.__f_ == &__f.__buf_) 2103 { 2104 __f.__f_->__clone(__as_base(&__buf_)); 2105 __f.__f_->destroy(); 2106 __f.__f_ = __f_; 2107 __f_ = __as_base(&__buf_); 2108 } 2109 else 2110 _VSTD::swap(__f_, __f.__f_); 2111 } 2112 2113 _LIBCPP_INLINE_VISIBILITY 2114 explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; } 2115 2116#ifndef _LIBCPP_NO_RTTI 2117 _LIBCPP_INLINE_VISIBILITY 2118 const std::type_info& target_type() const _NOEXCEPT 2119 { 2120 if (__f_ == nullptr) 2121 return typeid(void); 2122 return __f_->target_type(); 2123 } 2124 2125 template <typename _Tp> 2126 _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT 2127 { 2128 if (__f_ == nullptr) 2129 return nullptr; 2130 return (const _Tp*)__f_->target(typeid(_Tp)); 2131 } 2132#endif // _LIBCPP_NO_RTTI 2133}; 2134 2135// Storage for a functor object, to be used with __policy to manage copy and 2136// destruction. 2137union __policy_storage 2138{ 2139 mutable char __small[sizeof(void*) * 2]; 2140 void* __large; 2141}; 2142 2143// True if _Fun can safely be held in __policy_storage.__small. 2144template <typename _Fun> 2145struct __use_small_storage 2146 : public integral_constant< 2147 bool, sizeof(_Fun) <= sizeof(__policy_storage) && 2148 _LIBCPP_ALIGNOF(_Fun) <= _LIBCPP_ALIGNOF(__policy_storage) && 2149 is_trivially_copy_constructible<_Fun>::value && 2150 is_trivially_destructible<_Fun>::value> {}; 2151 2152// Policy contains information about how to copy, destroy, and move the 2153// underlying functor. You can think of it as a vtable of sorts. 2154struct __policy 2155{ 2156 // Used to copy or destroy __large values. null for trivial objects. 2157 void* (*const __clone)(const void*); 2158 void (*const __destroy)(void*); 2159 2160 // True if this is the null policy (no value). 2161 const bool __is_null; 2162 2163 // The target type. May be null if RTTI is disabled. 2164 const std::type_info* const __type_info; 2165 2166 // Returns a pointer to a static policy object suitable for the functor 2167 // type. 2168 template <typename _Fun> 2169 _LIBCPP_INLINE_VISIBILITY static const __policy* __create() 2170 { 2171 return __choose_policy<_Fun>(__use_small_storage<_Fun>()); 2172 } 2173 2174 _LIBCPP_INLINE_VISIBILITY 2175 static const __policy* __create_empty() 2176 { 2177 static const _LIBCPP_CONSTEXPR __policy __policy_ = {nullptr, nullptr, 2178 true, 2179#ifndef _LIBCPP_NO_RTTI 2180 &typeid(void) 2181#else 2182 nullptr 2183#endif 2184 }; 2185 return &__policy_; 2186 } 2187 2188 private: 2189 template <typename _Fun> static void* __large_clone(const void* __s) 2190 { 2191 const _Fun* __f = static_cast<const _Fun*>(__s); 2192 return __f->__clone(); 2193 } 2194 2195 template <typename _Fun> 2196 static void __large_destroy(void* __s) { 2197 _Fun::__destroy_and_delete(static_cast<_Fun*>(__s)); 2198 } 2199 2200 template <typename _Fun> 2201 _LIBCPP_INLINE_VISIBILITY static const __policy* 2202 __choose_policy(/* is_small = */ false_type) { 2203 static const _LIBCPP_CONSTEXPR __policy __policy_ = { 2204 &__large_clone<_Fun>, &__large_destroy<_Fun>, false, 2205#ifndef _LIBCPP_NO_RTTI 2206 &typeid(typename _Fun::_Target) 2207#else 2208 nullptr 2209#endif 2210 }; 2211 return &__policy_; 2212 } 2213 2214 template <typename _Fun> 2215 _LIBCPP_INLINE_VISIBILITY static const __policy* 2216 __choose_policy(/* is_small = */ true_type) 2217 { 2218 static const _LIBCPP_CONSTEXPR __policy __policy_ = { 2219 nullptr, nullptr, false, 2220#ifndef _LIBCPP_NO_RTTI 2221 &typeid(typename _Fun::_Target) 2222#else 2223 nullptr 2224#endif 2225 }; 2226 return &__policy_; 2227 } 2228}; 2229 2230// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is 2231// faster for types that can be passed in registers. 2232template <typename _Tp> 2233using __fast_forward = 2234 typename conditional<is_scalar<_Tp>::value, _Tp, _Tp&&>::type; 2235 2236// __policy_invoker calls an instance of __alloc_func held in __policy_storage. 2237 2238template <class _Fp> struct __policy_invoker; 2239 2240template <class _Rp, class... _ArgTypes> 2241struct __policy_invoker<_Rp(_ArgTypes...)> 2242{ 2243 typedef _Rp (*__Call)(const __policy_storage*, 2244 __fast_forward<_ArgTypes>...); 2245 2246 __Call __call_; 2247 2248 // Creates an invoker that throws bad_function_call. 2249 _LIBCPP_INLINE_VISIBILITY 2250 __policy_invoker() : __call_(&__call_empty) {} 2251 2252 // Creates an invoker that calls the given instance of __func. 2253 template <typename _Fun> 2254 _LIBCPP_INLINE_VISIBILITY static __policy_invoker __create() 2255 { 2256 return __policy_invoker(&__call_impl<_Fun>); 2257 } 2258 2259 private: 2260 _LIBCPP_INLINE_VISIBILITY 2261 explicit __policy_invoker(__Call __c) : __call_(__c) {} 2262 2263 static _Rp __call_empty(const __policy_storage*, 2264 __fast_forward<_ArgTypes>...) 2265 { 2266 __throw_bad_function_call(); 2267 } 2268 2269 template <typename _Fun> 2270 static _Rp __call_impl(const __policy_storage* __buf, 2271 __fast_forward<_ArgTypes>... __args) 2272 { 2273 _Fun* __f = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value 2274 ? &__buf->__small 2275 : __buf->__large); 2276 return (*__f)(_VSTD::forward<_ArgTypes>(__args)...); 2277 } 2278}; 2279 2280// __policy_func uses a __policy and __policy_invoker to create a type-erased, 2281// copyable functor. 2282 2283template <class _Fp> class __policy_func; 2284 2285template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)> 2286{ 2287 // Inline storage for small objects. 2288 __policy_storage __buf_; 2289 2290 // Calls the value stored in __buf_. This could technically be part of 2291 // policy, but storing it here eliminates a level of indirection inside 2292 // operator(). 2293 typedef __function::__policy_invoker<_Rp(_ArgTypes...)> __invoker; 2294 __invoker __invoker_; 2295 2296 // The policy that describes how to move / copy / destroy __buf_. Never 2297 // null, even if the function is empty. 2298 const __policy* __policy_; 2299 2300 public: 2301 _LIBCPP_INLINE_VISIBILITY 2302 __policy_func() : __policy_(__policy::__create_empty()) {} 2303 2304 template <class _Fp, class _Alloc> 2305 _LIBCPP_INLINE_VISIBILITY __policy_func(_Fp&& __f, const _Alloc& __a) 2306 : __policy_(__policy::__create_empty()) 2307 { 2308 typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun; 2309 typedef allocator_traits<_Alloc> __alloc_traits; 2310 typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type 2311 _FunAlloc; 2312 2313 if (__function::__not_null(__f)) 2314 { 2315 __invoker_ = __invoker::template __create<_Fun>(); 2316 __policy_ = __policy::__create<_Fun>(); 2317 2318 _FunAlloc __af(__a); 2319 if (__use_small_storage<_Fun>()) 2320 { 2321 ::new ((void*)&__buf_.__small) 2322 _Fun(_VSTD::move(__f), _Alloc(__af)); 2323 } 2324 else 2325 { 2326 typedef __allocator_destructor<_FunAlloc> _Dp; 2327 unique_ptr<_Fun, _Dp> __hold(__af.allocate(1), _Dp(__af, 1)); 2328 ::new ((void*)__hold.get()) 2329 _Fun(_VSTD::move(__f), _Alloc(__af)); 2330 __buf_.__large = __hold.release(); 2331 } 2332 } 2333 } 2334 2335 template <class _Fp, class = typename enable_if<!is_same<typename decay<_Fp>::type, __policy_func>::value>::type> 2336 _LIBCPP_INLINE_VISIBILITY explicit __policy_func(_Fp&& __f) 2337 : __policy_(__policy::__create_empty()) { 2338 typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun; 2339 2340 if (__function::__not_null(__f)) { 2341 __invoker_ = __invoker::template __create<_Fun>(); 2342 __policy_ = __policy::__create<_Fun>(); 2343 if (__use_small_storage<_Fun>()) { 2344 ::new ((void*)&__buf_.__small) _Fun(_VSTD::move(__f)); 2345 } else { 2346 __builtin_new_allocator::__holder_t __hold = 2347 __builtin_new_allocator::__allocate_type<_Fun>(1); 2348 __buf_.__large = ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f)); 2349 (void)__hold.release(); 2350 } 2351 } 2352 } 2353 2354 _LIBCPP_INLINE_VISIBILITY 2355 __policy_func(const __policy_func& __f) 2356 : __buf_(__f.__buf_), __invoker_(__f.__invoker_), 2357 __policy_(__f.__policy_) 2358 { 2359 if (__policy_->__clone) 2360 __buf_.__large = __policy_->__clone(__f.__buf_.__large); 2361 } 2362 2363 _LIBCPP_INLINE_VISIBILITY 2364 __policy_func(__policy_func&& __f) 2365 : __buf_(__f.__buf_), __invoker_(__f.__invoker_), 2366 __policy_(__f.__policy_) 2367 { 2368 if (__policy_->__destroy) 2369 { 2370 __f.__policy_ = __policy::__create_empty(); 2371 __f.__invoker_ = __invoker(); 2372 } 2373 } 2374 2375 _LIBCPP_INLINE_VISIBILITY 2376 ~__policy_func() 2377 { 2378 if (__policy_->__destroy) 2379 __policy_->__destroy(__buf_.__large); 2380 } 2381 2382 _LIBCPP_INLINE_VISIBILITY 2383 __policy_func& operator=(__policy_func&& __f) 2384 { 2385 *this = nullptr; 2386 __buf_ = __f.__buf_; 2387 __invoker_ = __f.__invoker_; 2388 __policy_ = __f.__policy_; 2389 __f.__policy_ = __policy::__create_empty(); 2390 __f.__invoker_ = __invoker(); 2391 return *this; 2392 } 2393 2394 _LIBCPP_INLINE_VISIBILITY 2395 __policy_func& operator=(nullptr_t) 2396 { 2397 const __policy* __p = __policy_; 2398 __policy_ = __policy::__create_empty(); 2399 __invoker_ = __invoker(); 2400 if (__p->__destroy) 2401 __p->__destroy(__buf_.__large); 2402 return *this; 2403 } 2404 2405 _LIBCPP_INLINE_VISIBILITY 2406 _Rp operator()(_ArgTypes&&... __args) const 2407 { 2408 return __invoker_.__call_(_VSTD::addressof(__buf_), 2409 _VSTD::forward<_ArgTypes>(__args)...); 2410 } 2411 2412 _LIBCPP_INLINE_VISIBILITY 2413 void swap(__policy_func& __f) 2414 { 2415 _VSTD::swap(__invoker_, __f.__invoker_); 2416 _VSTD::swap(__policy_, __f.__policy_); 2417 _VSTD::swap(__buf_, __f.__buf_); 2418 } 2419 2420 _LIBCPP_INLINE_VISIBILITY 2421 explicit operator bool() const _NOEXCEPT 2422 { 2423 return !__policy_->__is_null; 2424 } 2425 2426#ifndef _LIBCPP_NO_RTTI 2427 _LIBCPP_INLINE_VISIBILITY 2428 const std::type_info& target_type() const _NOEXCEPT 2429 { 2430 return *__policy_->__type_info; 2431 } 2432 2433 template <typename _Tp> 2434 _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT 2435 { 2436 if (__policy_->__is_null || typeid(_Tp) != *__policy_->__type_info) 2437 return nullptr; 2438 if (__policy_->__clone) // Out of line storage. 2439 return reinterpret_cast<const _Tp*>(__buf_.__large); 2440 else 2441 return reinterpret_cast<const _Tp*>(&__buf_.__small); 2442 } 2443#endif // _LIBCPP_NO_RTTI 2444}; 2445 2446#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC) 2447 2448extern "C" void *_Block_copy(const void *); 2449extern "C" void _Block_release(const void *); 2450 2451template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes> 2452class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> 2453 : public __base<_Rp(_ArgTypes...)> 2454{ 2455 typedef _Rp1(^__block_type)(_ArgTypes1...); 2456 __block_type __f_; 2457 2458public: 2459 _LIBCPP_INLINE_VISIBILITY 2460 explicit __func(__block_type const& __f) 2461 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) 2462 { } 2463 2464 // [TODO] add && to save on a retain 2465 2466 _LIBCPP_INLINE_VISIBILITY 2467 explicit __func(__block_type __f, const _Alloc& /* unused */) 2468 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) 2469 { } 2470 2471 virtual __base<_Rp(_ArgTypes...)>* __clone() const { 2472 _LIBCPP_ASSERT(false, 2473 "Block pointers are just pointers, so they should always fit into " 2474 "std::function's small buffer optimization. This function should " 2475 "never be invoked."); 2476 return nullptr; 2477 } 2478 2479 virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const { 2480 ::new ((void*)__p) __func(__f_); 2481 } 2482 2483 virtual void destroy() _NOEXCEPT { 2484 if (__f_) 2485 _Block_release(__f_); 2486 __f_ = 0; 2487 } 2488 2489 virtual void destroy_deallocate() _NOEXCEPT { 2490 _LIBCPP_ASSERT(false, 2491 "Block pointers are just pointers, so they should always fit into " 2492 "std::function's small buffer optimization. This function should " 2493 "never be invoked."); 2494 } 2495 2496 virtual _Rp operator()(_ArgTypes&& ... __arg) { 2497 return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...); 2498 } 2499 2500#ifndef _LIBCPP_NO_RTTI 2501 virtual const void* target(type_info const& __ti) const _NOEXCEPT { 2502 if (__ti == typeid(__func::__block_type)) 2503 return &__f_; 2504 return (const void*)nullptr; 2505 } 2506 2507 virtual const std::type_info& target_type() const _NOEXCEPT { 2508 return typeid(__func::__block_type); 2509 } 2510#endif // _LIBCPP_NO_RTTI 2511}; 2512 2513#endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC 2514 2515} // __function 2516 2517template<class _Rp, class ..._ArgTypes> 2518class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> 2519#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) 2520 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, 2521 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> 2522#endif 2523{ 2524#ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION 2525 typedef __function::__value_func<_Rp(_ArgTypes...)> __func; 2526#else 2527 typedef __function::__policy_func<_Rp(_ArgTypes...)> __func; 2528#endif 2529 2530 __func __f_; 2531 2532 template <class _Fp, bool = _And< 2533 _IsNotSame<__uncvref_t<_Fp>, function>, 2534 __invokable<_Fp, _ArgTypes...> 2535 >::value> 2536 struct __callable; 2537 template <class _Fp> 2538 struct __callable<_Fp, true> 2539 { 2540 static const bool value = is_void<_Rp>::value || 2541 __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type, 2542 _Rp>::value; 2543 }; 2544 template <class _Fp> 2545 struct __callable<_Fp, false> 2546 { 2547 static const bool value = false; 2548 }; 2549 2550 template <class _Fp> 2551 using _EnableIfLValueCallable = typename enable_if<__callable<_Fp&>::value>::type; 2552public: 2553 typedef _Rp result_type; 2554 2555 // construct/copy/destroy: 2556 _LIBCPP_INLINE_VISIBILITY 2557 function() _NOEXCEPT { } 2558 _LIBCPP_INLINE_VISIBILITY 2559 function(nullptr_t) _NOEXCEPT {} 2560 function(const function&); 2561 function(function&&) _NOEXCEPT; 2562 template<class _Fp, class = _EnableIfLValueCallable<_Fp>> 2563 function(_Fp); 2564 2565#if _LIBCPP_STD_VER <= 14 2566 template<class _Alloc> 2567 _LIBCPP_INLINE_VISIBILITY 2568 function(allocator_arg_t, const _Alloc&) _NOEXCEPT {} 2569 template<class _Alloc> 2570 _LIBCPP_INLINE_VISIBILITY 2571 function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT {} 2572 template<class _Alloc> 2573 function(allocator_arg_t, const _Alloc&, const function&); 2574 template<class _Alloc> 2575 function(allocator_arg_t, const _Alloc&, function&&); 2576 template<class _Fp, class _Alloc, class = _EnableIfLValueCallable<_Fp>> 2577 function(allocator_arg_t, const _Alloc& __a, _Fp __f); 2578#endif 2579 2580 function& operator=(const function&); 2581 function& operator=(function&&) _NOEXCEPT; 2582 function& operator=(nullptr_t) _NOEXCEPT; 2583 template<class _Fp, class = _EnableIfLValueCallable<typename decay<_Fp>::type>> 2584 function& operator=(_Fp&&); 2585 2586 ~function(); 2587 2588 // function modifiers: 2589 void swap(function&) _NOEXCEPT; 2590 2591#if _LIBCPP_STD_VER <= 14 2592 template<class _Fp, class _Alloc> 2593 _LIBCPP_INLINE_VISIBILITY 2594 void assign(_Fp&& __f, const _Alloc& __a) 2595 {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} 2596#endif 2597 2598 // function capacity: 2599 _LIBCPP_INLINE_VISIBILITY 2600 explicit operator bool() const _NOEXCEPT { 2601 return static_cast<bool>(__f_); 2602 } 2603 2604 // deleted overloads close possible hole in the type system 2605 template<class _R2, class... _ArgTypes2> 2606 bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; 2607 template<class _R2, class... _ArgTypes2> 2608 bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; 2609public: 2610 // function invocation: 2611 _Rp operator()(_ArgTypes...) const; 2612 2613#ifndef _LIBCPP_NO_RTTI 2614 // function target access: 2615 const std::type_info& target_type() const _NOEXCEPT; 2616 template <typename _Tp> _Tp* target() _NOEXCEPT; 2617 template <typename _Tp> const _Tp* target() const _NOEXCEPT; 2618#endif // _LIBCPP_NO_RTTI 2619}; 2620 2621#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 2622template<class _Rp, class ..._Ap> 2623function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>; 2624 2625template<class _Fp> 2626struct __strip_signature; 2627 2628template<class _Rp, class _Gp, class ..._Ap> 2629struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); }; 2630template<class _Rp, class _Gp, class ..._Ap> 2631struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); }; 2632template<class _Rp, class _Gp, class ..._Ap> 2633struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); }; 2634template<class _Rp, class _Gp, class ..._Ap> 2635struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); }; 2636 2637template<class _Rp, class _Gp, class ..._Ap> 2638struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); }; 2639template<class _Rp, class _Gp, class ..._Ap> 2640struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); }; 2641template<class _Rp, class _Gp, class ..._Ap> 2642struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); }; 2643template<class _Rp, class _Gp, class ..._Ap> 2644struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); }; 2645 2646template<class _Rp, class _Gp, class ..._Ap> 2647struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); }; 2648template<class _Rp, class _Gp, class ..._Ap> 2649struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); }; 2650template<class _Rp, class _Gp, class ..._Ap> 2651struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); }; 2652template<class _Rp, class _Gp, class ..._Ap> 2653struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); }; 2654 2655template<class _Rp, class _Gp, class ..._Ap> 2656struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); }; 2657template<class _Rp, class _Gp, class ..._Ap> 2658struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); }; 2659template<class _Rp, class _Gp, class ..._Ap> 2660struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); }; 2661template<class _Rp, class _Gp, class ..._Ap> 2662struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); }; 2663 2664template<class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type> 2665function(_Fp) -> function<_Stripped>; 2666#endif // !_LIBCPP_HAS_NO_DEDUCTION_GUIDES 2667 2668template<class _Rp, class ..._ArgTypes> 2669function<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {} 2670 2671#if _LIBCPP_STD_VER <= 14 2672template<class _Rp, class ..._ArgTypes> 2673template <class _Alloc> 2674function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 2675 const function& __f) : __f_(__f.__f_) {} 2676#endif 2677 2678template <class _Rp, class... _ArgTypes> 2679function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT 2680 : __f_(_VSTD::move(__f.__f_)) {} 2681 2682#if _LIBCPP_STD_VER <= 14 2683template<class _Rp, class ..._ArgTypes> 2684template <class _Alloc> 2685function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 2686 function&& __f) 2687 : __f_(_VSTD::move(__f.__f_)) {} 2688#endif 2689 2690template <class _Rp, class... _ArgTypes> 2691template <class _Fp, class> 2692function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(_VSTD::move(__f)) {} 2693 2694#if _LIBCPP_STD_VER <= 14 2695template <class _Rp, class... _ArgTypes> 2696template <class _Fp, class _Alloc, class> 2697function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a, 2698 _Fp __f) 2699 : __f_(_VSTD::move(__f), __a) {} 2700#endif 2701 2702template<class _Rp, class ..._ArgTypes> 2703function<_Rp(_ArgTypes...)>& 2704function<_Rp(_ArgTypes...)>::operator=(const function& __f) 2705{ 2706 function(__f).swap(*this); 2707 return *this; 2708} 2709 2710template<class _Rp, class ..._ArgTypes> 2711function<_Rp(_ArgTypes...)>& 2712function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT 2713{ 2714 __f_ = _VSTD::move(__f.__f_); 2715 return *this; 2716} 2717 2718template<class _Rp, class ..._ArgTypes> 2719function<_Rp(_ArgTypes...)>& 2720function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT 2721{ 2722 __f_ = nullptr; 2723 return *this; 2724} 2725 2726template<class _Rp, class ..._ArgTypes> 2727template <class _Fp, class> 2728function<_Rp(_ArgTypes...)>& 2729function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) 2730{ 2731 function(_VSTD::forward<_Fp>(__f)).swap(*this); 2732 return *this; 2733} 2734 2735template<class _Rp, class ..._ArgTypes> 2736function<_Rp(_ArgTypes...)>::~function() {} 2737 2738template<class _Rp, class ..._ArgTypes> 2739void 2740function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT 2741{ 2742 __f_.swap(__f.__f_); 2743} 2744 2745template<class _Rp, class ..._ArgTypes> 2746_Rp 2747function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const 2748{ 2749 return __f_(_VSTD::forward<_ArgTypes>(__arg)...); 2750} 2751 2752#ifndef _LIBCPP_NO_RTTI 2753 2754template<class _Rp, class ..._ArgTypes> 2755const std::type_info& 2756function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 2757{ 2758 return __f_.target_type(); 2759} 2760 2761template<class _Rp, class ..._ArgTypes> 2762template <typename _Tp> 2763_Tp* 2764function<_Rp(_ArgTypes...)>::target() _NOEXCEPT 2765{ 2766 return (_Tp*)(__f_.template target<_Tp>()); 2767} 2768 2769template<class _Rp, class ..._ArgTypes> 2770template <typename _Tp> 2771const _Tp* 2772function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT 2773{ 2774 return __f_.template target<_Tp>(); 2775} 2776 2777#endif // _LIBCPP_NO_RTTI 2778 2779template <class _Rp, class... _ArgTypes> 2780inline _LIBCPP_INLINE_VISIBILITY 2781bool 2782operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} 2783 2784template <class _Rp, class... _ArgTypes> 2785inline _LIBCPP_INLINE_VISIBILITY 2786bool 2787operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} 2788 2789template <class _Rp, class... _ArgTypes> 2790inline _LIBCPP_INLINE_VISIBILITY 2791bool 2792operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} 2793 2794template <class _Rp, class... _ArgTypes> 2795inline _LIBCPP_INLINE_VISIBILITY 2796bool 2797operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} 2798 2799template <class _Rp, class... _ArgTypes> 2800inline _LIBCPP_INLINE_VISIBILITY 2801void 2802swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT 2803{return __x.swap(__y);} 2804 2805#else // _LIBCPP_CXX03_LANG 2806 2807#include <__functional_03> 2808 2809#endif 2810 2811//////////////////////////////////////////////////////////////////////////////// 2812// BIND 2813//============================================================================== 2814 2815template<class _Tp> struct __is_bind_expression : public false_type {}; 2816template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression 2817 : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; 2818 2819#if _LIBCPP_STD_VER > 14 2820template <class _Tp> 2821_LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; 2822#endif 2823 2824template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; 2825template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder 2826 : public __is_placeholder<typename remove_cv<_Tp>::type> {}; 2827 2828#if _LIBCPP_STD_VER > 14 2829template <class _Tp> 2830_LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; 2831#endif 2832 2833namespace placeholders 2834{ 2835 2836template <int _Np> struct __ph {}; 2837 2838#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) 2839_LIBCPP_FUNC_VIS extern const __ph<1> _1; 2840_LIBCPP_FUNC_VIS extern const __ph<2> _2; 2841_LIBCPP_FUNC_VIS extern const __ph<3> _3; 2842_LIBCPP_FUNC_VIS extern const __ph<4> _4; 2843_LIBCPP_FUNC_VIS extern const __ph<5> _5; 2844_LIBCPP_FUNC_VIS extern const __ph<6> _6; 2845_LIBCPP_FUNC_VIS extern const __ph<7> _7; 2846_LIBCPP_FUNC_VIS extern const __ph<8> _8; 2847_LIBCPP_FUNC_VIS extern const __ph<9> _9; 2848_LIBCPP_FUNC_VIS extern const __ph<10> _10; 2849#else 2850/* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{}; 2851/* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{}; 2852/* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{}; 2853/* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{}; 2854/* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{}; 2855/* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{}; 2856/* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{}; 2857/* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{}; 2858/* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{}; 2859/* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{}; 2860#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) 2861 2862} // placeholders 2863 2864template<int _Np> 2865struct __is_placeholder<placeholders::__ph<_Np> > 2866 : public integral_constant<int, _Np> {}; 2867 2868 2869#ifndef _LIBCPP_CXX03_LANG 2870 2871template <class _Tp, class _Uj> 2872inline _LIBCPP_INLINE_VISIBILITY 2873_Tp& 2874__mu(reference_wrapper<_Tp> __t, _Uj&) 2875{ 2876 return __t.get(); 2877} 2878 2879template <class _Ti, class ..._Uj, size_t ..._Indx> 2880inline _LIBCPP_INLINE_VISIBILITY 2881typename __invoke_of<_Ti&, _Uj...>::type 2882__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) 2883{ 2884 return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); 2885} 2886 2887template <class _Ti, class ..._Uj> 2888inline _LIBCPP_INLINE_VISIBILITY 2889typename _EnableIf 2890< 2891 is_bind_expression<_Ti>::value, 2892 __invoke_of<_Ti&, _Uj...> 2893>::type 2894__mu(_Ti& __ti, tuple<_Uj...>& __uj) 2895{ 2896 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; 2897 return _VSTD::__mu_expand(__ti, __uj, __indices()); 2898} 2899 2900template <bool IsPh, class _Ti, class _Uj> 2901struct __mu_return2 {}; 2902 2903template <class _Ti, class _Uj> 2904struct __mu_return2<true, _Ti, _Uj> 2905{ 2906 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; 2907}; 2908 2909template <class _Ti, class _Uj> 2910inline _LIBCPP_INLINE_VISIBILITY 2911typename enable_if 2912< 2913 0 < is_placeholder<_Ti>::value, 2914 typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type 2915>::type 2916__mu(_Ti&, _Uj& __uj) 2917{ 2918 const size_t _Indx = is_placeholder<_Ti>::value - 1; 2919 return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj)); 2920} 2921 2922template <class _Ti, class _Uj> 2923inline _LIBCPP_INLINE_VISIBILITY 2924typename enable_if 2925< 2926 !is_bind_expression<_Ti>::value && 2927 is_placeholder<_Ti>::value == 0 && 2928 !__is_reference_wrapper<_Ti>::value, 2929 _Ti& 2930>::type 2931__mu(_Ti& __ti, _Uj&) 2932{ 2933 return __ti; 2934} 2935 2936template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, 2937 class _TupleUj> 2938struct __mu_return_impl; 2939 2940template <bool _Invokable, class _Ti, class ..._Uj> 2941struct __mu_return_invokable // false 2942{ 2943 typedef __nat type; 2944}; 2945 2946template <class _Ti, class ..._Uj> 2947struct __mu_return_invokable<true, _Ti, _Uj...> 2948{ 2949 typedef typename __invoke_of<_Ti&, _Uj...>::type type; 2950}; 2951 2952template <class _Ti, class ..._Uj> 2953struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> > 2954 : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> 2955{ 2956}; 2957 2958template <class _Ti, class _TupleUj> 2959struct __mu_return_impl<_Ti, false, false, true, _TupleUj> 2960{ 2961 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, 2962 _TupleUj>::type&& type; 2963}; 2964 2965template <class _Ti, class _TupleUj> 2966struct __mu_return_impl<_Ti, true, false, false, _TupleUj> 2967{ 2968 typedef typename _Ti::type& type; 2969}; 2970 2971template <class _Ti, class _TupleUj> 2972struct __mu_return_impl<_Ti, false, false, false, _TupleUj> 2973{ 2974 typedef _Ti& type; 2975}; 2976 2977template <class _Ti, class _TupleUj> 2978struct __mu_return 2979 : public __mu_return_impl<_Ti, 2980 __is_reference_wrapper<_Ti>::value, 2981 is_bind_expression<_Ti>::value, 2982 0 < is_placeholder<_Ti>::value && 2983 is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, 2984 _TupleUj> 2985{ 2986}; 2987 2988template <class _Fp, class _BoundArgs, class _TupleUj> 2989struct __is_valid_bind_return 2990{ 2991 static const bool value = false; 2992}; 2993 2994template <class _Fp, class ..._BoundArgs, class _TupleUj> 2995struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> 2996{ 2997 static const bool value = __invokable<_Fp, 2998 typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; 2999}; 3000 3001template <class _Fp, class ..._BoundArgs, class _TupleUj> 3002struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> 3003{ 3004 static const bool value = __invokable<_Fp, 3005 typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; 3006}; 3007 3008template <class _Fp, class _BoundArgs, class _TupleUj, 3009 bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> 3010struct __bind_return; 3011 3012template <class _Fp, class ..._BoundArgs, class _TupleUj> 3013struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> 3014{ 3015 typedef typename __invoke_of 3016 < 3017 _Fp&, 3018 typename __mu_return 3019 < 3020 _BoundArgs, 3021 _TupleUj 3022 >::type... 3023 >::type type; 3024}; 3025 3026template <class _Fp, class ..._BoundArgs, class _TupleUj> 3027struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> 3028{ 3029 typedef typename __invoke_of 3030 < 3031 _Fp&, 3032 typename __mu_return 3033 < 3034 const _BoundArgs, 3035 _TupleUj 3036 >::type... 3037 >::type type; 3038}; 3039 3040template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> 3041inline _LIBCPP_INLINE_VISIBILITY 3042typename __bind_return<_Fp, _BoundArgs, _Args>::type 3043__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, 3044 _Args&& __args) 3045{ 3046 return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...); 3047} 3048 3049template<class _Fp, class ..._BoundArgs> 3050class __bind 3051#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) 3052 : public __weak_result_type<typename decay<_Fp>::type> 3053#endif 3054{ 3055protected: 3056 typedef typename decay<_Fp>::type _Fd; 3057 typedef tuple<typename decay<_BoundArgs>::type...> _Td; 3058private: 3059 _Fd __f_; 3060 _Td __bound_args_; 3061 3062 typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; 3063public: 3064 template <class _Gp, class ..._BA, 3065 class = typename enable_if 3066 < 3067 is_constructible<_Fd, _Gp>::value && 3068 !is_same<typename remove_reference<_Gp>::type, 3069 __bind>::value 3070 >::type> 3071 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3072 explicit __bind(_Gp&& __f, _BA&& ...__bound_args) 3073 : __f_(_VSTD::forward<_Gp>(__f)), 3074 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} 3075 3076 template <class ..._Args> 3077 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3078 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 3079 operator()(_Args&& ...__args) 3080 { 3081 return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), 3082 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 3083 } 3084 3085 template <class ..._Args> 3086 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3087 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type 3088 operator()(_Args&& ...__args) const 3089 { 3090 return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), 3091 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 3092 } 3093}; 3094 3095template<class _Fp, class ..._BoundArgs> 3096struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; 3097 3098template<class _Rp, class _Fp, class ..._BoundArgs> 3099class __bind_r 3100 : public __bind<_Fp, _BoundArgs...> 3101{ 3102 typedef __bind<_Fp, _BoundArgs...> base; 3103 typedef typename base::_Fd _Fd; 3104 typedef typename base::_Td _Td; 3105public: 3106 typedef _Rp result_type; 3107 3108 3109 template <class _Gp, class ..._BA, 3110 class = typename enable_if 3111 < 3112 is_constructible<_Fd, _Gp>::value && 3113 !is_same<typename remove_reference<_Gp>::type, 3114 __bind_r>::value 3115 >::type> 3116 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3117 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) 3118 : base(_VSTD::forward<_Gp>(__f), 3119 _VSTD::forward<_BA>(__bound_args)...) {} 3120 3121 template <class ..._Args> 3122 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3123 typename enable_if 3124 < 3125 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, 3126 result_type>::value || is_void<_Rp>::value, 3127 result_type 3128 >::type 3129 operator()(_Args&& ...__args) 3130 { 3131 typedef __invoke_void_return_wrapper<_Rp> _Invoker; 3132 return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...); 3133 } 3134 3135 template <class ..._Args> 3136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3137 typename enable_if 3138 < 3139 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, 3140 result_type>::value || is_void<_Rp>::value, 3141 result_type 3142 >::type 3143 operator()(_Args&& ...__args) const 3144 { 3145 typedef __invoke_void_return_wrapper<_Rp> _Invoker; 3146 return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...); 3147 } 3148}; 3149 3150template<class _Rp, class _Fp, class ..._BoundArgs> 3151struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; 3152 3153template<class _Fp, class ..._BoundArgs> 3154inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3155__bind<_Fp, _BoundArgs...> 3156bind(_Fp&& __f, _BoundArgs&&... __bound_args) 3157{ 3158 typedef __bind<_Fp, _BoundArgs...> type; 3159 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 3160} 3161 3162template<class _Rp, class _Fp, class ..._BoundArgs> 3163inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3164__bind_r<_Rp, _Fp, _BoundArgs...> 3165bind(_Fp&& __f, _BoundArgs&&... __bound_args) 3166{ 3167 typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; 3168 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 3169} 3170 3171#endif // _LIBCPP_CXX03_LANG 3172 3173#if _LIBCPP_STD_VER > 14 3174 3175template<class _Op, class _Tuple, 3176 class _Idxs = typename __make_tuple_indices<tuple_size<_Tuple>::value>::type> 3177struct __perfect_forward_impl; 3178 3179template<class _Op, class... _Bound, size_t... _Idxs> 3180struct __perfect_forward_impl<_Op, __tuple_types<_Bound...>, __tuple_indices<_Idxs...>> 3181{ 3182 tuple<_Bound...> __bound_; 3183 3184 template<class... _Args> 3185 _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) & 3186 noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) 3187 -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) 3188 {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} 3189 3190 template<class... _Args> 3191 _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const& 3192 noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) 3193 -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) 3194 {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} 3195 3196 template<class... _Args> 3197 _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) && 3198 noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., 3199 _VSTD::forward<_Args>(__args)...))) 3200 -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., 3201 _VSTD::forward<_Args>(__args)...)) 3202 {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., 3203 _VSTD::forward<_Args>(__args)...);} 3204 3205 template<class... _Args> 3206 _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const&& 3207 noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., 3208 _VSTD::forward<_Args>(__args)...))) 3209 -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., 3210 _VSTD::forward<_Args>(__args)...)) 3211 {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., 3212 _VSTD::forward<_Args>(__args)...);} 3213 3214 template<class _Fn = typename tuple_element<0, tuple<_Bound...>>::type, 3215 class = _EnableIf<is_copy_constructible_v<_Fn>>> 3216 constexpr __perfect_forward_impl(__perfect_forward_impl const& __other) 3217 : __bound_(__other.__bound_) {} 3218 3219 template<class _Fn = typename tuple_element<0, tuple<_Bound...>>::type, 3220 class = _EnableIf<is_move_constructible_v<_Fn>>> 3221 constexpr __perfect_forward_impl(__perfect_forward_impl && __other) 3222 : __bound_(_VSTD::move(__other.__bound_)) {} 3223 3224 template<class... _BoundArgs> 3225 explicit constexpr __perfect_forward_impl(_BoundArgs&&... __bound) : 3226 __bound_(_VSTD::forward<_BoundArgs>(__bound)...) { } 3227}; 3228 3229template<class _Op, class... _Args> 3230using __perfect_forward = 3231 __perfect_forward_impl<_Op, __tuple_types<decay_t<_Args>...>>; 3232 3233struct __not_fn_op 3234{ 3235 template<class... _Args> 3236 static _LIBCPP_CONSTEXPR_AFTER_CXX17 auto __call(_Args&&... __args) 3237 noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) 3238 -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...)) 3239 { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); } 3240}; 3241 3242template<class _Fn, 3243 class = _EnableIf<is_constructible_v<decay_t<_Fn>, _Fn> && 3244 is_move_constructible_v<_Fn>>> 3245_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) 3246{ 3247 return __perfect_forward<__not_fn_op, _Fn>(_VSTD::forward<_Fn>(__f)); 3248} 3249 3250#endif // _LIBCPP_STD_VER > 14 3251 3252#if _LIBCPP_STD_VER > 17 3253 3254struct __bind_front_op 3255{ 3256 template<class... _Args> 3257 constexpr static auto __call(_Args&&... __args) 3258 noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) 3259 -> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...)) 3260 { return _VSTD::invoke(_VSTD::forward<_Args>(__args)...); } 3261}; 3262 3263template<class _Fn, class... _Args, 3264 class = _EnableIf<conjunction<is_constructible<decay_t<_Fn>, _Fn>, 3265 is_move_constructible<decay_t<_Fn>>, 3266 is_constructible<decay_t<_Args>, _Args>..., 3267 is_move_constructible<decay_t<_Args>>... 3268 >::value>> 3269constexpr auto bind_front(_Fn&& __f, _Args&&... __args) 3270{ 3271 return __perfect_forward<__bind_front_op, _Fn, _Args...>(_VSTD::forward<_Fn>(__f), 3272 _VSTD::forward<_Args>(__args)...); 3273} 3274 3275#endif // _LIBCPP_STD_VER > 17 3276 3277// struct hash<T*> in <memory> 3278 3279#if _LIBCPP_STD_VER > 14 3280 3281// default searcher 3282template<class _ForwardIterator, class _BinaryPredicate = equal_to<>> 3283class _LIBCPP_TEMPLATE_VIS default_searcher { 3284public: 3285 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3286 default_searcher(_ForwardIterator __f, _ForwardIterator __l, 3287 _BinaryPredicate __p = _BinaryPredicate()) 3288 : __first_(__f), __last_(__l), __pred_(__p) {} 3289 3290 template <typename _ForwardIterator2> 3291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 3292 pair<_ForwardIterator2, _ForwardIterator2> 3293 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const 3294 { 3295 return _VSTD::__search(__f, __l, __first_, __last_, __pred_, 3296 typename iterator_traits<_ForwardIterator>::iterator_category(), 3297 typename iterator_traits<_ForwardIterator2>::iterator_category()); 3298 } 3299 3300private: 3301 _ForwardIterator __first_; 3302 _ForwardIterator __last_; 3303 _BinaryPredicate __pred_; 3304 }; 3305 3306#endif // _LIBCPP_STD_VER > 14 3307 3308#if _LIBCPP_STD_VER > 17 3309template <class _Tp> 3310using unwrap_reference_t = typename unwrap_reference<_Tp>::type; 3311 3312template <class _Tp> 3313using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; 3314#endif // > C++17 3315 3316#if _LIBCPP_STD_VER > 17 3317// [func.identity] 3318struct identity { 3319 template<class _Tp> 3320 _LIBCPP_NODISCARD_EXT constexpr _Tp&& operator()(_Tp&& __t) const noexcept 3321 { 3322 return _VSTD::forward<_Tp>(__t); 3323 } 3324 3325 using is_transparent = void; 3326}; 3327#endif // _LIBCPP_STD_VER > 17 3328 3329#if !defined(_LIBCPP_HAS_NO_RANGES) 3330 3331namespace ranges { 3332 3333struct equal_to { 3334 template <class _Tp, class _Up> 3335 requires equality_comparable_with<_Tp, _Up> 3336 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 3337 noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) { 3338 return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u); 3339 } 3340 3341 using is_transparent = void; 3342}; 3343 3344struct not_equal_to { 3345 template <class _Tp, class _Up> 3346 requires equality_comparable_with<_Tp, _Up> 3347 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 3348 noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) { 3349 return !(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)); 3350 } 3351 3352 using is_transparent = void; 3353}; 3354 3355struct greater { 3356 template <class _Tp, class _Up> 3357 requires totally_ordered_with<_Tp, _Up> 3358 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 3359 noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) { 3360 return _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t); 3361 } 3362 3363 using is_transparent = void; 3364}; 3365 3366struct less { 3367 template <class _Tp, class _Up> 3368 requires totally_ordered_with<_Tp, _Up> 3369 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 3370 noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) { 3371 return _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u); 3372 } 3373 3374 using is_transparent = void; 3375}; 3376 3377struct greater_equal { 3378 template <class _Tp, class _Up> 3379 requires totally_ordered_with<_Tp, _Up> 3380 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 3381 noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) { 3382 return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)); 3383 } 3384 3385 using is_transparent = void; 3386}; 3387 3388struct less_equal { 3389 template <class _Tp, class _Up> 3390 requires totally_ordered_with<_Tp, _Up> 3391 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 3392 noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) { 3393 return !(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)); 3394 } 3395 3396 using is_transparent = void; 3397}; 3398 3399} // namespace ranges 3400 3401#endif // !defined(_LIBCPP_HAS_NO_RANGES) 3402 3403_LIBCPP_END_NAMESPACE_STD 3404 3405#endif // _LIBCPP_FUNCTIONAL 3406