13e519524SHoward Hinnant// -*- C++ -*- 23e519524SHoward Hinnant//===------------------------ functional ----------------------------------===// 33e519524SHoward Hinnant// 45b08a8a4SHoward Hinnant// The LLVM Compiler Infrastructure 53e519524SHoward Hinnant// 6412dbebeSHoward Hinnant// This file is dual licensed under the MIT and the University of Illinois Open 7412dbebeSHoward Hinnant// Source Licenses. See LICENSE.TXT for details. 83e519524SHoward Hinnant// 93e519524SHoward Hinnant//===----------------------------------------------------------------------===// 103e519524SHoward Hinnant 113e519524SHoward Hinnant#ifndef _LIBCPP_FUNCTIONAL 123e519524SHoward Hinnant#define _LIBCPP_FUNCTIONAL 133e519524SHoward Hinnant 143e519524SHoward Hinnant/* 153e519524SHoward Hinnant functional synopsis 163e519524SHoward Hinnant 173e519524SHoward Hinnantnamespace std 183e519524SHoward Hinnant{ 193e519524SHoward Hinnant 203e519524SHoward Hinnanttemplate <class Arg, class Result> 213e519524SHoward Hinnantstruct unary_function 223e519524SHoward Hinnant{ 233e519524SHoward Hinnant typedef Arg argument_type; 243e519524SHoward Hinnant typedef Result result_type; 253e519524SHoward Hinnant}; 263e519524SHoward Hinnant 273e519524SHoward Hinnanttemplate <class Arg1, class Arg2, class Result> 283e519524SHoward Hinnantstruct binary_function 293e519524SHoward Hinnant{ 303e519524SHoward Hinnant typedef Arg1 first_argument_type; 313e519524SHoward Hinnant typedef Arg2 second_argument_type; 323e519524SHoward Hinnant typedef Result result_type; 333e519524SHoward Hinnant}; 343e519524SHoward Hinnant 359b0b6d45SHoward Hinnanttemplate <class T> 363e519524SHoward Hinnantclass reference_wrapper 373e519524SHoward Hinnant : public unary_function<T1, R> // if wrapping a unary functor 383e519524SHoward Hinnant : public binary_function<T1, T2, R> // if wraping a binary functor 393e519524SHoward Hinnant{ 403e519524SHoward Hinnantpublic: 413e519524SHoward Hinnant // types 423e519524SHoward Hinnant typedef T type; 433e519524SHoward Hinnant typedef see below result_type; // Not always defined 443e519524SHoward Hinnant 453e519524SHoward Hinnant // construct/copy/destroy 466a07d6f0SHoward Hinnant reference_wrapper(T&) noexcept; 473e519524SHoward Hinnant reference_wrapper(T&&) = delete; // do not bind to temps 486a07d6f0SHoward Hinnant reference_wrapper(const reference_wrapper<T>& x) noexcept; 493e519524SHoward Hinnant 503e519524SHoward Hinnant // assignment 516a07d6f0SHoward Hinnant reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept; 523e519524SHoward Hinnant 533e519524SHoward Hinnant // access 546a07d6f0SHoward Hinnant operator T& () const noexcept; 556a07d6f0SHoward Hinnant T& get() const noexcept; 563e519524SHoward Hinnant 573e519524SHoward Hinnant // invoke 583e519524SHoward Hinnant template <class... ArgTypes> 59b76e6a95SHoward Hinnant typename result_of<T&(ArgTypes&&...)>::type 603e519524SHoward Hinnant operator() (ArgTypes&&...) const; 613e519524SHoward Hinnant}; 623e519524SHoward Hinnant 636a07d6f0SHoward Hinnanttemplate <class T> reference_wrapper<T> ref(T& t) noexcept; 649b0b6d45SHoward Hinnanttemplate <class T> void ref(const T&& t) = delete; 656a07d6f0SHoward Hinnanttemplate <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept; 663e519524SHoward Hinnant 676a07d6f0SHoward Hinnanttemplate <class T> reference_wrapper<const T> cref(const T& t) noexcept; 689b0b6d45SHoward Hinnanttemplate <class T> void cref(const T&& t) = delete; 696a07d6f0SHoward Hinnanttemplate <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept; 703e519524SHoward Hinnant 7183c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 723e519524SHoward Hinnantstruct plus : binary_function<T, T, T> 733e519524SHoward Hinnant{ 743e519524SHoward Hinnant T operator()(const T& x, const T& y) const; 753e519524SHoward Hinnant}; 763e519524SHoward Hinnant 7783c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 783e519524SHoward Hinnantstruct minus : binary_function<T, T, T> 793e519524SHoward Hinnant{ 803e519524SHoward Hinnant T operator()(const T& x, const T& y) const; 813e519524SHoward Hinnant}; 823e519524SHoward Hinnant 8383c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 843e519524SHoward Hinnantstruct multiplies : binary_function<T, T, T> 853e519524SHoward Hinnant{ 863e519524SHoward Hinnant T operator()(const T& x, const T& y) const; 873e519524SHoward Hinnant}; 883e519524SHoward Hinnant 8983c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 903e519524SHoward Hinnantstruct divides : binary_function<T, T, T> 913e519524SHoward Hinnant{ 923e519524SHoward Hinnant T operator()(const T& x, const T& y) const; 933e519524SHoward Hinnant}; 943e519524SHoward Hinnant 9583c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 963e519524SHoward Hinnantstruct modulus : binary_function<T, T, T> 973e519524SHoward Hinnant{ 983e519524SHoward Hinnant T operator()(const T& x, const T& y) const; 993e519524SHoward Hinnant}; 1003e519524SHoward Hinnant 10183c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1023e519524SHoward Hinnantstruct negate : unary_function<T, T> 1033e519524SHoward Hinnant{ 1043e519524SHoward Hinnant T operator()(const T& x) const; 1053e519524SHoward Hinnant}; 1063e519524SHoward Hinnant 10783c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1083e519524SHoward Hinnantstruct equal_to : binary_function<T, T, bool> 1093e519524SHoward Hinnant{ 1103e519524SHoward Hinnant bool operator()(const T& x, const T& y) const; 1113e519524SHoward Hinnant}; 1123e519524SHoward Hinnant 11383c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1143e519524SHoward Hinnantstruct not_equal_to : binary_function<T, T, bool> 1153e519524SHoward Hinnant{ 1163e519524SHoward Hinnant bool operator()(const T& x, const T& y) const; 1173e519524SHoward Hinnant}; 1183e519524SHoward Hinnant 11983c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1203e519524SHoward Hinnantstruct greater : binary_function<T, T, bool> 1213e519524SHoward Hinnant{ 1223e519524SHoward Hinnant bool operator()(const T& x, const T& y) const; 1233e519524SHoward Hinnant}; 1243e519524SHoward Hinnant 12583c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1263e519524SHoward Hinnantstruct less : binary_function<T, T, bool> 1273e519524SHoward Hinnant{ 1283e519524SHoward Hinnant bool operator()(const T& x, const T& y) const; 1293e519524SHoward Hinnant}; 1303e519524SHoward Hinnant 13183c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1323e519524SHoward Hinnantstruct greater_equal : binary_function<T, T, bool> 1333e519524SHoward Hinnant{ 1343e519524SHoward Hinnant bool operator()(const T& x, const T& y) const; 1353e519524SHoward Hinnant}; 1363e519524SHoward Hinnant 13783c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1383e519524SHoward Hinnantstruct less_equal : binary_function<T, T, bool> 1393e519524SHoward Hinnant{ 1403e519524SHoward Hinnant bool operator()(const T& x, const T& y) const; 1413e519524SHoward Hinnant}; 1423e519524SHoward Hinnant 14383c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1443e519524SHoward Hinnantstruct logical_and : binary_function<T, T, bool> 1453e519524SHoward Hinnant{ 1463e519524SHoward Hinnant bool operator()(const T& x, const T& y) const; 1473e519524SHoward Hinnant}; 1483e519524SHoward Hinnant 14983c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1503e519524SHoward Hinnantstruct logical_or : binary_function<T, T, bool> 1513e519524SHoward Hinnant{ 1523e519524SHoward Hinnant bool operator()(const T& x, const T& y) const; 1533e519524SHoward Hinnant}; 1543e519524SHoward Hinnant 15583c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 1563e519524SHoward Hinnantstruct logical_not : unary_function<T, bool> 1573e519524SHoward Hinnant{ 1583e519524SHoward Hinnant bool operator()(const T& x) const; 1593e519524SHoward Hinnant}; 1603e519524SHoward Hinnant 16183c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 16283c08b44SMarshall Clowstruct bit_and : unary_function<T, bool> 16383c08b44SMarshall Clow{ 16483c08b44SMarshall Clow bool operator()(const T& x, const T& y) const; 16583c08b44SMarshall Clow}; 16683c08b44SMarshall Clow 16783c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 16883c08b44SMarshall Clowstruct bit_or : unary_function<T, bool> 16983c08b44SMarshall Clow{ 17083c08b44SMarshall Clow bool operator()(const T& x, const T& y) const; 17183c08b44SMarshall Clow}; 17283c08b44SMarshall Clow 17383c08b44SMarshall Clowtemplate <class T> // <class T=void> in C++14 17483c08b44SMarshall Clowstruct bit_xor : unary_function<T, bool> 17583c08b44SMarshall Clow{ 17683c08b44SMarshall Clow bool operator()(const T& x, const T& y) const; 17783c08b44SMarshall Clow}; 17883c08b44SMarshall Clow 17983c08b44SMarshall Clowtemplate <class T=void> // C++14 18083c08b44SMarshall Clowstruct bit_xor : unary_function<T, bool> 18183c08b44SMarshall Clow{ 18283c08b44SMarshall Clow bool operator()(const T& x) const; 18383c08b44SMarshall Clow}; 18483c08b44SMarshall Clow 1853e519524SHoward Hinnanttemplate <class Predicate> 186*ea5cd3b4SLouis Dionneclass unary_negate // deprecated in C++17 1873e519524SHoward Hinnant : public unary_function<typename Predicate::argument_type, bool> 1883e519524SHoward Hinnant{ 1893e519524SHoward Hinnantpublic: 1903e519524SHoward Hinnant explicit unary_negate(const Predicate& pred); 1913e519524SHoward Hinnant bool operator()(const typename Predicate::argument_type& x) const; 1923e519524SHoward Hinnant}; 1933e519524SHoward Hinnant 194*ea5cd3b4SLouis Dionnetemplate <class Predicate> // deprecated in C++17 195*ea5cd3b4SLouis Dionneunary_negate<Predicate> not1(const Predicate& pred); 1963e519524SHoward Hinnant 1973e519524SHoward Hinnanttemplate <class Predicate> 198*ea5cd3b4SLouis Dionneclass binary_negate // deprecated in C++17 1993e519524SHoward Hinnant : public binary_function<typename Predicate::first_argument_type, 2003e519524SHoward Hinnant typename Predicate::second_argument_type, 2013e519524SHoward Hinnant bool> 2023e519524SHoward Hinnant{ 2033e519524SHoward Hinnantpublic: 2043e519524SHoward Hinnant explicit binary_negate(const Predicate& pred); 2053e519524SHoward Hinnant bool operator()(const typename Predicate::first_argument_type& x, 2063e519524SHoward Hinnant const typename Predicate::second_argument_type& y) const; 2073e519524SHoward Hinnant}; 2083e519524SHoward Hinnant 209*ea5cd3b4SLouis Dionnetemplate <class Predicate> // deprecated in C++17 210*ea5cd3b4SLouis Dionnebinary_negate<Predicate> not2(const Predicate& pred); 2113e519524SHoward Hinnant 21257257567SEric Fiseliertemplate <class F> unspecified not_fn(F&& f); // C++17 21357257567SEric Fiselier 2143e519524SHoward Hinnanttemplate<class T> struct is_bind_expression; 2153e519524SHoward Hinnanttemplate<class T> struct is_placeholder; 2163e519524SHoward Hinnant 217a48055ceSMarshall Clow // See C++14 20.9.9, Function object binders 21840a01d53SMarshall Clowtemplate <class T> inline constexpr bool is_bind_expression_v 219a48055ceSMarshall Clow = is_bind_expression<T>::value; // C++17 22040a01d53SMarshall Clowtemplate <class T> inline constexpr int is_placeholder_v 221a48055ceSMarshall Clow = is_placeholder<T>::value; // C++17 222a48055ceSMarshall Clow 223a48055ceSMarshall Clow 2249b0b6d45SHoward Hinnanttemplate<class Fn, class... BoundArgs> 2259b0b6d45SHoward Hinnant unspecified bind(Fn&&, BoundArgs&&...); 2269b0b6d45SHoward Hinnanttemplate<class R, class Fn, class... BoundArgs> 2279b0b6d45SHoward Hinnant unspecified bind(Fn&&, BoundArgs&&...); 2283e519524SHoward Hinnant 2293e519524SHoward Hinnantnamespace placeholders { 2303e519524SHoward Hinnant // M is the implementation-defined number of placeholders 2313e519524SHoward Hinnant extern unspecified _1; 2323e519524SHoward Hinnant extern unspecified _2; 2333e519524SHoward Hinnant . 2343e519524SHoward Hinnant . 2353e519524SHoward Hinnant . 236c003db1fSHoward Hinnant extern unspecified _Mp; 2373e519524SHoward Hinnant} 2383e519524SHoward Hinnant 2393e519524SHoward Hinnanttemplate <class Operation> 2407d210c78SMarshall Clowclass binder1st // deprecated in C++11, removed in C++17 2413e519524SHoward Hinnant : public unary_function<typename Operation::second_argument_type, 2423e519524SHoward Hinnant typename Operation::result_type> 2433e519524SHoward Hinnant{ 2443e519524SHoward Hinnantprotected: 2453e519524SHoward Hinnant Operation op; 2463e519524SHoward Hinnant typename Operation::first_argument_type value; 2473e519524SHoward Hinnantpublic: 2483e519524SHoward Hinnant binder1st(const Operation& x, const typename Operation::first_argument_type y); 2493e519524SHoward Hinnant typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; 2503e519524SHoward Hinnant typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; 2513e519524SHoward Hinnant}; 2523e519524SHoward Hinnant 2533e519524SHoward Hinnanttemplate <class Operation, class T> 2547d210c78SMarshall Clowbinder1st<Operation> bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 2553e519524SHoward Hinnant 2563e519524SHoward Hinnanttemplate <class Operation> 2577d210c78SMarshall Clowclass binder2nd // deprecated in C++11, removed in C++17 2583e519524SHoward Hinnant : public unary_function<typename Operation::first_argument_type, 2593e519524SHoward Hinnant typename Operation::result_type> 2603e519524SHoward Hinnant{ 2613e519524SHoward Hinnantprotected: 2623e519524SHoward Hinnant Operation op; 2633e519524SHoward Hinnant typename Operation::second_argument_type value; 2643e519524SHoward Hinnantpublic: 2653e519524SHoward Hinnant binder2nd(const Operation& x, const typename Operation::second_argument_type y); 2663e519524SHoward Hinnant typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; 2673e519524SHoward Hinnant typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; 2683e519524SHoward Hinnant}; 2693e519524SHoward Hinnant 2703e519524SHoward Hinnanttemplate <class Operation, class T> 2717d210c78SMarshall Clowbinder2nd<Operation> bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 2723e519524SHoward Hinnant 2737d210c78SMarshall Clowtemplate <class Arg, class Result> // deprecated in C++11, removed in C++17 2743e519524SHoward Hinnantclass pointer_to_unary_function : public unary_function<Arg, Result> 2753e519524SHoward Hinnant{ 2763e519524SHoward Hinnantpublic: 2773e519524SHoward Hinnant explicit pointer_to_unary_function(Result (*f)(Arg)); 2783e519524SHoward Hinnant Result operator()(Arg x) const; 2793e519524SHoward Hinnant}; 2803e519524SHoward Hinnant 2813e519524SHoward Hinnanttemplate <class Arg, class Result> 2827d210c78SMarshall Clowpointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17 2833e519524SHoward Hinnant 2847d210c78SMarshall Clowtemplate <class Arg1, class Arg2, class Result> // deprecated in C++11, removed in C++17 2853e519524SHoward Hinnantclass pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> 2863e519524SHoward Hinnant{ 2873e519524SHoward Hinnantpublic: 2883e519524SHoward Hinnant explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); 2893e519524SHoward Hinnant Result operator()(Arg1 x, Arg2 y) const; 2903e519524SHoward Hinnant}; 2913e519524SHoward Hinnant 2923e519524SHoward Hinnanttemplate <class Arg1, class Arg2, class Result> 2937d210c78SMarshall Clowpointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17 2943e519524SHoward Hinnant 2957d210c78SMarshall Clowtemplate<class S, class T> // deprecated in C++11, removed in C++17 2963e519524SHoward Hinnantclass mem_fun_t : public unary_function<T*, S> 2973e519524SHoward Hinnant{ 2983e519524SHoward Hinnantpublic: 2993e519524SHoward Hinnant explicit mem_fun_t(S (T::*p)()); 3003e519524SHoward Hinnant S operator()(T* p) const; 3013e519524SHoward Hinnant}; 3023e519524SHoward Hinnant 3033e519524SHoward Hinnanttemplate<class S, class T, class A> 3047d210c78SMarshall Clowclass mem_fun1_t : public binary_function<T*, A, S> // deprecated in C++11, removed in C++17 3053e519524SHoward Hinnant{ 3063e519524SHoward Hinnantpublic: 3073e519524SHoward Hinnant explicit mem_fun1_t(S (T::*p)(A)); 3083e519524SHoward Hinnant S operator()(T* p, A x) const; 3093e519524SHoward Hinnant}; 3103e519524SHoward Hinnant 3117d210c78SMarshall Clowtemplate<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17 3127d210c78SMarshall Clowtemplate<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 3133e519524SHoward Hinnant 3143e519524SHoward Hinnanttemplate<class S, class T> 3157d210c78SMarshall Clowclass mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17 3163e519524SHoward Hinnant{ 3173e519524SHoward Hinnantpublic: 3183e519524SHoward Hinnant explicit mem_fun_ref_t(S (T::*p)()); 3193e519524SHoward Hinnant S operator()(T& p) const; 3203e519524SHoward Hinnant}; 3213e519524SHoward Hinnant 3223e519524SHoward Hinnanttemplate<class S, class T, class A> 3237d210c78SMarshall Clowclass mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17 3243e519524SHoward Hinnant{ 3253e519524SHoward Hinnantpublic: 3263e519524SHoward Hinnant explicit mem_fun1_ref_t(S (T::*p)(A)); 3273e519524SHoward Hinnant S operator()(T& p, A x) const; 3283e519524SHoward Hinnant}; 3293e519524SHoward Hinnant 3307d210c78SMarshall Clowtemplate<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17 3317d210c78SMarshall Clowtemplate<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 3323e519524SHoward Hinnant 3333e519524SHoward Hinnanttemplate <class S, class T> 3347d210c78SMarshall Clowclass const_mem_fun_t : public unary_function<const T*, S> // deprecated in C++11, removed in C++17 3353e519524SHoward Hinnant{ 3363e519524SHoward Hinnantpublic: 3373e519524SHoward Hinnant explicit const_mem_fun_t(S (T::*p)() const); 3383e519524SHoward Hinnant S operator()(const T* p) const; 3393e519524SHoward Hinnant}; 3403e519524SHoward Hinnant 3413e519524SHoward Hinnanttemplate <class S, class T, class A> 3427d210c78SMarshall Clowclass const_mem_fun1_t : public binary_function<const T*, A, S> // deprecated in C++11, removed in C++17 3433e519524SHoward Hinnant{ 3443e519524SHoward Hinnantpublic: 3453e519524SHoward Hinnant explicit const_mem_fun1_t(S (T::*p)(A) const); 3463e519524SHoward Hinnant S operator()(const T* p, A x) const; 3473e519524SHoward Hinnant}; 3483e519524SHoward Hinnant 3497d210c78SMarshall Clowtemplate <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17 3507d210c78SMarshall Clowtemplate <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 3513e519524SHoward Hinnant 3523e519524SHoward Hinnanttemplate <class S, class T> 3537d210c78SMarshall Clowclass const_mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17 3543e519524SHoward Hinnant{ 3553e519524SHoward Hinnantpublic: 3563e519524SHoward Hinnant explicit const_mem_fun_ref_t(S (T::*p)() const); 3573e519524SHoward Hinnant S operator()(const T& p) const; 3583e519524SHoward Hinnant}; 3593e519524SHoward Hinnant 3603e519524SHoward Hinnanttemplate <class S, class T, class A> 3617d210c78SMarshall Clowclass const_mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17 3623e519524SHoward Hinnant{ 3633e519524SHoward Hinnantpublic: 3643e519524SHoward Hinnant explicit const_mem_fun1_ref_t(S (T::*p)(A) const); 3653e519524SHoward Hinnant S operator()(const T& p, A x) const; 3663e519524SHoward Hinnant}; 3673e519524SHoward Hinnant 3687d210c78SMarshall Clowtemplate <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 3697d210c78SMarshall Clowtemplate <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 3703e519524SHoward Hinnant 3719b0b6d45SHoward Hinnanttemplate<class R, class T> unspecified mem_fn(R T::*); 3729b0b6d45SHoward Hinnant 3733e519524SHoward Hinnantclass bad_function_call 3743e519524SHoward Hinnant : public exception 3753e519524SHoward Hinnant{ 3763e519524SHoward Hinnant}; 3773e519524SHoward Hinnant 3789b0b6d45SHoward Hinnanttemplate<class> class function; // undefined 3793e519524SHoward Hinnant 3809b0b6d45SHoward Hinnanttemplate<class R, class... ArgTypes> 3813e519524SHoward Hinnantclass function<R(ArgTypes...)> 3823e519524SHoward Hinnant : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and 3833e519524SHoward Hinnant // ArgTypes contains T1 3843e519524SHoward Hinnant : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and 3853e519524SHoward Hinnant // ArgTypes contains T1 and T2 3863e519524SHoward Hinnant{ 3873e519524SHoward Hinnantpublic: 3883e519524SHoward Hinnant typedef R result_type; 3893e519524SHoward Hinnant 3909b0b6d45SHoward Hinnant // construct/copy/destroy: 3916a07d6f0SHoward Hinnant function() noexcept; 3926a07d6f0SHoward Hinnant function(nullptr_t) noexcept; 3933e519524SHoward Hinnant function(const function&); 3946a07d6f0SHoward Hinnant function(function&&) noexcept; 3953e519524SHoward Hinnant template<class F> 3963e519524SHoward Hinnant function(F); 3973e519524SHoward Hinnant template<Allocator Alloc> 3986ecac730SMarshall Clow function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17 3993e519524SHoward Hinnant template<Allocator Alloc> 4006ecac730SMarshall Clow function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17 4013e519524SHoward Hinnant template<Allocator Alloc> 4026ecac730SMarshall Clow function(allocator_arg_t, const Alloc&, const function&); // removed in C++17 4033e519524SHoward Hinnant template<Allocator Alloc> 4046ecac730SMarshall Clow function(allocator_arg_t, const Alloc&, function&&); // removed in C++17 4053e519524SHoward Hinnant template<class F, Allocator Alloc> 4066ecac730SMarshall Clow function(allocator_arg_t, const Alloc&, F); // removed in C++17 4073e519524SHoward Hinnant 4083e519524SHoward Hinnant function& operator=(const function&); 4096a07d6f0SHoward Hinnant function& operator=(function&&) noexcept; 410af152c84SHoward Hinnant function& operator=(nullptr_t) noexcept; 4113e519524SHoward Hinnant template<class F> 4129b0b6d45SHoward Hinnant function& operator=(F&&); 4133e519524SHoward Hinnant template<class F> 4146a07d6f0SHoward Hinnant function& operator=(reference_wrapper<F>) noexcept; 4153e519524SHoward Hinnant 4163e519524SHoward Hinnant ~function(); 4173e519524SHoward Hinnant 4189b0b6d45SHoward Hinnant // function modifiers: 4196a07d6f0SHoward Hinnant void swap(function&) noexcept; 4209b0b6d45SHoward Hinnant template<class F, class Alloc> 4210aa1ccb0SMarshall Clow void assign(F&&, const Alloc&); // Removed in C++17 4223e519524SHoward Hinnant 4239b0b6d45SHoward Hinnant // function capacity: 4246a07d6f0SHoward Hinnant explicit operator bool() const noexcept; 4253e519524SHoward Hinnant 4269b0b6d45SHoward Hinnant // function invocation: 4273e519524SHoward Hinnant R operator()(ArgTypes...) const; 4283e519524SHoward Hinnant 4299b0b6d45SHoward Hinnant // function target access: 4306a07d6f0SHoward Hinnant const std::type_info& target_type() const noexcept; 4316a07d6f0SHoward Hinnant template <typename T> T* target() noexcept; 4326a07d6f0SHoward Hinnant template <typename T> const T* target() const noexcept; 4333e519524SHoward Hinnant}; 4343e519524SHoward Hinnant 4359b0b6d45SHoward Hinnant// Null pointer comparisons: 4369b0b6d45SHoward Hinnanttemplate <class R, class ... ArgTypes> 4376a07d6f0SHoward Hinnant bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 4383e519524SHoward Hinnant 4399b0b6d45SHoward Hinnanttemplate <class R, class ... ArgTypes> 4406a07d6f0SHoward Hinnant bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 4413e519524SHoward Hinnant 4429b0b6d45SHoward Hinnanttemplate <class R, class ... ArgTypes> 4436a07d6f0SHoward Hinnant bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 4443e519524SHoward Hinnant 4459b0b6d45SHoward Hinnanttemplate <class R, class ... ArgTypes> 4466a07d6f0SHoward Hinnant bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 4473e519524SHoward Hinnant 4489b0b6d45SHoward Hinnant// specialized algorithms: 4499b0b6d45SHoward Hinnanttemplate <class R, class ... ArgTypes> 4506a07d6f0SHoward Hinnant void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept; 4513e519524SHoward Hinnant 4523e519524SHoward Hinnanttemplate <class T> struct hash; 4533e519524SHoward Hinnant 4543e519524SHoward Hinnanttemplate <> struct hash<bool>; 4553e519524SHoward Hinnanttemplate <> struct hash<char>; 4563e519524SHoward Hinnanttemplate <> struct hash<signed char>; 4573e519524SHoward Hinnanttemplate <> struct hash<unsigned char>; 4583e519524SHoward Hinnanttemplate <> struct hash<char16_t>; 4593e519524SHoward Hinnanttemplate <> struct hash<char32_t>; 4603e519524SHoward Hinnanttemplate <> struct hash<wchar_t>; 4613e519524SHoward Hinnanttemplate <> struct hash<short>; 4623e519524SHoward Hinnanttemplate <> struct hash<unsigned short>; 4633e519524SHoward Hinnanttemplate <> struct hash<int>; 4643e519524SHoward Hinnanttemplate <> struct hash<unsigned int>; 4653e519524SHoward Hinnanttemplate <> struct hash<long>; 4663e519524SHoward Hinnanttemplate <> struct hash<long long>; 4673e519524SHoward Hinnanttemplate <> struct hash<unsigned long>; 4683e519524SHoward Hinnanttemplate <> struct hash<unsigned long long>; 4693e519524SHoward Hinnant 4703e519524SHoward Hinnanttemplate <> struct hash<float>; 4713e519524SHoward Hinnanttemplate <> struct hash<double>; 4723e519524SHoward Hinnanttemplate <> struct hash<long double>; 4733e519524SHoward Hinnant 4743e519524SHoward Hinnanttemplate<class T> struct hash<T*>; 475d8323168SMarshall Clowtemplate <> struct hash<nullptr_t>; // C++17 4763e519524SHoward Hinnant 4773e519524SHoward Hinnant} // std 4783e519524SHoward Hinnant 4793e519524SHoward HinnantPOLICY: For non-variadic implementations, the number of arguments is limited 4803e519524SHoward Hinnant to 3. It is hoped that the need for non-variadic implementations 4813e519524SHoward Hinnant will be minimal. 4823e519524SHoward Hinnant 4833e519524SHoward Hinnant*/ 4843e519524SHoward Hinnant 4853e519524SHoward Hinnant#include <__config> 4863e519524SHoward Hinnant#include <type_traits> 4873e519524SHoward Hinnant#include <typeinfo> 4883e519524SHoward Hinnant#include <exception> 4893e519524SHoward Hinnant#include <memory> 4903e519524SHoward Hinnant#include <tuple> 491f9127593SEric Fiselier#include <utility> 492f56972e2SMarshall Clow#include <version> 4933e519524SHoward Hinnant 4943e519524SHoward Hinnant#include <__functional_base> 4953e519524SHoward Hinnant 496073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 4973e519524SHoward Hinnant#pragma GCC system_header 498073458b1SHoward Hinnant#endif 4993e519524SHoward Hinnant 5003e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 5013e519524SHoward Hinnant 50283c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 50383c08b44SMarshall Clowtemplate <class _Tp = void> 50483c08b44SMarshall Clow#else 5053e519524SHoward Hinnanttemplate <class _Tp> 50683c08b44SMarshall Clow#endif 507e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp> 5083e519524SHoward Hinnant{ 5093d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5103d5134ddSMarshall Clow _Tp operator()(const _Tp& __x, const _Tp& __y) const 5113e519524SHoward Hinnant {return __x + __y;} 5123e519524SHoward Hinnant}; 5133e519524SHoward Hinnant 51483c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 51583c08b44SMarshall Clowtemplate <> 516e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS plus<void> 51783c08b44SMarshall Clow{ 51883c08b44SMarshall Clow template <class _T1, class _T2> 5193d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5203d5134ddSMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 521a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) 522a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) 52383c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } 52425d3402cSMarshall Clow typedef void is_transparent; 52583c08b44SMarshall Clow}; 52683c08b44SMarshall Clow#endif 52783c08b44SMarshall Clow 52883c08b44SMarshall Clow 52983c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 53083c08b44SMarshall Clowtemplate <class _Tp = void> 53183c08b44SMarshall Clow#else 5323e519524SHoward Hinnanttemplate <class _Tp> 53383c08b44SMarshall Clow#endif 534e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp> 5353e519524SHoward Hinnant{ 5363d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5373d5134ddSMarshall Clow _Tp operator()(const _Tp& __x, const _Tp& __y) const 5383e519524SHoward Hinnant {return __x - __y;} 5393e519524SHoward Hinnant}; 5403e519524SHoward Hinnant 54183c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 54283c08b44SMarshall Clowtemplate <> 543e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS minus<void> 54483c08b44SMarshall Clow{ 54583c08b44SMarshall Clow template <class _T1, class _T2> 5463d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5473d5134ddSMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 548a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) 549a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) 55083c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } 55125d3402cSMarshall Clow typedef void is_transparent; 55283c08b44SMarshall Clow}; 55383c08b44SMarshall Clow#endif 55483c08b44SMarshall Clow 55583c08b44SMarshall Clow 55683c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 55783c08b44SMarshall Clowtemplate <class _Tp = void> 55883c08b44SMarshall Clow#else 5593e519524SHoward Hinnanttemplate <class _Tp> 56083c08b44SMarshall Clow#endif 561e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp> 5623e519524SHoward Hinnant{ 5633d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5643d5134ddSMarshall Clow _Tp operator()(const _Tp& __x, const _Tp& __y) const 5653e519524SHoward Hinnant {return __x * __y;} 5663e519524SHoward Hinnant}; 5673e519524SHoward Hinnant 56883c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 56983c08b44SMarshall Clowtemplate <> 570e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS multiplies<void> 57183c08b44SMarshall Clow{ 57283c08b44SMarshall Clow template <class _T1, class _T2> 5733d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5743d5134ddSMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 575a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) 576a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) 57783c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } 57825d3402cSMarshall Clow typedef void is_transparent; 57983c08b44SMarshall Clow}; 58083c08b44SMarshall Clow#endif 58183c08b44SMarshall Clow 58283c08b44SMarshall Clow 58383c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 58483c08b44SMarshall Clowtemplate <class _Tp = void> 58583c08b44SMarshall Clow#else 5863e519524SHoward Hinnanttemplate <class _Tp> 58783c08b44SMarshall Clow#endif 588e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp> 5893e519524SHoward Hinnant{ 5903d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5913d5134ddSMarshall Clow _Tp operator()(const _Tp& __x, const _Tp& __y) const 5923e519524SHoward Hinnant {return __x / __y;} 5933e519524SHoward Hinnant}; 5943e519524SHoward Hinnant 59583c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 59683c08b44SMarshall Clowtemplate <> 597e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS divides<void> 59883c08b44SMarshall Clow{ 59983c08b44SMarshall Clow template <class _T1, class _T2> 6003d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 6013d5134ddSMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 602a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) 603a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) 60483c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } 60525d3402cSMarshall Clow typedef void is_transparent; 60683c08b44SMarshall Clow}; 60783c08b44SMarshall Clow#endif 60883c08b44SMarshall Clow 60983c08b44SMarshall Clow 61083c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 61183c08b44SMarshall Clowtemplate <class _Tp = void> 61283c08b44SMarshall Clow#else 6133e519524SHoward Hinnanttemplate <class _Tp> 61483c08b44SMarshall Clow#endif 615e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp> 6163e519524SHoward Hinnant{ 6173d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 6183d5134ddSMarshall Clow _Tp operator()(const _Tp& __x, const _Tp& __y) const 6193e519524SHoward Hinnant {return __x % __y;} 6203e519524SHoward Hinnant}; 6213e519524SHoward Hinnant 62283c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 62383c08b44SMarshall Clowtemplate <> 624e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS modulus<void> 62583c08b44SMarshall Clow{ 62683c08b44SMarshall Clow template <class _T1, class _T2> 6273d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 6283d5134ddSMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 629a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) 630a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) 63183c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } 63225d3402cSMarshall Clow typedef void is_transparent; 63383c08b44SMarshall Clow}; 63483c08b44SMarshall Clow#endif 63583c08b44SMarshall Clow 63683c08b44SMarshall Clow 63783c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 63883c08b44SMarshall Clowtemplate <class _Tp = void> 63983c08b44SMarshall Clow#else 6403e519524SHoward Hinnanttemplate <class _Tp> 64183c08b44SMarshall Clow#endif 642e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp> 6433e519524SHoward Hinnant{ 6443d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 6453d5134ddSMarshall Clow _Tp operator()(const _Tp& __x) const 6463e519524SHoward Hinnant {return -__x;} 6473e519524SHoward Hinnant}; 6483e519524SHoward Hinnant 64983c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 65083c08b44SMarshall Clowtemplate <> 651e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS negate<void> 65283c08b44SMarshall Clow{ 6533e519524SHoward Hinnant template <class _Tp> 6543d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 6553d5134ddSMarshall Clow auto operator()(_Tp&& __x) const 656a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) 657a64f2fbcSMarshall Clow -> decltype (- _VSTD::forward<_Tp>(__x)) 65883c08b44SMarshall Clow { return - _VSTD::forward<_Tp>(__x); } 65925d3402cSMarshall Clow typedef void is_transparent; 66083c08b44SMarshall Clow}; 66183c08b44SMarshall Clow#endif 66283c08b44SMarshall Clow 66383c08b44SMarshall Clow 66483c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 66583c08b44SMarshall Clowtemplate <class _Tp = void> 66683c08b44SMarshall Clow#else 66783c08b44SMarshall Clowtemplate <class _Tp> 66883c08b44SMarshall Clow#endif 669e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool> 6703e519524SHoward Hinnant{ 6713d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 6723d5134ddSMarshall Clow bool operator()(const _Tp& __x, const _Tp& __y) const 6733e519524SHoward Hinnant {return __x == __y;} 6743e519524SHoward Hinnant}; 6753e519524SHoward Hinnant 67683c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 67783c08b44SMarshall Clowtemplate <> 678e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS equal_to<void> 67983c08b44SMarshall Clow{ 6803d5134ddSMarshall Clow template <class _T1, class _T2> 6813d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 68283c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 683a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) 684a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) 68583c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } 68625d3402cSMarshall Clow typedef void is_transparent; 68783c08b44SMarshall Clow}; 68883c08b44SMarshall Clow#endif 68983c08b44SMarshall Clow 69083c08b44SMarshall Clow 69183c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 69283c08b44SMarshall Clowtemplate <class _Tp = void> 69383c08b44SMarshall Clow#else 6943e519524SHoward Hinnanttemplate <class _Tp> 69583c08b44SMarshall Clow#endif 696e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS not_equal_to : binary_function<_Tp, _Tp, bool> 6973e519524SHoward Hinnant{ 6983d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 6993d5134ddSMarshall Clow bool operator()(const _Tp& __x, const _Tp& __y) const 7003e519524SHoward Hinnant {return __x != __y;} 7013e519524SHoward Hinnant}; 7023e519524SHoward Hinnant 70383c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 70483c08b44SMarshall Clowtemplate <> 705e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS not_equal_to<void> 70683c08b44SMarshall Clow{ 7073d5134ddSMarshall Clow template <class _T1, class _T2> 7083d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 70983c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 710a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) 711a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) 71283c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } 71325d3402cSMarshall Clow typedef void is_transparent; 71483c08b44SMarshall Clow}; 71583c08b44SMarshall Clow#endif 71683c08b44SMarshall Clow 71783c08b44SMarshall Clow 71883c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 71983c08b44SMarshall Clowtemplate <class _Tp = void> 72083c08b44SMarshall Clow#else 7213e519524SHoward Hinnanttemplate <class _Tp> 72283c08b44SMarshall Clow#endif 723e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool> 7243e519524SHoward Hinnant{ 7253d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 7263d5134ddSMarshall Clow bool operator()(const _Tp& __x, const _Tp& __y) const 7273e519524SHoward Hinnant {return __x > __y;} 7283e519524SHoward Hinnant}; 7293e519524SHoward Hinnant 73083c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 73183c08b44SMarshall Clowtemplate <> 732e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS greater<void> 73383c08b44SMarshall Clow{ 7343d5134ddSMarshall Clow template <class _T1, class _T2> 7353d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 73683c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 737a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) 738a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) 73983c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } 74025d3402cSMarshall Clow typedef void is_transparent; 74183c08b44SMarshall Clow}; 74283c08b44SMarshall Clow#endif 74383c08b44SMarshall Clow 74483c08b44SMarshall Clow 74567f39647SHoward Hinnant// less in <__functional_base> 7463e519524SHoward Hinnant 74783c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 74883c08b44SMarshall Clowtemplate <class _Tp = void> 74983c08b44SMarshall Clow#else 7503e519524SHoward Hinnanttemplate <class _Tp> 75183c08b44SMarshall Clow#endif 752e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool> 7533e519524SHoward Hinnant{ 7543d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 7553d5134ddSMarshall Clow bool operator()(const _Tp& __x, const _Tp& __y) const 7563e519524SHoward Hinnant {return __x >= __y;} 7573e519524SHoward Hinnant}; 7583e519524SHoward Hinnant 75983c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 76083c08b44SMarshall Clowtemplate <> 761e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS greater_equal<void> 76283c08b44SMarshall Clow{ 7633d5134ddSMarshall Clow template <class _T1, class _T2> 7643d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 76583c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 766a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) 767a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) 76883c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } 76925d3402cSMarshall Clow typedef void is_transparent; 77083c08b44SMarshall Clow}; 77183c08b44SMarshall Clow#endif 77283c08b44SMarshall Clow 77383c08b44SMarshall Clow 77483c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 77583c08b44SMarshall Clowtemplate <class _Tp = void> 77683c08b44SMarshall Clow#else 7773e519524SHoward Hinnanttemplate <class _Tp> 77883c08b44SMarshall Clow#endif 779e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool> 7803e519524SHoward Hinnant{ 7813d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 7823d5134ddSMarshall Clow bool operator()(const _Tp& __x, const _Tp& __y) const 7833e519524SHoward Hinnant {return __x <= __y;} 7843e519524SHoward Hinnant}; 7853e519524SHoward Hinnant 78683c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 78783c08b44SMarshall Clowtemplate <> 788e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS less_equal<void> 78983c08b44SMarshall Clow{ 7903d5134ddSMarshall Clow template <class _T1, class _T2> 7913d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 79283c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 793a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) 794a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) 79583c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } 79625d3402cSMarshall Clow typedef void is_transparent; 79783c08b44SMarshall Clow}; 79883c08b44SMarshall Clow#endif 79983c08b44SMarshall Clow 80083c08b44SMarshall Clow 80183c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 80283c08b44SMarshall Clowtemplate <class _Tp = void> 80383c08b44SMarshall Clow#else 8043e519524SHoward Hinnanttemplate <class _Tp> 80583c08b44SMarshall Clow#endif 806e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool> 8073e519524SHoward Hinnant{ 8083d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 8093d5134ddSMarshall Clow bool operator()(const _Tp& __x, const _Tp& __y) const 8103e519524SHoward Hinnant {return __x && __y;} 8113e519524SHoward Hinnant}; 8123e519524SHoward Hinnant 81383c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 81483c08b44SMarshall Clowtemplate <> 815e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS logical_and<void> 81683c08b44SMarshall Clow{ 8173d5134ddSMarshall Clow template <class _T1, class _T2> 8183d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 81983c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 820a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) 821a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) 82283c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } 82325d3402cSMarshall Clow typedef void is_transparent; 82483c08b44SMarshall Clow}; 82583c08b44SMarshall Clow#endif 82683c08b44SMarshall Clow 82783c08b44SMarshall Clow 82883c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 82983c08b44SMarshall Clowtemplate <class _Tp = void> 83083c08b44SMarshall Clow#else 8313e519524SHoward Hinnanttemplate <class _Tp> 83283c08b44SMarshall Clow#endif 833e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool> 8343e519524SHoward Hinnant{ 8353d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 8363d5134ddSMarshall Clow bool operator()(const _Tp& __x, const _Tp& __y) const 8373e519524SHoward Hinnant {return __x || __y;} 8383e519524SHoward Hinnant}; 8393e519524SHoward Hinnant 84083c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 84183c08b44SMarshall Clowtemplate <> 842e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS logical_or<void> 84383c08b44SMarshall Clow{ 8443d5134ddSMarshall Clow template <class _T1, class _T2> 8453d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 84683c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 847a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) 848a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) 84983c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } 85025d3402cSMarshall Clow typedef void is_transparent; 85183c08b44SMarshall Clow}; 85283c08b44SMarshall Clow#endif 85383c08b44SMarshall Clow 85483c08b44SMarshall Clow 85583c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 85683c08b44SMarshall Clowtemplate <class _Tp = void> 85783c08b44SMarshall Clow#else 8583e519524SHoward Hinnanttemplate <class _Tp> 85983c08b44SMarshall Clow#endif 860e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool> 8613e519524SHoward Hinnant{ 8623d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 8633d5134ddSMarshall Clow bool operator()(const _Tp& __x) const 8643e519524SHoward Hinnant {return !__x;} 8653e519524SHoward Hinnant}; 8663e519524SHoward Hinnant 86783c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 86883c08b44SMarshall Clowtemplate <> 869e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS logical_not<void> 87083c08b44SMarshall Clow{ 8713e519524SHoward Hinnant template <class _Tp> 8723d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 8733d5134ddSMarshall Clow auto operator()(_Tp&& __x) const 874a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) 875a64f2fbcSMarshall Clow -> decltype (!_VSTD::forward<_Tp>(__x)) 87683c08b44SMarshall Clow { return !_VSTD::forward<_Tp>(__x); } 87725d3402cSMarshall Clow typedef void is_transparent; 87883c08b44SMarshall Clow}; 87983c08b44SMarshall Clow#endif 88083c08b44SMarshall Clow 88183c08b44SMarshall Clow 88283c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 88383c08b44SMarshall Clowtemplate <class _Tp = void> 88483c08b44SMarshall Clow#else 88583c08b44SMarshall Clowtemplate <class _Tp> 88683c08b44SMarshall Clow#endif 887e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp> 8883e519524SHoward Hinnant{ 8893d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 8903d5134ddSMarshall Clow _Tp operator()(const _Tp& __x, const _Tp& __y) const 8913e519524SHoward Hinnant {return __x & __y;} 8923e519524SHoward Hinnant}; 8933e519524SHoward Hinnant 89483c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 89583c08b44SMarshall Clowtemplate <> 896e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS bit_and<void> 89783c08b44SMarshall Clow{ 8983d5134ddSMarshall Clow template <class _T1, class _T2> 8993d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 90083c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 901a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) 902a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) 90383c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } 90425d3402cSMarshall Clow typedef void is_transparent; 90583c08b44SMarshall Clow}; 90683c08b44SMarshall Clow#endif 90783c08b44SMarshall Clow 90883c08b44SMarshall Clow 90983c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 91083c08b44SMarshall Clowtemplate <class _Tp = void> 91183c08b44SMarshall Clow#else 9123e519524SHoward Hinnanttemplate <class _Tp> 91383c08b44SMarshall Clow#endif 914e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp> 9153e519524SHoward Hinnant{ 9163d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 9173d5134ddSMarshall Clow _Tp operator()(const _Tp& __x, const _Tp& __y) const 9183e519524SHoward Hinnant {return __x | __y;} 9193e519524SHoward Hinnant}; 9203e519524SHoward Hinnant 92183c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 92283c08b44SMarshall Clowtemplate <> 923e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS bit_or<void> 92483c08b44SMarshall Clow{ 9253d5134ddSMarshall Clow template <class _T1, class _T2> 9263d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 92783c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 928a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) 929a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) 93083c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } 93125d3402cSMarshall Clow typedef void is_transparent; 93283c08b44SMarshall Clow}; 93383c08b44SMarshall Clow#endif 93483c08b44SMarshall Clow 93583c08b44SMarshall Clow 93683c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 93783c08b44SMarshall Clowtemplate <class _Tp = void> 93883c08b44SMarshall Clow#else 9393e519524SHoward Hinnanttemplate <class _Tp> 94083c08b44SMarshall Clow#endif 941e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp> 9423e519524SHoward Hinnant{ 9433d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 9443d5134ddSMarshall Clow _Tp operator()(const _Tp& __x, const _Tp& __y) const 9453e519524SHoward Hinnant {return __x ^ __y;} 9463e519524SHoward Hinnant}; 9473e519524SHoward Hinnant 94883c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 94983c08b44SMarshall Clowtemplate <> 950e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS bit_xor<void> 95183c08b44SMarshall Clow{ 9523d5134ddSMarshall Clow template <class _T1, class _T2> 9533d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 95483c08b44SMarshall Clow auto operator()(_T1&& __t, _T2&& __u) const 955a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) 956a64f2fbcSMarshall Clow -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) 95783c08b44SMarshall Clow { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } 95825d3402cSMarshall Clow typedef void is_transparent; 95983c08b44SMarshall Clow}; 96083c08b44SMarshall Clow#endif 96183c08b44SMarshall Clow 96283c08b44SMarshall Clow 96383c08b44SMarshall Clow#if _LIBCPP_STD_VER > 11 96483c08b44SMarshall Clowtemplate <class _Tp = void> 965e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS bit_not : unary_function<_Tp, _Tp> 96683c08b44SMarshall Clow{ 9673d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 9683d5134ddSMarshall Clow _Tp operator()(const _Tp& __x) const 96983c08b44SMarshall Clow {return ~__x;} 97083c08b44SMarshall Clow}; 97183c08b44SMarshall Clow 97283c08b44SMarshall Clowtemplate <> 973e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS bit_not<void> 97483c08b44SMarshall Clow{ 97583c08b44SMarshall Clow template <class _Tp> 9763d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 9773d5134ddSMarshall Clow auto operator()(_Tp&& __x) const 978a64f2fbcSMarshall Clow _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) 979a64f2fbcSMarshall Clow -> decltype (~_VSTD::forward<_Tp>(__x)) 98083c08b44SMarshall Clow { return ~_VSTD::forward<_Tp>(__x); } 98125d3402cSMarshall Clow typedef void is_transparent; 98283c08b44SMarshall Clow}; 98383c08b44SMarshall Clow#endif 98483c08b44SMarshall Clow 9853e519524SHoward Hinnanttemplate <class _Predicate> 986*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate 9873e519524SHoward Hinnant : public unary_function<typename _Predicate::argument_type, bool> 9883e519524SHoward Hinnant{ 9893e519524SHoward Hinnant _Predicate __pred_; 9903e519524SHoward Hinnantpublic: 9913d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 9923d5134ddSMarshall Clow explicit unary_negate(const _Predicate& __pred) 9933e519524SHoward Hinnant : __pred_(__pred) {} 9943d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 9953d5134ddSMarshall Clow bool operator()(const typename _Predicate::argument_type& __x) const 9963e519524SHoward Hinnant {return !__pred_(__x);} 9973e519524SHoward Hinnant}; 9983e519524SHoward Hinnant 9993e519524SHoward Hinnanttemplate <class _Predicate> 1000*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 10013e519524SHoward Hinnantunary_negate<_Predicate> 10023e519524SHoward Hinnantnot1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} 10033e519524SHoward Hinnant 10043e519524SHoward Hinnanttemplate <class _Predicate> 1005*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate 10063e519524SHoward Hinnant : public binary_function<typename _Predicate::first_argument_type, 10073e519524SHoward Hinnant typename _Predicate::second_argument_type, 10083e519524SHoward Hinnant bool> 10093e519524SHoward Hinnant{ 10103e519524SHoward Hinnant _Predicate __pred_; 10113e519524SHoward Hinnantpublic: 10123d5134ddSMarshall Clow _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 10133d5134ddSMarshall Clow binary_negate(const _Predicate& __pred) : __pred_(__pred) {} 10143d5134ddSMarshall Clow 10153d5134ddSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 10163d5134ddSMarshall Clow bool operator()(const typename _Predicate::first_argument_type& __x, 10173e519524SHoward Hinnant const typename _Predicate::second_argument_type& __y) const 10183e519524SHoward Hinnant {return !__pred_(__x, __y);} 10193e519524SHoward Hinnant}; 10203e519524SHoward Hinnant 10213e519524SHoward Hinnanttemplate <class _Predicate> 1022*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 10233e519524SHoward Hinnantbinary_negate<_Predicate> 10243e519524SHoward Hinnantnot2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} 10253e519524SHoward Hinnant 10267d210c78SMarshall Clow#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) 10273e519524SHoward Hinnanttemplate <class __Operation> 1028*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st 10293e519524SHoward Hinnant : public unary_function<typename __Operation::second_argument_type, 10303e519524SHoward Hinnant typename __Operation::result_type> 10313e519524SHoward Hinnant{ 10323e519524SHoward Hinnantprotected: 10333e519524SHoward Hinnant __Operation op; 10343e519524SHoward Hinnant typename __Operation::first_argument_type value; 10353e519524SHoward Hinnantpublic: 10363e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, 10373e519524SHoward Hinnant const typename __Operation::first_argument_type __y) 10383e519524SHoward Hinnant : op(__x), value(__y) {} 10393e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 10403e519524SHoward Hinnant (typename __Operation::second_argument_type& __x) const 10413e519524SHoward Hinnant {return op(value, __x);} 10423e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 10433e519524SHoward Hinnant (const typename __Operation::second_argument_type& __x) const 10443e519524SHoward Hinnant {return op(value, __x);} 10453e519524SHoward Hinnant}; 10463e519524SHoward Hinnant 10473e519524SHoward Hinnanttemplate <class __Operation, class _Tp> 1048*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 10493e519524SHoward Hinnantbinder1st<__Operation> 10503e519524SHoward Hinnantbind1st(const __Operation& __op, const _Tp& __x) 10513e519524SHoward Hinnant {return binder1st<__Operation>(__op, __x);} 10523e519524SHoward Hinnant 10533e519524SHoward Hinnanttemplate <class __Operation> 1054*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd 10553e519524SHoward Hinnant : public unary_function<typename __Operation::first_argument_type, 10563e519524SHoward Hinnant typename __Operation::result_type> 10573e519524SHoward Hinnant{ 10583e519524SHoward Hinnantprotected: 10593e519524SHoward Hinnant __Operation op; 10603e519524SHoward Hinnant typename __Operation::second_argument_type value; 10613e519524SHoward Hinnantpublic: 10620af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 10633e519524SHoward Hinnant binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) 10643e519524SHoward Hinnant : op(__x), value(__y) {} 10653e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 10663e519524SHoward Hinnant ( typename __Operation::first_argument_type& __x) const 10673e519524SHoward Hinnant {return op(__x, value);} 10683e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 10693e519524SHoward Hinnant (const typename __Operation::first_argument_type& __x) const 10703e519524SHoward Hinnant {return op(__x, value);} 10713e519524SHoward Hinnant}; 10723e519524SHoward Hinnant 10733e519524SHoward Hinnanttemplate <class __Operation, class _Tp> 1074*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 10753e519524SHoward Hinnantbinder2nd<__Operation> 10763e519524SHoward Hinnantbind2nd(const __Operation& __op, const _Tp& __x) 10773e519524SHoward Hinnant {return binder2nd<__Operation>(__op, __x);} 10783e519524SHoward Hinnant 10793e519524SHoward Hinnanttemplate <class _Arg, class _Result> 1080*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function 10810af133f9SHoward Hinnant : public unary_function<_Arg, _Result> 10823e519524SHoward Hinnant{ 10833e519524SHoward Hinnant _Result (*__f_)(_Arg); 10843e519524SHoward Hinnantpublic: 10853e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) 10863e519524SHoward Hinnant : __f_(__f) {} 10873e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const 10883e519524SHoward Hinnant {return __f_(__x);} 10893e519524SHoward Hinnant}; 10903e519524SHoward Hinnant 10913e519524SHoward Hinnanttemplate <class _Arg, class _Result> 1092*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 10933e519524SHoward Hinnantpointer_to_unary_function<_Arg,_Result> 10943e519524SHoward Hinnantptr_fun(_Result (*__f)(_Arg)) 10953e519524SHoward Hinnant {return pointer_to_unary_function<_Arg,_Result>(__f);} 10963e519524SHoward Hinnant 10973e519524SHoward Hinnanttemplate <class _Arg1, class _Arg2, class _Result> 1098*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function 10990af133f9SHoward Hinnant : public binary_function<_Arg1, _Arg2, _Result> 11003e519524SHoward Hinnant{ 11013e519524SHoward Hinnant _Result (*__f_)(_Arg1, _Arg2); 11023e519524SHoward Hinnantpublic: 11033e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) 11043e519524SHoward Hinnant : __f_(__f) {} 11053e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const 11063e519524SHoward Hinnant {return __f_(__x, __y);} 11073e519524SHoward Hinnant}; 11083e519524SHoward Hinnant 11093e519524SHoward Hinnanttemplate <class _Arg1, class _Arg2, class _Result> 1110*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 11113e519524SHoward Hinnantpointer_to_binary_function<_Arg1,_Arg2,_Result> 11123e519524SHoward Hinnantptr_fun(_Result (*__f)(_Arg1,_Arg2)) 11133e519524SHoward Hinnant {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} 11143e519524SHoward Hinnant 11153e519524SHoward Hinnanttemplate<class _Sp, class _Tp> 1116*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t 1117*ea5cd3b4SLouis Dionne : public unary_function<_Tp*, _Sp> 11183e519524SHoward Hinnant{ 11193e519524SHoward Hinnant _Sp (_Tp::*__p_)(); 11203e519524SHoward Hinnantpublic: 11213e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) 11223e519524SHoward Hinnant : __p_(__p) {} 11233e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const 11243e519524SHoward Hinnant {return (__p->*__p_)();} 11253e519524SHoward Hinnant}; 11263e519524SHoward Hinnant 11273e519524SHoward Hinnanttemplate<class _Sp, class _Tp, class _Ap> 1128*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t 1129*ea5cd3b4SLouis Dionne : public binary_function<_Tp*, _Ap, _Sp> 11303e519524SHoward Hinnant{ 11313e519524SHoward Hinnant _Sp (_Tp::*__p_)(_Ap); 11323e519524SHoward Hinnantpublic: 11333e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) 11343e519524SHoward Hinnant : __p_(__p) {} 11353e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const 11363e519524SHoward Hinnant {return (__p->*__p_)(__x);} 11373e519524SHoward Hinnant}; 11383e519524SHoward Hinnant 11393e519524SHoward Hinnanttemplate<class _Sp, class _Tp> 1140*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 11413e519524SHoward Hinnantmem_fun_t<_Sp,_Tp> 11423e519524SHoward Hinnantmem_fun(_Sp (_Tp::*__f)()) 11433e519524SHoward Hinnant {return mem_fun_t<_Sp,_Tp>(__f);} 11443e519524SHoward Hinnant 11453e519524SHoward Hinnanttemplate<class _Sp, class _Tp, class _Ap> 1146*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 11473e519524SHoward Hinnantmem_fun1_t<_Sp,_Tp,_Ap> 11483e519524SHoward Hinnantmem_fun(_Sp (_Tp::*__f)(_Ap)) 11493e519524SHoward Hinnant {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 11503e519524SHoward Hinnant 11513e519524SHoward Hinnanttemplate<class _Sp, class _Tp> 1152*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t 1153*ea5cd3b4SLouis Dionne : public unary_function<_Tp, _Sp> 11543e519524SHoward Hinnant{ 11553e519524SHoward Hinnant _Sp (_Tp::*__p_)(); 11563e519524SHoward Hinnantpublic: 11573e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) 11583e519524SHoward Hinnant : __p_(__p) {} 11593e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const 11603e519524SHoward Hinnant {return (__p.*__p_)();} 11613e519524SHoward Hinnant}; 11623e519524SHoward Hinnant 11633e519524SHoward Hinnanttemplate<class _Sp, class _Tp, class _Ap> 1164*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t 1165*ea5cd3b4SLouis Dionne : public binary_function<_Tp, _Ap, _Sp> 11663e519524SHoward Hinnant{ 11673e519524SHoward Hinnant _Sp (_Tp::*__p_)(_Ap); 11683e519524SHoward Hinnantpublic: 11693e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) 11703e519524SHoward Hinnant : __p_(__p) {} 11713e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const 11723e519524SHoward Hinnant {return (__p.*__p_)(__x);} 11733e519524SHoward Hinnant}; 11743e519524SHoward Hinnant 11753e519524SHoward Hinnanttemplate<class _Sp, class _Tp> 1176*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 11773e519524SHoward Hinnantmem_fun_ref_t<_Sp,_Tp> 11783e519524SHoward Hinnantmem_fun_ref(_Sp (_Tp::*__f)()) 11793e519524SHoward Hinnant {return mem_fun_ref_t<_Sp,_Tp>(__f);} 11803e519524SHoward Hinnant 11813e519524SHoward Hinnanttemplate<class _Sp, class _Tp, class _Ap> 1182*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 11833e519524SHoward Hinnantmem_fun1_ref_t<_Sp,_Tp,_Ap> 11843e519524SHoward Hinnantmem_fun_ref(_Sp (_Tp::*__f)(_Ap)) 11853e519524SHoward Hinnant {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 11863e519524SHoward Hinnant 11873e519524SHoward Hinnanttemplate <class _Sp, class _Tp> 1188*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t 1189*ea5cd3b4SLouis Dionne : public unary_function<const _Tp*, _Sp> 11903e519524SHoward Hinnant{ 11913e519524SHoward Hinnant _Sp (_Tp::*__p_)() const; 11923e519524SHoward Hinnantpublic: 11933e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) 11943e519524SHoward Hinnant : __p_(__p) {} 11953e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const 11963e519524SHoward Hinnant {return (__p->*__p_)();} 11973e519524SHoward Hinnant}; 11983e519524SHoward Hinnant 11993e519524SHoward Hinnanttemplate <class _Sp, class _Tp, class _Ap> 1200*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t 1201*ea5cd3b4SLouis Dionne : public binary_function<const _Tp*, _Ap, _Sp> 12023e519524SHoward Hinnant{ 12033e519524SHoward Hinnant _Sp (_Tp::*__p_)(_Ap) const; 12043e519524SHoward Hinnantpublic: 12053e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) 12063e519524SHoward Hinnant : __p_(__p) {} 12073e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const 12083e519524SHoward Hinnant {return (__p->*__p_)(__x);} 12093e519524SHoward Hinnant}; 12103e519524SHoward Hinnant 12113e519524SHoward Hinnanttemplate <class _Sp, class _Tp> 1212*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 12133e519524SHoward Hinnantconst_mem_fun_t<_Sp,_Tp> 12143e519524SHoward Hinnantmem_fun(_Sp (_Tp::*__f)() const) 12153e519524SHoward Hinnant {return const_mem_fun_t<_Sp,_Tp>(__f);} 12163e519524SHoward Hinnant 12173e519524SHoward Hinnanttemplate <class _Sp, class _Tp, class _Ap> 1218*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 12193e519524SHoward Hinnantconst_mem_fun1_t<_Sp,_Tp,_Ap> 12203e519524SHoward Hinnantmem_fun(_Sp (_Tp::*__f)(_Ap) const) 12213e519524SHoward Hinnant {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 12223e519524SHoward Hinnant 12233e519524SHoward Hinnanttemplate <class _Sp, class _Tp> 1224*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t 1225*ea5cd3b4SLouis Dionne : public unary_function<_Tp, _Sp> 12263e519524SHoward Hinnant{ 12273e519524SHoward Hinnant _Sp (_Tp::*__p_)() const; 12283e519524SHoward Hinnantpublic: 12293e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) 12303e519524SHoward Hinnant : __p_(__p) {} 12313e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const 12323e519524SHoward Hinnant {return (__p.*__p_)();} 12333e519524SHoward Hinnant}; 12343e519524SHoward Hinnant 12353e519524SHoward Hinnanttemplate <class _Sp, class _Tp, class _Ap> 1236*ea5cd3b4SLouis Dionneclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t 12370af133f9SHoward Hinnant : public binary_function<_Tp, _Ap, _Sp> 12383e519524SHoward Hinnant{ 12393e519524SHoward Hinnant _Sp (_Tp::*__p_)(_Ap) const; 12403e519524SHoward Hinnantpublic: 12413e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) 12423e519524SHoward Hinnant : __p_(__p) {} 12433e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const 12443e519524SHoward Hinnant {return (__p.*__p_)(__x);} 12453e519524SHoward Hinnant}; 12463e519524SHoward Hinnant 12473e519524SHoward Hinnanttemplate <class _Sp, class _Tp> 1248*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 12493e519524SHoward Hinnantconst_mem_fun_ref_t<_Sp,_Tp> 12503e519524SHoward Hinnantmem_fun_ref(_Sp (_Tp::*__f)() const) 12513e519524SHoward Hinnant {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} 12523e519524SHoward Hinnant 12533e519524SHoward Hinnanttemplate <class _Sp, class _Tp, class _Ap> 1254*ea5cd3b4SLouis Dionne_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 12553e519524SHoward Hinnantconst_mem_fun1_ref_t<_Sp,_Tp,_Ap> 12563e519524SHoward Hinnantmem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) 12573e519524SHoward Hinnant {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 12587d210c78SMarshall Clow#endif 12593e519524SHoward Hinnant 1260e5407178SEric Fiselier//////////////////////////////////////////////////////////////////////////////// 1261e5407178SEric Fiselier// MEMFUN 1262e5407178SEric Fiselier//============================================================================== 12633e519524SHoward Hinnant 12643e519524SHoward Hinnanttemplate <class _Tp> 12653e519524SHoward Hinnantclass __mem_fn 12663e519524SHoward Hinnant : public __weak_result_type<_Tp> 12673e519524SHoward Hinnant{ 12683e519524SHoward Hinnantpublic: 12693e519524SHoward Hinnant // types 12703e519524SHoward Hinnant typedef _Tp type; 12713e519524SHoward Hinnantprivate: 12723e519524SHoward Hinnant type __f_; 12733e519524SHoward Hinnant 12743e519524SHoward Hinnantpublic: 12753b72a6efSMarshall Clow _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} 12763e519524SHoward Hinnant 12777e23afcbSEric Fiselier#ifndef _LIBCPP_CXX03_LANG 12783e519524SHoward Hinnant // invoke 12793e519524SHoward Hinnant template <class... _ArgTypes> 12800af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 12813e519524SHoward Hinnant typename __invoke_return<type, _ArgTypes...>::type 128200f512ebSEric Fiselier operator() (_ArgTypes&&... __args) const { 1283ce48a113SHoward Hinnant return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); 12843e519524SHoward Hinnant } 128500f512ebSEric Fiselier#else 128600f512ebSEric Fiselier 128700f512ebSEric Fiselier template <class _A0> 128870192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 128900f512ebSEric Fiselier typename __invoke_return0<type, _A0>::type 129000f512ebSEric Fiselier operator() (_A0& __a0) const { 129100f512ebSEric Fiselier return __invoke(__f_, __a0); 129200f512ebSEric Fiselier } 129300f512ebSEric Fiselier 129470192a9eSEric Fiselier template <class _A0> 129570192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 129670192a9eSEric Fiselier typename __invoke_return0<type, _A0 const>::type 129770192a9eSEric Fiselier operator() (_A0 const& __a0) const { 129870192a9eSEric Fiselier return __invoke(__f_, __a0); 129970192a9eSEric Fiselier } 130070192a9eSEric Fiselier 130100f512ebSEric Fiselier template <class _A0, class _A1> 130270192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 130300f512ebSEric Fiselier typename __invoke_return1<type, _A0, _A1>::type 130400f512ebSEric Fiselier operator() (_A0& __a0, _A1& __a1) const { 130500f512ebSEric Fiselier return __invoke(__f_, __a0, __a1); 130600f512ebSEric Fiselier } 130700f512ebSEric Fiselier 130870192a9eSEric Fiselier template <class _A0, class _A1> 130970192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 131070192a9eSEric Fiselier typename __invoke_return1<type, _A0 const, _A1>::type 131170192a9eSEric Fiselier operator() (_A0 const& __a0, _A1& __a1) const { 131270192a9eSEric Fiselier return __invoke(__f_, __a0, __a1); 131370192a9eSEric Fiselier } 131470192a9eSEric Fiselier 131570192a9eSEric Fiselier template <class _A0, class _A1> 131670192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 131770192a9eSEric Fiselier typename __invoke_return1<type, _A0, _A1 const>::type 131870192a9eSEric Fiselier operator() (_A0& __a0, _A1 const& __a1) const { 131970192a9eSEric Fiselier return __invoke(__f_, __a0, __a1); 132070192a9eSEric Fiselier } 132170192a9eSEric Fiselier 132270192a9eSEric Fiselier template <class _A0, class _A1> 132370192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 132470192a9eSEric Fiselier typename __invoke_return1<type, _A0 const, _A1 const>::type 132570192a9eSEric Fiselier operator() (_A0 const& __a0, _A1 const& __a1) const { 132670192a9eSEric Fiselier return __invoke(__f_, __a0, __a1); 132770192a9eSEric Fiselier } 132870192a9eSEric Fiselier 132900f512ebSEric Fiselier template <class _A0, class _A1, class _A2> 133070192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 133100f512ebSEric Fiselier typename __invoke_return2<type, _A0, _A1, _A2>::type 133200f512ebSEric Fiselier operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { 133300f512ebSEric Fiselier return __invoke(__f_, __a0, __a1, __a2); 133400f512ebSEric Fiselier } 133570192a9eSEric Fiselier 133670192a9eSEric Fiselier template <class _A0, class _A1, class _A2> 133770192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 133870192a9eSEric Fiselier typename __invoke_return2<type, _A0 const, _A1, _A2>::type 133970192a9eSEric Fiselier operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { 134070192a9eSEric Fiselier return __invoke(__f_, __a0, __a1, __a2); 134170192a9eSEric Fiselier } 134270192a9eSEric Fiselier 134370192a9eSEric Fiselier template <class _A0, class _A1, class _A2> 134470192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 134570192a9eSEric Fiselier typename __invoke_return2<type, _A0, _A1 const, _A2>::type 134670192a9eSEric Fiselier operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { 134770192a9eSEric Fiselier return __invoke(__f_, __a0, __a1, __a2); 134870192a9eSEric Fiselier } 134970192a9eSEric Fiselier 135070192a9eSEric Fiselier template <class _A0, class _A1, class _A2> 135170192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 135270192a9eSEric Fiselier typename __invoke_return2<type, _A0, _A1, _A2 const>::type 135370192a9eSEric Fiselier operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { 135470192a9eSEric Fiselier return __invoke(__f_, __a0, __a1, __a2); 135570192a9eSEric Fiselier } 135670192a9eSEric Fiselier 135770192a9eSEric Fiselier template <class _A0, class _A1, class _A2> 135870192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 135970192a9eSEric Fiselier typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type 136070192a9eSEric Fiselier operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { 136170192a9eSEric Fiselier return __invoke(__f_, __a0, __a1, __a2); 136270192a9eSEric Fiselier } 136370192a9eSEric Fiselier 136470192a9eSEric Fiselier template <class _A0, class _A1, class _A2> 136570192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 136670192a9eSEric Fiselier typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type 136770192a9eSEric Fiselier operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { 136870192a9eSEric Fiselier return __invoke(__f_, __a0, __a1, __a2); 136970192a9eSEric Fiselier } 137070192a9eSEric Fiselier 137170192a9eSEric Fiselier template <class _A0, class _A1, class _A2> 137270192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 137370192a9eSEric Fiselier typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type 137470192a9eSEric Fiselier operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { 137570192a9eSEric Fiselier return __invoke(__f_, __a0, __a1, __a2); 137670192a9eSEric Fiselier } 137770192a9eSEric Fiselier 137870192a9eSEric Fiselier template <class _A0, class _A1, class _A2> 137970192a9eSEric Fiselier _LIBCPP_INLINE_VISIBILITY 138070192a9eSEric Fiselier typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type 138170192a9eSEric Fiselier operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { 138270192a9eSEric Fiselier return __invoke(__f_, __a0, __a1, __a2); 138370192a9eSEric Fiselier } 138400f512ebSEric Fiselier#endif 13853e519524SHoward Hinnant}; 13863e519524SHoward Hinnant 1387c003db1fSHoward Hinnanttemplate<class _Rp, class _Tp> 13883e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 1389c003db1fSHoward Hinnant__mem_fn<_Rp _Tp::*> 13903b72a6efSMarshall Clowmem_fn(_Rp _Tp::* __pm) _NOEXCEPT 13913e519524SHoward Hinnant{ 1392c003db1fSHoward Hinnant return __mem_fn<_Rp _Tp::*>(__pm); 13933e519524SHoward Hinnant} 13943e519524SHoward Hinnant 1395e5407178SEric Fiselier//////////////////////////////////////////////////////////////////////////////// 1396e5407178SEric Fiselier// FUNCTION 1397e5407178SEric Fiselier//============================================================================== 1398e5407178SEric Fiselier 13993e519524SHoward Hinnant// bad_function_call 14003e519524SHoward Hinnant 14010af133f9SHoward Hinnantclass _LIBCPP_EXCEPTION_ABI bad_function_call 14023e519524SHoward Hinnant : public exception 14033e519524SHoward Hinnant{ 1404c7cd73e8SShoaib Meenai#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 1405c7cd73e8SShoaib Meenaipublic: 1406c7cd73e8SShoaib Meenai virtual ~bad_function_call() _NOEXCEPT; 1407c7cd73e8SShoaib Meenai 1408c7cd73e8SShoaib Meenai virtual const char* what() const _NOEXCEPT; 1409c7cd73e8SShoaib Meenai#endif 14103e519524SHoward Hinnant}; 14113e519524SHoward Hinnant 1412dc7200b4SLouis Dionne_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY 1413d437fa5cSMarshall Clowvoid __throw_bad_function_call() 1414d437fa5cSMarshall Clow{ 1415d437fa5cSMarshall Clow#ifndef _LIBCPP_NO_EXCEPTIONS 1416d437fa5cSMarshall Clow throw bad_function_call(); 1417d437fa5cSMarshall Clow#else 1418d437fa5cSMarshall Clow _VSTD::abort(); 1419d437fa5cSMarshall Clow#endif 1420d437fa5cSMarshall Clow} 1421d437fa5cSMarshall Clow 1422e2f2d1edSEric Fiseliertemplate<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined 14233e519524SHoward Hinnant 14243e519524SHoward Hinnantnamespace __function 14253e519524SHoward Hinnant{ 14263e519524SHoward Hinnant 1427e5407178SEric Fiseliertemplate<class _Rp> 14283e519524SHoward Hinnantstruct __maybe_derive_from_unary_function 14293e519524SHoward Hinnant{ 14303e519524SHoward Hinnant}; 14313e519524SHoward Hinnant 1432c003db1fSHoward Hinnanttemplate<class _Rp, class _A1> 1433c003db1fSHoward Hinnantstruct __maybe_derive_from_unary_function<_Rp(_A1)> 1434c003db1fSHoward Hinnant : public unary_function<_A1, _Rp> 14353e519524SHoward Hinnant{ 14363e519524SHoward Hinnant}; 14373e519524SHoward Hinnant 1438e5407178SEric Fiseliertemplate<class _Rp> 14393e519524SHoward Hinnantstruct __maybe_derive_from_binary_function 14403e519524SHoward Hinnant{ 14413e519524SHoward Hinnant}; 14423e519524SHoward Hinnant 1443c003db1fSHoward Hinnanttemplate<class _Rp, class _A1, class _A2> 1444c003db1fSHoward Hinnantstruct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> 1445c003db1fSHoward Hinnant : public binary_function<_A1, _A2, _Rp> 14463e519524SHoward Hinnant{ 14473e519524SHoward Hinnant}; 14483e519524SHoward Hinnant 14490d28f784SEric Fiseliertemplate <class _Fp> 14500d28f784SEric Fiselier_LIBCPP_INLINE_VISIBILITY 14510d28f784SEric Fiselierbool __not_null(_Fp const&) { return true; } 14520d28f784SEric Fiselier 14530d28f784SEric Fiseliertemplate <class _Fp> 14540d28f784SEric Fiselier_LIBCPP_INLINE_VISIBILITY 14550d28f784SEric Fiselierbool __not_null(_Fp* __ptr) { return __ptr; } 14560d28f784SEric Fiselier 14570d28f784SEric Fiseliertemplate <class _Ret, class _Class> 14580d28f784SEric Fiselier_LIBCPP_INLINE_VISIBILITY 14590d28f784SEric Fiselierbool __not_null(_Ret _Class::*__ptr) { return __ptr; } 14600d28f784SEric Fiselier 14610d28f784SEric Fiseliertemplate <class _Fp> 14620d28f784SEric Fiselier_LIBCPP_INLINE_VISIBILITY 14630d28f784SEric Fiselierbool __not_null(function<_Fp> const& __f) { return !!__f; } 14640d28f784SEric Fiselier 1465e5407178SEric Fiselier} // namespace __function 1466e5407178SEric Fiselier 14677e23afcbSEric Fiselier#ifndef _LIBCPP_CXX03_LANG 1468e5407178SEric Fiselier 1469e5407178SEric Fiseliernamespace __function { 1470e5407178SEric Fiselier 14713e519524SHoward Hinnanttemplate<class _Fp> class __base; 14723e519524SHoward Hinnant 1473c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1474c003db1fSHoward Hinnantclass __base<_Rp(_ArgTypes...)> 14753e519524SHoward Hinnant{ 14763e519524SHoward Hinnant __base(const __base&); 14773e519524SHoward Hinnant __base& operator=(const __base&); 14783e519524SHoward Hinnantpublic: 14790af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY __base() {} 14800af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} 14813e519524SHoward Hinnant virtual __base* __clone() const = 0; 14823e519524SHoward Hinnant virtual void __clone(__base*) const = 0; 14836a07d6f0SHoward Hinnant virtual void destroy() _NOEXCEPT = 0; 14846a07d6f0SHoward Hinnant virtual void destroy_deallocate() _NOEXCEPT = 0; 1485c003db1fSHoward Hinnant virtual _Rp operator()(_ArgTypes&& ...) = 0; 148654b409fdSHoward Hinnant#ifndef _LIBCPP_NO_RTTI 14876a07d6f0SHoward Hinnant virtual const void* target(const type_info&) const _NOEXCEPT = 0; 14886a07d6f0SHoward Hinnant virtual const std::type_info& target_type() const _NOEXCEPT = 0; 1489b3371f6fSHoward Hinnant#endif // _LIBCPP_NO_RTTI 14903e519524SHoward Hinnant}; 14913e519524SHoward Hinnant 14923e519524SHoward Hinnanttemplate<class _FD, class _Alloc, class _FB> class __func; 14933e519524SHoward Hinnant 1494c003db1fSHoward Hinnanttemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1495c003db1fSHoward Hinnantclass __func<_Fp, _Alloc, _Rp(_ArgTypes...)> 1496c003db1fSHoward Hinnant : public __base<_Rp(_ArgTypes...)> 14973e519524SHoward Hinnant{ 1498c003db1fSHoward Hinnant __compressed_pair<_Fp, _Alloc> __f_; 14993e519524SHoward Hinnantpublic: 15000af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 15019bb1429fSHoward Hinnant explicit __func(_Fp&& __f) 15029bb1429fSHoward Hinnant : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 15039bb1429fSHoward Hinnant _VSTD::forward_as_tuple()) {} 15040af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 15059bb1429fSHoward Hinnant explicit __func(const _Fp& __f, const _Alloc& __a) 15069bb1429fSHoward Hinnant : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 15079bb1429fSHoward Hinnant _VSTD::forward_as_tuple(__a)) {} 15089bb1429fSHoward Hinnant 15099bb1429fSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 15109bb1429fSHoward Hinnant explicit __func(const _Fp& __f, _Alloc&& __a) 15119bb1429fSHoward Hinnant : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 15129bb1429fSHoward Hinnant _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 15139bb1429fSHoward Hinnant 15149bb1429fSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 15159bb1429fSHoward Hinnant explicit __func(_Fp&& __f, _Alloc&& __a) 15169bb1429fSHoward Hinnant : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 15179bb1429fSHoward Hinnant _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1518c003db1fSHoward Hinnant virtual __base<_Rp(_ArgTypes...)>* __clone() const; 1519c003db1fSHoward Hinnant virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; 15206a07d6f0SHoward Hinnant virtual void destroy() _NOEXCEPT; 15216a07d6f0SHoward Hinnant virtual void destroy_deallocate() _NOEXCEPT; 1522c003db1fSHoward Hinnant virtual _Rp operator()(_ArgTypes&& ... __arg); 152354b409fdSHoward Hinnant#ifndef _LIBCPP_NO_RTTI 15246a07d6f0SHoward Hinnant virtual const void* target(const type_info&) const _NOEXCEPT; 15256a07d6f0SHoward Hinnant virtual const std::type_info& target_type() const _NOEXCEPT; 1526b3371f6fSHoward Hinnant#endif // _LIBCPP_NO_RTTI 15273e519524SHoward Hinnant}; 15283e519524SHoward Hinnant 1529c003db1fSHoward Hinnanttemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1530c003db1fSHoward Hinnant__base<_Rp(_ArgTypes...)>* 1531c003db1fSHoward Hinnant__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const 15323e519524SHoward Hinnant{ 15336d370568SEric Fiselier typedef allocator_traits<_Alloc> __alloc_traits; 15341f508014SMarshall Clow typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; 1535c003db1fSHoward Hinnant _Ap __a(__f_.second()); 1536c003db1fSHoward Hinnant typedef __allocator_destructor<_Ap> _Dp; 1537c003db1fSHoward Hinnant unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 15383e519524SHoward Hinnant ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); 15393e519524SHoward Hinnant return __hold.release(); 15403e519524SHoward Hinnant} 15413e519524SHoward Hinnant 1542c003db1fSHoward Hinnanttemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 15433e519524SHoward Hinnantvoid 1544c003db1fSHoward Hinnant__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const 15453e519524SHoward Hinnant{ 15463e519524SHoward Hinnant ::new (__p) __func(__f_.first(), __f_.second()); 15473e519524SHoward Hinnant} 15483e519524SHoward Hinnant 1549c003db1fSHoward Hinnanttemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 15503e519524SHoward Hinnantvoid 1551c003db1fSHoward Hinnant__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT 15523e519524SHoward Hinnant{ 1553c003db1fSHoward Hinnant __f_.~__compressed_pair<_Fp, _Alloc>(); 15543e519524SHoward Hinnant} 15553e519524SHoward Hinnant 1556c003db1fSHoward Hinnanttemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 15573e519524SHoward Hinnantvoid 1558c003db1fSHoward Hinnant__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT 15593e519524SHoward Hinnant{ 15606d370568SEric Fiselier typedef allocator_traits<_Alloc> __alloc_traits; 15611f508014SMarshall Clow typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; 1562c003db1fSHoward Hinnant _Ap __a(__f_.second()); 1563c003db1fSHoward Hinnant __f_.~__compressed_pair<_Fp, _Alloc>(); 15643e519524SHoward Hinnant __a.deallocate(this, 1); 15653e519524SHoward Hinnant} 15663e519524SHoward Hinnant 1567c003db1fSHoward Hinnanttemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1568c003db1fSHoward Hinnant_Rp 1569c003db1fSHoward Hinnant__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) 15703e519524SHoward Hinnant{ 157154519a6bSEric Fiselier typedef __invoke_void_return_wrapper<_Rp> _Invoker; 157254519a6bSEric Fiselier return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); 15733e519524SHoward Hinnant} 15743e519524SHoward Hinnant 157554b409fdSHoward Hinnant#ifndef _LIBCPP_NO_RTTI 157654b409fdSHoward Hinnant 1577c003db1fSHoward Hinnanttemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 15783e519524SHoward Hinnantconst void* 1579c003db1fSHoward Hinnant__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT 15803e519524SHoward Hinnant{ 1581c003db1fSHoward Hinnant if (__ti == typeid(_Fp)) 15823e519524SHoward Hinnant return &__f_.first(); 15833e519524SHoward Hinnant return (const void*)0; 15843e519524SHoward Hinnant} 15853e519524SHoward Hinnant 1586c003db1fSHoward Hinnanttemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 15873e519524SHoward Hinnantconst std::type_info& 1588c003db1fSHoward Hinnant__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 15893e519524SHoward Hinnant{ 1590c003db1fSHoward Hinnant return typeid(_Fp); 15913e519524SHoward Hinnant} 15923e519524SHoward Hinnant 1593b3371f6fSHoward Hinnant#endif // _LIBCPP_NO_RTTI 159454b409fdSHoward Hinnant 15953e519524SHoward Hinnant} // __function 15963e519524SHoward Hinnant 1597c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1598e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> 1599c003db1fSHoward Hinnant : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, 1600c003db1fSHoward Hinnant public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> 16013e519524SHoward Hinnant{ 1602c003db1fSHoward Hinnant typedef __function::__base<_Rp(_ArgTypes...)> __base; 16038d3e7974SHoward Hinnant typename aligned_storage<3*sizeof(void*)>::type __buf_; 16043e519524SHoward Hinnant __base* __f_; 16053e519524SHoward Hinnant 16063e58a6a7SEvgeniy Stepanov _LIBCPP_NO_CFI static __base *__as_base(void *p) { 16073e58a6a7SEvgeniy Stepanov return reinterpret_cast<__base*>(p); 16083e58a6a7SEvgeniy Stepanov } 16093e58a6a7SEvgeniy Stepanov 161094d55511SEric Fiselier template <class _Fp, bool = __lazy_and< 161194d55511SEric Fiselier integral_constant<bool, !is_same<__uncvref_t<_Fp>, function>::value>, 161294d55511SEric Fiselier __invokable<_Fp&, _ArgTypes...> 161394d55511SEric Fiselier >::value> 1614542b2507SHoward Hinnant struct __callable; 1615c003db1fSHoward Hinnant template <class _Fp> 1616c003db1fSHoward Hinnant struct __callable<_Fp, true> 1617542b2507SHoward Hinnant { 161854519a6bSEric Fiselier static const bool value = is_same<void, _Rp>::value || 1619c003db1fSHoward Hinnant is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type, 1620c003db1fSHoward Hinnant _Rp>::value; 1621542b2507SHoward Hinnant }; 1622c003db1fSHoward Hinnant template <class _Fp> 1623c003db1fSHoward Hinnant struct __callable<_Fp, false> 1624542b2507SHoward Hinnant { 1625542b2507SHoward Hinnant static const bool value = false; 1626542b2507SHoward Hinnant }; 162794d55511SEric Fiselier 162894d55511SEric Fiselier template <class _Fp> 162994d55511SEric Fiselier using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type; 16303e519524SHoward Hinnantpublic: 1631c003db1fSHoward Hinnant typedef _Rp result_type; 16323e519524SHoward Hinnant 16339b0b6d45SHoward Hinnant // construct/copy/destroy: 16340af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 16356a07d6f0SHoward Hinnant function() _NOEXCEPT : __f_(0) {} 16360af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 16376a07d6f0SHoward Hinnant function(nullptr_t) _NOEXCEPT : __f_(0) {} 16383e519524SHoward Hinnant function(const function&); 16396a07d6f0SHoward Hinnant function(function&&) _NOEXCEPT; 164094d55511SEric Fiselier template<class _Fp, class = _EnableIfCallable<_Fp>> 1641fd32ab92SEric Fiselier function(_Fp); 16423e519524SHoward Hinnant 16436ecac730SMarshall Clow#if _LIBCPP_STD_VER <= 14 16449b0b6d45SHoward Hinnant template<class _Alloc> 16450af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 16466a07d6f0SHoward Hinnant function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} 16479b0b6d45SHoward Hinnant template<class _Alloc> 16480af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 16496a07d6f0SHoward Hinnant function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {} 16509b0b6d45SHoward Hinnant template<class _Alloc> 16519b0b6d45SHoward Hinnant function(allocator_arg_t, const _Alloc&, const function&); 16529b0b6d45SHoward Hinnant template<class _Alloc> 16539b0b6d45SHoward Hinnant function(allocator_arg_t, const _Alloc&, function&&); 165494d55511SEric Fiselier template<class _Fp, class _Alloc, class = _EnableIfCallable<_Fp>> 1655fd32ab92SEric Fiselier function(allocator_arg_t, const _Alloc& __a, _Fp __f); 16566ecac730SMarshall Clow#endif 16573e519524SHoward Hinnant 16583e519524SHoward Hinnant function& operator=(const function&); 16596a07d6f0SHoward Hinnant function& operator=(function&&) _NOEXCEPT; 16606a07d6f0SHoward Hinnant function& operator=(nullptr_t) _NOEXCEPT; 166194d55511SEric Fiselier template<class _Fp, class = _EnableIfCallable<_Fp>> 166294d55511SEric Fiselier function& operator=(_Fp&&); 16633e519524SHoward Hinnant 16643e519524SHoward Hinnant ~function(); 16653e519524SHoward Hinnant 16669b0b6d45SHoward Hinnant // function modifiers: 16676a07d6f0SHoward Hinnant void swap(function&) _NOEXCEPT; 16680aa1ccb0SMarshall Clow 16690aa1ccb0SMarshall Clow#if _LIBCPP_STD_VER <= 14 1670c003db1fSHoward Hinnant template<class _Fp, class _Alloc> 16710af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1672c003db1fSHoward Hinnant void assign(_Fp&& __f, const _Alloc& __a) 1673c003db1fSHoward Hinnant {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} 16740aa1ccb0SMarshall Clow#endif 16753e519524SHoward Hinnant 16769b0b6d45SHoward Hinnant // function capacity: 16770af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1678f2f2d8b9SHoward Hinnant _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;} 16793e519524SHoward Hinnant 16803e519524SHoward Hinnant // deleted overloads close possible hole in the type system 16813e519524SHoward Hinnant template<class _R2, class... _ArgTypes2> 168237030a77SHoward Hinnant bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; 16833e519524SHoward Hinnant template<class _R2, class... _ArgTypes2> 168437030a77SHoward Hinnant bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; 16853e519524SHoward Hinnantpublic: 16869b0b6d45SHoward Hinnant // function invocation: 1687c003db1fSHoward Hinnant _Rp operator()(_ArgTypes...) const; 16883e519524SHoward Hinnant 168954b409fdSHoward Hinnant#ifndef _LIBCPP_NO_RTTI 16909b0b6d45SHoward Hinnant // function target access: 16916a07d6f0SHoward Hinnant const std::type_info& target_type() const _NOEXCEPT; 1692c003db1fSHoward Hinnant template <typename _Tp> _Tp* target() _NOEXCEPT; 1693c003db1fSHoward Hinnant template <typename _Tp> const _Tp* target() const _NOEXCEPT; 1694b3371f6fSHoward Hinnant#endif // _LIBCPP_NO_RTTI 16953e519524SHoward Hinnant}; 16963e519524SHoward Hinnant 1697c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1698c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::function(const function& __f) 16993e519524SHoward Hinnant{ 17003e519524SHoward Hinnant if (__f.__f_ == 0) 17013e519524SHoward Hinnant __f_ = 0; 17023e58a6a7SEvgeniy Stepanov else if ((void *)__f.__f_ == &__f.__buf_) 17033e519524SHoward Hinnant { 17043e58a6a7SEvgeniy Stepanov __f_ = __as_base(&__buf_); 17053e519524SHoward Hinnant __f.__f_->__clone(__f_); 17063e519524SHoward Hinnant } 17073e519524SHoward Hinnant else 17083e519524SHoward Hinnant __f_ = __f.__f_->__clone(); 17093e519524SHoward Hinnant} 17103e519524SHoward Hinnant 17116ecac730SMarshall Clow#if _LIBCPP_STD_VER <= 14 1712c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 17139b0b6d45SHoward Hinnanttemplate <class _Alloc> 1714c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 17159b0b6d45SHoward Hinnant const function& __f) 17169b0b6d45SHoward Hinnant{ 17179b0b6d45SHoward Hinnant if (__f.__f_ == 0) 17189b0b6d45SHoward Hinnant __f_ = 0; 17193e58a6a7SEvgeniy Stepanov else if ((void *)__f.__f_ == &__f.__buf_) 17209b0b6d45SHoward Hinnant { 17213e58a6a7SEvgeniy Stepanov __f_ = __as_base(&__buf_); 17229b0b6d45SHoward Hinnant __f.__f_->__clone(__f_); 17239b0b6d45SHoward Hinnant } 17249b0b6d45SHoward Hinnant else 17259b0b6d45SHoward Hinnant __f_ = __f.__f_->__clone(); 17269b0b6d45SHoward Hinnant} 17276ecac730SMarshall Clow#endif 17289b0b6d45SHoward Hinnant 1729c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1730c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT 17313e519524SHoward Hinnant{ 17323e519524SHoward Hinnant if (__f.__f_ == 0) 17333e519524SHoward Hinnant __f_ = 0; 17343e58a6a7SEvgeniy Stepanov else if ((void *)__f.__f_ == &__f.__buf_) 17353e519524SHoward Hinnant { 17363e58a6a7SEvgeniy Stepanov __f_ = __as_base(&__buf_); 17373e519524SHoward Hinnant __f.__f_->__clone(__f_); 17383e519524SHoward Hinnant } 17393e519524SHoward Hinnant else 17403e519524SHoward Hinnant { 17413e519524SHoward Hinnant __f_ = __f.__f_; 17423e519524SHoward Hinnant __f.__f_ = 0; 17433e519524SHoward Hinnant } 17443e519524SHoward Hinnant} 17453e519524SHoward Hinnant 17466ecac730SMarshall Clow#if _LIBCPP_STD_VER <= 14 1747c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 17489b0b6d45SHoward Hinnanttemplate <class _Alloc> 1749c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 17509b0b6d45SHoward Hinnant function&& __f) 17519b0b6d45SHoward Hinnant{ 17529b0b6d45SHoward Hinnant if (__f.__f_ == 0) 17539b0b6d45SHoward Hinnant __f_ = 0; 17543e58a6a7SEvgeniy Stepanov else if ((void *)__f.__f_ == &__f.__buf_) 17559b0b6d45SHoward Hinnant { 17563e58a6a7SEvgeniy Stepanov __f_ = __as_base(&__buf_); 17579b0b6d45SHoward Hinnant __f.__f_->__clone(__f_); 17589b0b6d45SHoward Hinnant } 17599b0b6d45SHoward Hinnant else 17609b0b6d45SHoward Hinnant { 17619b0b6d45SHoward Hinnant __f_ = __f.__f_; 17629b0b6d45SHoward Hinnant __f.__f_ = 0; 17639b0b6d45SHoward Hinnant } 17649b0b6d45SHoward Hinnant} 17656ecac730SMarshall Clow#endif 17669b0b6d45SHoward Hinnant 1767c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1768fd32ab92SEric Fiseliertemplate <class _Fp, class> 1769fd32ab92SEric Fiselierfunction<_Rp(_ArgTypes...)>::function(_Fp __f) 17703e519524SHoward Hinnant : __f_(0) 17713e519524SHoward Hinnant{ 17720d28f784SEric Fiselier if (__function::__not_null(__f)) 17733e519524SHoward Hinnant { 1774c003db1fSHoward Hinnant typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; 1775c003db1fSHoward Hinnant if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) 17763e519524SHoward Hinnant { 17773e58a6a7SEvgeniy Stepanov __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f)); 17783e519524SHoward Hinnant } 17793e519524SHoward Hinnant else 17803e519524SHoward Hinnant { 1781c003db1fSHoward Hinnant typedef allocator<_FF> _Ap; 1782c003db1fSHoward Hinnant _Ap __a; 1783c003db1fSHoward Hinnant typedef __allocator_destructor<_Ap> _Dp; 1784c003db1fSHoward Hinnant unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1785c003db1fSHoward Hinnant ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a)); 17863e519524SHoward Hinnant __f_ = __hold.release(); 17873e519524SHoward Hinnant } 17883e519524SHoward Hinnant } 17893e519524SHoward Hinnant} 17903e519524SHoward Hinnant 17916ecac730SMarshall Clow#if _LIBCPP_STD_VER <= 14 1792c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1793fd32ab92SEric Fiseliertemplate <class _Fp, class _Alloc, class> 1794fd32ab92SEric Fiselierfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f) 17959b0b6d45SHoward Hinnant : __f_(0) 17969b0b6d45SHoward Hinnant{ 17979b0b6d45SHoward Hinnant typedef allocator_traits<_Alloc> __alloc_traits; 17980d28f784SEric Fiselier if (__function::__not_null(__f)) 17999b0b6d45SHoward Hinnant { 1800c003db1fSHoward Hinnant typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; 18011f508014SMarshall Clow typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; 1802c003db1fSHoward Hinnant _Ap __a(__a0); 18035f7c2db2SMarshall Clow if (sizeof(_FF) <= sizeof(__buf_) && 18045f7c2db2SMarshall Clow is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value) 18055f7c2db2SMarshall Clow { 18063e58a6a7SEvgeniy Stepanov __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a)); 18075f7c2db2SMarshall Clow } 18085f7c2db2SMarshall Clow else 18095f7c2db2SMarshall Clow { 1810c003db1fSHoward Hinnant typedef __allocator_destructor<_Ap> _Dp; 1811c003db1fSHoward Hinnant unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1812ce48a113SHoward Hinnant ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); 18139b0b6d45SHoward Hinnant __f_ = __hold.release(); 18149b0b6d45SHoward Hinnant } 18159b0b6d45SHoward Hinnant } 18169b0b6d45SHoward Hinnant} 18176ecac730SMarshall Clow#endif 18189b0b6d45SHoward Hinnant 1819c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1820c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>& 1821c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::operator=(const function& __f) 18223e519524SHoward Hinnant{ 18233e519524SHoward Hinnant function(__f).swap(*this); 18243e519524SHoward Hinnant return *this; 18253e519524SHoward Hinnant} 18263e519524SHoward Hinnant 1827c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1828c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>& 1829c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT 18303e519524SHoward Hinnant{ 1831aa208791SVolodymyr Sapsai *this = nullptr; 18323e519524SHoward Hinnant if (__f.__f_ == 0) 18333e519524SHoward Hinnant __f_ = 0; 18343e58a6a7SEvgeniy Stepanov else if ((void *)__f.__f_ == &__f.__buf_) 18353e519524SHoward Hinnant { 18363e58a6a7SEvgeniy Stepanov __f_ = __as_base(&__buf_); 18373e519524SHoward Hinnant __f.__f_->__clone(__f_); 18383e519524SHoward Hinnant } 18393e519524SHoward Hinnant else 18403e519524SHoward Hinnant { 18413e519524SHoward Hinnant __f_ = __f.__f_; 18423e519524SHoward Hinnant __f.__f_ = 0; 18433e519524SHoward Hinnant } 184488db3171SArgyrios Kyrtzidis return *this; 18453e519524SHoward Hinnant} 18463e519524SHoward Hinnant 1847c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1848c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>& 1849c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT 18503e519524SHoward Hinnant{ 1851aa208791SVolodymyr Sapsai __base* __t = __f_; 18523e519524SHoward Hinnant __f_ = 0; 1853aa208791SVolodymyr Sapsai if ((void *)__t == &__buf_) 1854aa208791SVolodymyr Sapsai __t->destroy(); 1855aa208791SVolodymyr Sapsai else if (__t) 1856aa208791SVolodymyr Sapsai __t->destroy_deallocate(); 185788db3171SArgyrios Kyrtzidis return *this; 18583e519524SHoward Hinnant} 18593e519524SHoward Hinnant 1860c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 186194d55511SEric Fiseliertemplate <class _Fp, class> 1862c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>& 1863c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) 18643e519524SHoward Hinnant{ 1865c003db1fSHoward Hinnant function(_VSTD::forward<_Fp>(__f)).swap(*this); 18663e519524SHoward Hinnant return *this; 18673e519524SHoward Hinnant} 18683e519524SHoward Hinnant 1869c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1870c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::~function() 18713e519524SHoward Hinnant{ 18723e58a6a7SEvgeniy Stepanov if ((void *)__f_ == &__buf_) 18733e519524SHoward Hinnant __f_->destroy(); 18743e519524SHoward Hinnant else if (__f_) 18753e519524SHoward Hinnant __f_->destroy_deallocate(); 18763e519524SHoward Hinnant} 18773e519524SHoward Hinnant 1878c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 18793e519524SHoward Hinnantvoid 1880c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT 18813e519524SHoward Hinnant{ 1882d566c345SEric Fiselier if (_VSTD::addressof(__f) == this) 1883d566c345SEric Fiselier return; 18843e58a6a7SEvgeniy Stepanov if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_) 18853e519524SHoward Hinnant { 18863e519524SHoward Hinnant typename aligned_storage<sizeof(__buf_)>::type __tempbuf; 18873e58a6a7SEvgeniy Stepanov __base* __t = __as_base(&__tempbuf); 18883e519524SHoward Hinnant __f_->__clone(__t); 18893e519524SHoward Hinnant __f_->destroy(); 18903e519524SHoward Hinnant __f_ = 0; 18913e58a6a7SEvgeniy Stepanov __f.__f_->__clone(__as_base(&__buf_)); 18923e519524SHoward Hinnant __f.__f_->destroy(); 18933e519524SHoward Hinnant __f.__f_ = 0; 18943e58a6a7SEvgeniy Stepanov __f_ = __as_base(&__buf_); 18953e58a6a7SEvgeniy Stepanov __t->__clone(__as_base(&__f.__buf_)); 18963e519524SHoward Hinnant __t->destroy(); 18973e58a6a7SEvgeniy Stepanov __f.__f_ = __as_base(&__f.__buf_); 18983e519524SHoward Hinnant } 18993e58a6a7SEvgeniy Stepanov else if ((void *)__f_ == &__buf_) 19003e519524SHoward Hinnant { 19013e58a6a7SEvgeniy Stepanov __f_->__clone(__as_base(&__f.__buf_)); 19023e519524SHoward Hinnant __f_->destroy(); 19033e519524SHoward Hinnant __f_ = __f.__f_; 19043e58a6a7SEvgeniy Stepanov __f.__f_ = __as_base(&__f.__buf_); 19053e519524SHoward Hinnant } 19063e58a6a7SEvgeniy Stepanov else if ((void *)__f.__f_ == &__f.__buf_) 19073e519524SHoward Hinnant { 19083e58a6a7SEvgeniy Stepanov __f.__f_->__clone(__as_base(&__buf_)); 19093e519524SHoward Hinnant __f.__f_->destroy(); 19103e519524SHoward Hinnant __f.__f_ = __f_; 19113e58a6a7SEvgeniy Stepanov __f_ = __as_base(&__buf_); 19123e519524SHoward Hinnant } 19133e519524SHoward Hinnant else 1914ce48a113SHoward Hinnant _VSTD::swap(__f_, __f.__f_); 19153e519524SHoward Hinnant} 19163e519524SHoward Hinnant 1917c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1918c003db1fSHoward Hinnant_Rp 1919c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const 19203e519524SHoward Hinnant{ 19213e519524SHoward Hinnant if (__f_ == 0) 1922d437fa5cSMarshall Clow __throw_bad_function_call(); 1923ce48a113SHoward Hinnant return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); 19243e519524SHoward Hinnant} 19253e519524SHoward Hinnant 192654b409fdSHoward Hinnant#ifndef _LIBCPP_NO_RTTI 192754b409fdSHoward Hinnant 1928c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 19293e519524SHoward Hinnantconst std::type_info& 1930c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 19313e519524SHoward Hinnant{ 19323e519524SHoward Hinnant if (__f_ == 0) 19333e519524SHoward Hinnant return typeid(void); 19343e519524SHoward Hinnant return __f_->target_type(); 19353e519524SHoward Hinnant} 19363e519524SHoward Hinnant 1937c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1938c003db1fSHoward Hinnanttemplate <typename _Tp> 1939c003db1fSHoward Hinnant_Tp* 1940c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::target() _NOEXCEPT 19413e519524SHoward Hinnant{ 19423e519524SHoward Hinnant if (__f_ == 0) 19438b086e38SMarshall Clow return nullptr; 19448b086e38SMarshall Clow return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp))); 19453e519524SHoward Hinnant} 19463e519524SHoward Hinnant 1947c003db1fSHoward Hinnanttemplate<class _Rp, class ..._ArgTypes> 1948c003db1fSHoward Hinnanttemplate <typename _Tp> 1949c003db1fSHoward Hinnantconst _Tp* 1950c003db1fSHoward Hinnantfunction<_Rp(_ArgTypes...)>::target() const _NOEXCEPT 19513e519524SHoward Hinnant{ 19523e519524SHoward Hinnant if (__f_ == 0) 19538b086e38SMarshall Clow return nullptr; 1954c003db1fSHoward Hinnant return (const _Tp*)__f_->target(typeid(_Tp)); 19553e519524SHoward Hinnant} 19563e519524SHoward Hinnant 1957b3371f6fSHoward Hinnant#endif // _LIBCPP_NO_RTTI 195854b409fdSHoward Hinnant 1959c003db1fSHoward Hinnanttemplate <class _Rp, class... _ArgTypes> 19603e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 19613e519524SHoward Hinnantbool 1962c003db1fSHoward Hinnantoperator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} 19633e519524SHoward Hinnant 1964c003db1fSHoward Hinnanttemplate <class _Rp, class... _ArgTypes> 19653e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 19663e519524SHoward Hinnantbool 1967c003db1fSHoward Hinnantoperator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} 19683e519524SHoward Hinnant 1969c003db1fSHoward Hinnanttemplate <class _Rp, class... _ArgTypes> 19703e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 19713e519524SHoward Hinnantbool 1972c003db1fSHoward Hinnantoperator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} 19733e519524SHoward Hinnant 1974c003db1fSHoward Hinnanttemplate <class _Rp, class... _ArgTypes> 19753e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 19763e519524SHoward Hinnantbool 1977c003db1fSHoward Hinnantoperator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} 19783e519524SHoward Hinnant 1979c003db1fSHoward Hinnanttemplate <class _Rp, class... _ArgTypes> 19803e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 19813e519524SHoward Hinnantvoid 1982c003db1fSHoward Hinnantswap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT 19833e519524SHoward Hinnant{return __x.swap(__y);} 19843e519524SHoward Hinnant 19857e23afcbSEric Fiselier#else // _LIBCPP_CXX03_LANG 198600f512ebSEric Fiselier 198700f512ebSEric Fiselier#include <__functional_03> 198800f512ebSEric Fiselier 198900f512ebSEric Fiselier#endif 1990e5407178SEric Fiselier 1991e5407178SEric Fiselier//////////////////////////////////////////////////////////////////////////////// 1992e5407178SEric Fiselier// BIND 1993e5407178SEric Fiselier//============================================================================== 1994e5407178SEric Fiselier 19953e519524SHoward Hinnanttemplate<class _Tp> struct __is_bind_expression : public false_type {}; 1996e2f2d1edSEric Fiseliertemplate<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression 19973e519524SHoward Hinnant : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; 19983e519524SHoward Hinnant 1999a48055ceSMarshall Clow#if _LIBCPP_STD_VER > 14 2000a48055ceSMarshall Clowtemplate <class _Tp> 200140a01d53SMarshall Clow_LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; 2002a48055ceSMarshall Clow#endif 2003a48055ceSMarshall Clow 20043e519524SHoward Hinnanttemplate<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; 2005e2f2d1edSEric Fiseliertemplate<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder 20063e519524SHoward Hinnant : public __is_placeholder<typename remove_cv<_Tp>::type> {}; 20073e519524SHoward Hinnant 2008a48055ceSMarshall Clow#if _LIBCPP_STD_VER > 14 2009a48055ceSMarshall Clowtemplate <class _Tp> 201040a01d53SMarshall Clow_LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; 2011a48055ceSMarshall Clow#endif 2012a48055ceSMarshall Clow 20133e519524SHoward Hinnantnamespace placeholders 20143e519524SHoward Hinnant{ 20153e519524SHoward Hinnant 2016c003db1fSHoward Hinnanttemplate <int _Np> struct __ph {}; 20173e519524SHoward Hinnant 2018c8e84ff2SLouis Dionne#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) 201955533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<1> _1; 202055533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<2> _2; 202155533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<3> _3; 202255533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<4> _4; 202355533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<5> _5; 202455533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<6> _6; 202555533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<7> _7; 202655533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<8> _8; 202755533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<9> _9; 202855533071SEric Fiselier_LIBCPP_FUNC_VIS extern const __ph<10> _10; 202955533071SEric Fiselier#else 2030a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{}; 2031a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{}; 2032a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{}; 2033a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{}; 2034a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{}; 2035a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{}; 2036a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{}; 2037a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{}; 2038a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{}; 2039a911f39dSMarshall Clow/* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{}; 2040c8e84ff2SLouis Dionne#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) 20413e519524SHoward Hinnant 20423e519524SHoward Hinnant} // placeholders 20433e519524SHoward Hinnant 2044c003db1fSHoward Hinnanttemplate<int _Np> 2045c003db1fSHoward Hinnantstruct __is_placeholder<placeholders::__ph<_Np> > 2046c003db1fSHoward Hinnant : public integral_constant<int, _Np> {}; 20473e519524SHoward Hinnant 2048e5407178SEric Fiselier 20497e23afcbSEric Fiselier#ifndef _LIBCPP_CXX03_LANG 2050e5407178SEric Fiselier 20513e519524SHoward Hinnanttemplate <class _Tp, class _Uj> 20523e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 20533e519524SHoward Hinnant_Tp& 20543e519524SHoward Hinnant__mu(reference_wrapper<_Tp> __t, _Uj&) 20553e519524SHoward Hinnant{ 20563e519524SHoward Hinnant return __t.get(); 20573e519524SHoward Hinnant} 20583e519524SHoward Hinnant 20593e519524SHoward Hinnanttemplate <class _Ti, class ..._Uj, size_t ..._Indx> 20603e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 20612344d6c1SHoward Hinnanttypename __invoke_of<_Ti&, _Uj...>::type 20622344d6c1SHoward Hinnant__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) 20633e519524SHoward Hinnant{ 2064f9af6140SMarshall Clow return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); 20653e519524SHoward Hinnant} 20663e519524SHoward Hinnant 20673e519524SHoward Hinnanttemplate <class _Ti, class ..._Uj> 20683e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 2069279663c1SEric Fiseliertypename __lazy_enable_if 20703e519524SHoward Hinnant< 20713e519524SHoward Hinnant is_bind_expression<_Ti>::value, 2072279663c1SEric Fiselier __invoke_of<_Ti&, _Uj...> 20733e519524SHoward Hinnant>::type 20743e519524SHoward Hinnant__mu(_Ti& __ti, tuple<_Uj...>& __uj) 20753e519524SHoward Hinnant{ 20763e519524SHoward Hinnant typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; 20773e519524SHoward Hinnant return __mu_expand(__ti, __uj, __indices()); 20783e519524SHoward Hinnant} 20793e519524SHoward Hinnant 20803e519524SHoward Hinnanttemplate <bool IsPh, class _Ti, class _Uj> 20813e519524SHoward Hinnantstruct __mu_return2 {}; 20823e519524SHoward Hinnant 20833e519524SHoward Hinnanttemplate <class _Ti, class _Uj> 20843e519524SHoward Hinnantstruct __mu_return2<true, _Ti, _Uj> 20853e519524SHoward Hinnant{ 20863e519524SHoward Hinnant typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; 20873e519524SHoward Hinnant}; 20883e519524SHoward Hinnant 20893e519524SHoward Hinnanttemplate <class _Ti, class _Uj> 20903e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 20913e519524SHoward Hinnanttypename enable_if 20923e519524SHoward Hinnant< 20933e519524SHoward Hinnant 0 < is_placeholder<_Ti>::value, 20943e519524SHoward Hinnant typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type 20953e519524SHoward Hinnant>::type 20963e519524SHoward Hinnant__mu(_Ti&, _Uj& __uj) 20973e519524SHoward Hinnant{ 20983e519524SHoward Hinnant const size_t _Indx = is_placeholder<_Ti>::value - 1; 2099f9af6140SMarshall Clow return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj)); 21003e519524SHoward Hinnant} 21013e519524SHoward Hinnant 21023e519524SHoward Hinnanttemplate <class _Ti, class _Uj> 21033e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 21043e519524SHoward Hinnanttypename enable_if 21053e519524SHoward Hinnant< 21063e519524SHoward Hinnant !is_bind_expression<_Ti>::value && 21073e519524SHoward Hinnant is_placeholder<_Ti>::value == 0 && 21083e519524SHoward Hinnant !__is_reference_wrapper<_Ti>::value, 21093e519524SHoward Hinnant _Ti& 21103e519524SHoward Hinnant>::type 2111c206366fSHoward Hinnant__mu(_Ti& __ti, _Uj&) 21123e519524SHoward Hinnant{ 21133e519524SHoward Hinnant return __ti; 21143e519524SHoward Hinnant} 21153e519524SHoward Hinnant 21162fa07ae9SHoward Hinnanttemplate <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, 21172fa07ae9SHoward Hinnant class _TupleUj> 21180805a4faSLouis Dionnestruct __mu_return_impl; 21193e519524SHoward Hinnant 21209bf42533SHoward Hinnanttemplate <bool _Invokable, class _Ti, class ..._Uj> 21210805a4faSLouis Dionnestruct __mu_return_invokable // false 21229bf42533SHoward Hinnant{ 21239bf42533SHoward Hinnant typedef __nat type; 21249bf42533SHoward Hinnant}; 21259bf42533SHoward Hinnant 21263e519524SHoward Hinnanttemplate <class _Ti, class ..._Uj> 21270805a4faSLouis Dionnestruct __mu_return_invokable<true, _Ti, _Uj...> 21283e519524SHoward Hinnant{ 21292344d6c1SHoward Hinnant typedef typename __invoke_of<_Ti&, _Uj...>::type type; 21303e519524SHoward Hinnant}; 21313e519524SHoward Hinnant 21329bf42533SHoward Hinnanttemplate <class _Ti, class ..._Uj> 21330805a4faSLouis Dionnestruct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> > 21340805a4faSLouis Dionne : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> 21359bf42533SHoward Hinnant{ 21369bf42533SHoward Hinnant}; 21379bf42533SHoward Hinnant 21383e519524SHoward Hinnanttemplate <class _Ti, class _TupleUj> 21390805a4faSLouis Dionnestruct __mu_return_impl<_Ti, false, false, true, _TupleUj> 21403e519524SHoward Hinnant{ 21413e519524SHoward Hinnant typedef typename tuple_element<is_placeholder<_Ti>::value - 1, 21423e519524SHoward Hinnant _TupleUj>::type&& type; 21433e519524SHoward Hinnant}; 21443e519524SHoward Hinnant 21453e519524SHoward Hinnanttemplate <class _Ti, class _TupleUj> 21460805a4faSLouis Dionnestruct __mu_return_impl<_Ti, true, false, false, _TupleUj> 21472fa07ae9SHoward Hinnant{ 21482fa07ae9SHoward Hinnant typedef typename _Ti::type& type; 21492fa07ae9SHoward Hinnant}; 21502fa07ae9SHoward Hinnant 21512fa07ae9SHoward Hinnanttemplate <class _Ti, class _TupleUj> 21520805a4faSLouis Dionnestruct __mu_return_impl<_Ti, false, false, false, _TupleUj> 21533e519524SHoward Hinnant{ 21543e519524SHoward Hinnant typedef _Ti& type; 21553e519524SHoward Hinnant}; 21563e519524SHoward Hinnant 21573e519524SHoward Hinnanttemplate <class _Ti, class _TupleUj> 21583e519524SHoward Hinnantstruct __mu_return 21590805a4faSLouis Dionne : public __mu_return_impl<_Ti, 21602fa07ae9SHoward Hinnant __is_reference_wrapper<_Ti>::value, 21613e519524SHoward Hinnant is_bind_expression<_Ti>::value, 2162c0c9748cSHoward Hinnant 0 < is_placeholder<_Ti>::value && 2163c0c9748cSHoward Hinnant is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, 21643e519524SHoward Hinnant _TupleUj> 21653e519524SHoward Hinnant{ 21663e519524SHoward Hinnant}; 21673e519524SHoward Hinnant 2168c003db1fSHoward Hinnanttemplate <class _Fp, class _BoundArgs, class _TupleUj> 216935cb2b28SEric Fiselierstruct __is_valid_bind_return 2170c0c9748cSHoward Hinnant{ 2171c0c9748cSHoward Hinnant static const bool value = false; 2172c0c9748cSHoward Hinnant}; 2173c0c9748cSHoward Hinnant 2174c0c9748cSHoward Hinnanttemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 217535cb2b28SEric Fiselierstruct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> 2176c0c9748cSHoward Hinnant{ 2177c0c9748cSHoward Hinnant static const bool value = __invokable<_Fp, 2178c0c9748cSHoward Hinnant typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; 2179c0c9748cSHoward Hinnant}; 2180c0c9748cSHoward Hinnant 2181c0c9748cSHoward Hinnanttemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 218235cb2b28SEric Fiselierstruct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> 2183c0c9748cSHoward Hinnant{ 2184c0c9748cSHoward Hinnant static const bool value = __invokable<_Fp, 2185c0c9748cSHoward Hinnant typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; 2186c0c9748cSHoward Hinnant}; 2187c0c9748cSHoward Hinnant 2188c0c9748cSHoward Hinnanttemplate <class _Fp, class _BoundArgs, class _TupleUj, 218935cb2b28SEric Fiselier bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> 21903e519524SHoward Hinnantstruct __bind_return; 21913e519524SHoward Hinnant 2192c003db1fSHoward Hinnanttemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 2193c0c9748cSHoward Hinnantstruct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> 21943e519524SHoward Hinnant{ 21952344d6c1SHoward Hinnant typedef typename __invoke_of 21963e519524SHoward Hinnant < 2197c003db1fSHoward Hinnant _Fp&, 21983e519524SHoward Hinnant typename __mu_return 21993e519524SHoward Hinnant < 22003e519524SHoward Hinnant _BoundArgs, 22013e519524SHoward Hinnant _TupleUj 22023e519524SHoward Hinnant >::type... 22033e519524SHoward Hinnant >::type type; 22043e519524SHoward Hinnant}; 22053e519524SHoward Hinnant 2206c003db1fSHoward Hinnanttemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 2207c0c9748cSHoward Hinnantstruct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> 22083e519524SHoward Hinnant{ 22092344d6c1SHoward Hinnant typedef typename __invoke_of 22103e519524SHoward Hinnant < 2211c003db1fSHoward Hinnant _Fp&, 22123e519524SHoward Hinnant typename __mu_return 22133e519524SHoward Hinnant < 22143e519524SHoward Hinnant const _BoundArgs, 22153e519524SHoward Hinnant _TupleUj 22163e519524SHoward Hinnant >::type... 22173e519524SHoward Hinnant >::type type; 22183e519524SHoward Hinnant}; 22193e519524SHoward Hinnant 2220c003db1fSHoward Hinnanttemplate <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> 22213e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 2222c003db1fSHoward Hinnanttypename __bind_return<_Fp, _BoundArgs, _Args>::type 2223c003db1fSHoward Hinnant__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, 22243e519524SHoward Hinnant _Args&& __args) 22253e519524SHoward Hinnant{ 22261f8b73d1SEric Fiselier return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...); 22273e519524SHoward Hinnant} 22283e519524SHoward Hinnant 2229c003db1fSHoward Hinnanttemplate<class _Fp, class ..._BoundArgs> 22303e519524SHoward Hinnantclass __bind 2231c003db1fSHoward Hinnant : public __weak_result_type<typename decay<_Fp>::type> 22323e519524SHoward Hinnant{ 2233c0c9748cSHoward Hinnantprotected: 2234c003db1fSHoward Hinnant typedef typename decay<_Fp>::type _Fd; 22352344d6c1SHoward Hinnant typedef tuple<typename decay<_BoundArgs>::type...> _Td; 2236c0c9748cSHoward Hinnantprivate: 22372344d6c1SHoward Hinnant _Fd __f_; 22382344d6c1SHoward Hinnant _Td __bound_args_; 22393e519524SHoward Hinnant 22403e519524SHoward Hinnant typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; 22413e519524SHoward Hinnantpublic: 2242df7aad41SHoward Hinnant template <class _Gp, class ..._BA, 2243df7aad41SHoward Hinnant class = typename enable_if 2244df7aad41SHoward Hinnant < 22459dbbf8deSHoward Hinnant is_constructible<_Fd, _Gp>::value && 22469dbbf8deSHoward Hinnant !is_same<typename remove_reference<_Gp>::type, 22479dbbf8deSHoward Hinnant __bind>::value 2248df7aad41SHoward Hinnant >::type> 22490af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2250c003db1fSHoward Hinnant explicit __bind(_Gp&& __f, _BA&& ...__bound_args) 2251c003db1fSHoward Hinnant : __f_(_VSTD::forward<_Gp>(__f)), 2252ce48a113SHoward Hinnant __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} 22533e519524SHoward Hinnant 22543e519524SHoward Hinnant template <class ..._Args> 22550af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 22562344d6c1SHoward Hinnant typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 22573e519524SHoward Hinnant operator()(_Args&& ...__args) 22583e519524SHoward Hinnant { 22591f8b73d1SEric Fiselier return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), 2260ce48a113SHoward Hinnant tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 22613e519524SHoward Hinnant } 22623e519524SHoward Hinnant 22633e519524SHoward Hinnant template <class ..._Args> 22640af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2265c0c9748cSHoward Hinnant typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type 22663e519524SHoward Hinnant operator()(_Args&& ...__args) const 22673e519524SHoward Hinnant { 22681f8b73d1SEric Fiselier return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), 2269ce48a113SHoward Hinnant tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 22703e519524SHoward Hinnant } 22713e519524SHoward Hinnant}; 22723e519524SHoward Hinnant 2273c003db1fSHoward Hinnanttemplate<class _Fp, class ..._BoundArgs> 2274c003db1fSHoward Hinnantstruct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; 22753e519524SHoward Hinnant 2276c003db1fSHoward Hinnanttemplate<class _Rp, class _Fp, class ..._BoundArgs> 22773e519524SHoward Hinnantclass __bind_r 2278c003db1fSHoward Hinnant : public __bind<_Fp, _BoundArgs...> 22793e519524SHoward Hinnant{ 2280c003db1fSHoward Hinnant typedef __bind<_Fp, _BoundArgs...> base; 2281c0c9748cSHoward Hinnant typedef typename base::_Fd _Fd; 2282c0c9748cSHoward Hinnant typedef typename base::_Td _Td; 22833e519524SHoward Hinnantpublic: 2284c003db1fSHoward Hinnant typedef _Rp result_type; 22853e519524SHoward Hinnant 2286086d0de1SHoward Hinnant 22879dbbf8deSHoward Hinnant template <class _Gp, class ..._BA, 22889dbbf8deSHoward Hinnant class = typename enable_if 22899dbbf8deSHoward Hinnant < 22909dbbf8deSHoward Hinnant is_constructible<_Fd, _Gp>::value && 22919dbbf8deSHoward Hinnant !is_same<typename remove_reference<_Gp>::type, 22929dbbf8deSHoward Hinnant __bind_r>::value 22939dbbf8deSHoward Hinnant >::type> 22940af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2295c003db1fSHoward Hinnant explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) 2296c003db1fSHoward Hinnant : base(_VSTD::forward<_Gp>(__f), 2297ce48a113SHoward Hinnant _VSTD::forward<_BA>(__bound_args)...) {} 22983e519524SHoward Hinnant 22993e519524SHoward Hinnant template <class ..._Args> 23000af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2301c0c9748cSHoward Hinnant typename enable_if 2302c0c9748cSHoward Hinnant < 2303c0c9748cSHoward Hinnant is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, 23042d15f15fSEric Fiselier result_type>::value || is_void<_Rp>::value, 23053e519524SHoward Hinnant result_type 2306c0c9748cSHoward Hinnant >::type 23073e519524SHoward Hinnant operator()(_Args&& ...__args) 23083e519524SHoward Hinnant { 23092d15f15fSEric Fiselier typedef __invoke_void_return_wrapper<_Rp> _Invoker; 23102d15f15fSEric Fiselier return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...); 23113e519524SHoward Hinnant } 23123e519524SHoward Hinnant 23133e519524SHoward Hinnant template <class ..._Args> 23140af133f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2315c0c9748cSHoward Hinnant typename enable_if 2316c0c9748cSHoward Hinnant < 2317c0c9748cSHoward Hinnant is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, 23182d15f15fSEric Fiselier result_type>::value || is_void<_Rp>::value, 23193e519524SHoward Hinnant result_type 2320c0c9748cSHoward Hinnant >::type 23213e519524SHoward Hinnant operator()(_Args&& ...__args) const 23223e519524SHoward Hinnant { 23232d15f15fSEric Fiselier typedef __invoke_void_return_wrapper<_Rp> _Invoker; 23242d15f15fSEric Fiselier return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...); 23253e519524SHoward Hinnant } 23263e519524SHoward Hinnant}; 23273e519524SHoward Hinnant 2328c003db1fSHoward Hinnanttemplate<class _Rp, class _Fp, class ..._BoundArgs> 2329c003db1fSHoward Hinnantstruct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; 23303e519524SHoward Hinnant 2331c003db1fSHoward Hinnanttemplate<class _Fp, class ..._BoundArgs> 23323e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 2333c003db1fSHoward Hinnant__bind<_Fp, _BoundArgs...> 2334c003db1fSHoward Hinnantbind(_Fp&& __f, _BoundArgs&&... __bound_args) 23353e519524SHoward Hinnant{ 2336c003db1fSHoward Hinnant typedef __bind<_Fp, _BoundArgs...> type; 2337c003db1fSHoward Hinnant return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 23383e519524SHoward Hinnant} 23393e519524SHoward Hinnant 2340c003db1fSHoward Hinnanttemplate<class _Rp, class _Fp, class ..._BoundArgs> 23413e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 2342c003db1fSHoward Hinnant__bind_r<_Rp, _Fp, _BoundArgs...> 2343c003db1fSHoward Hinnantbind(_Fp&& __f, _BoundArgs&&... __bound_args) 23443e519524SHoward Hinnant{ 2345c003db1fSHoward Hinnant typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; 2346c003db1fSHoward Hinnant return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 23473e519524SHoward Hinnant} 23483e519524SHoward Hinnant 23497e23afcbSEric Fiselier#endif // _LIBCPP_CXX03_LANG 23503e519524SHoward Hinnant 23515be45129SEric Fiselier#if _LIBCPP_STD_VER > 14 235257257567SEric Fiselier 23535be45129SEric Fiseliertemplate <class _Fn, class ..._Args> 23545be45129SEric Fiselierresult_of_t<_Fn&&(_Args&&...)> 235557257567SEric Fiselierinvoke(_Fn&& __f, _Args&&... __args) 235657257567SEric Fiselier noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...))) 235757257567SEric Fiselier{ 235857257567SEric Fiselier return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); 23595be45129SEric Fiselier} 236057257567SEric Fiselier 236157257567SEric Fiseliertemplate <class _DecayFunc> 2362e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS __not_fn_imp { 236357257567SEric Fiselier _DecayFunc __fd; 236457257567SEric Fiselier 236557257567SEric Fiselierpublic: 236657257567SEric Fiselier __not_fn_imp() = delete; 236757257567SEric Fiselier 236857257567SEric Fiselier template <class ..._Args> 236957257567SEric Fiselier _LIBCPP_INLINE_VISIBILITY 23709372d8bcSEric Fiselier auto operator()(_Args&& ...__args) & 237157257567SEric Fiselier noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))) 237257257567SEric Fiselier -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)) 237357257567SEric Fiselier { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); } 237457257567SEric Fiselier 237557257567SEric Fiselier template <class ..._Args> 237657257567SEric Fiselier _LIBCPP_INLINE_VISIBILITY 23779372d8bcSEric Fiselier auto operator()(_Args&& ...__args) && 23789372d8bcSEric Fiselier noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))) 23799372d8bcSEric Fiselier -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)) 23809372d8bcSEric Fiselier { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); } 23819372d8bcSEric Fiselier 23829372d8bcSEric Fiselier template <class ..._Args> 23839372d8bcSEric Fiselier _LIBCPP_INLINE_VISIBILITY 23849372d8bcSEric Fiselier auto operator()(_Args&& ...__args) const& 238557257567SEric Fiselier noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))) 238657257567SEric Fiselier -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)) 238757257567SEric Fiselier { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); } 238857257567SEric Fiselier 23899372d8bcSEric Fiselier 23909372d8bcSEric Fiselier template <class ..._Args> 23919372d8bcSEric Fiselier _LIBCPP_INLINE_VISIBILITY 23929372d8bcSEric Fiselier auto operator()(_Args&& ...__args) const&& 23939372d8bcSEric Fiselier noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))) 23949372d8bcSEric Fiselier -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)) 23959372d8bcSEric Fiselier { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); } 23969372d8bcSEric Fiselier 239757257567SEric Fiselierprivate: 239857257567SEric Fiselier template <class _RawFunc, 239957257567SEric Fiselier class = enable_if_t<!is_same<decay_t<_RawFunc>, __not_fn_imp>::value>> 240057257567SEric Fiselier _LIBCPP_INLINE_VISIBILITY 240157257567SEric Fiselier explicit __not_fn_imp(_RawFunc&& __rf) 240257257567SEric Fiselier : __fd(_VSTD::forward<_RawFunc>(__rf)) {} 240357257567SEric Fiselier 240457257567SEric Fiselier template <class _RawFunc> 240557257567SEric Fiselier friend inline _LIBCPP_INLINE_VISIBILITY 240657257567SEric Fiselier __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&&); 240757257567SEric Fiselier}; 240857257567SEric Fiselier 240957257567SEric Fiseliertemplate <class _RawFunc> 241057257567SEric Fiselierinline _LIBCPP_INLINE_VISIBILITY 241157257567SEric Fiselier__not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) { 241257257567SEric Fiselier return __not_fn_imp<decay_t<_RawFunc>>(_VSTD::forward<_RawFunc>(__fn)); 241357257567SEric Fiselier} 241457257567SEric Fiselier 24155be45129SEric Fiselier#endif 24165be45129SEric Fiselier 2417d1803b6cSHoward Hinnant// struct hash<T*> in <memory> 24183e519524SHoward Hinnant 2419d835e592SMarshall Clowtemplate <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2> 242012f0a779SMarshall Clowpair<_ForwardIterator1, _ForwardIterator1> _LIBCPP_CONSTEXPR_AFTER_CXX11 2421d835e592SMarshall Clow__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, 2422d835e592SMarshall Clow _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred, 2423d835e592SMarshall Clow forward_iterator_tag, forward_iterator_tag) 2424d835e592SMarshall Clow{ 2425d835e592SMarshall Clow if (__first2 == __last2) 2426d835e592SMarshall Clow return make_pair(__first1, __first1); // Everything matches an empty sequence 2427d835e592SMarshall Clow while (true) 2428d835e592SMarshall Clow { 2429d835e592SMarshall Clow // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks 2430d835e592SMarshall Clow while (true) 2431d835e592SMarshall Clow { 2432d835e592SMarshall Clow if (__first1 == __last1) // return __last1 if no element matches *__first2 2433d835e592SMarshall Clow return make_pair(__last1, __last1); 2434d835e592SMarshall Clow if (__pred(*__first1, *__first2)) 2435d835e592SMarshall Clow break; 2436d835e592SMarshall Clow ++__first1; 2437d835e592SMarshall Clow } 2438d835e592SMarshall Clow // *__first1 matches *__first2, now match elements after here 2439d835e592SMarshall Clow _ForwardIterator1 __m1 = __first1; 2440d835e592SMarshall Clow _ForwardIterator2 __m2 = __first2; 2441d835e592SMarshall Clow while (true) 2442d835e592SMarshall Clow { 2443d835e592SMarshall Clow if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern) 2444d835e592SMarshall Clow return make_pair(__first1, __m1); 2445d835e592SMarshall Clow if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found 2446d835e592SMarshall Clow return make_pair(__last1, __last1); 2447d835e592SMarshall Clow if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1 2448d835e592SMarshall Clow { 2449d835e592SMarshall Clow ++__first1; 2450d835e592SMarshall Clow break; 2451d835e592SMarshall Clow } // else there is a match, check next elements 2452d835e592SMarshall Clow } 2453d835e592SMarshall Clow } 2454d835e592SMarshall Clow} 2455d835e592SMarshall Clow 2456d835e592SMarshall Clowtemplate <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2> 2457d835e592SMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 2458d835e592SMarshall Clowpair<_RandomAccessIterator1, _RandomAccessIterator1> 2459d835e592SMarshall Clow__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, 2460d835e592SMarshall Clow _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, 2461d835e592SMarshall Clow random_access_iterator_tag, random_access_iterator_tag) 2462d835e592SMarshall Clow{ 2463d835e592SMarshall Clow typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1; 2464d835e592SMarshall Clow typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2; 2465d835e592SMarshall Clow // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern 2466d835e592SMarshall Clow const _D2 __len2 = __last2 - __first2; 2467d835e592SMarshall Clow if (__len2 == 0) 2468d835e592SMarshall Clow return make_pair(__first1, __first1); 2469d835e592SMarshall Clow const _D1 __len1 = __last1 - __first1; 2470d835e592SMarshall Clow if (__len1 < __len2) 2471d835e592SMarshall Clow return make_pair(__last1, __last1); 2472d835e592SMarshall Clow const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here 2473d835e592SMarshall Clow 2474d835e592SMarshall Clow while (true) 2475d835e592SMarshall Clow { 2476d835e592SMarshall Clow while (true) 2477d835e592SMarshall Clow { 2478d835e592SMarshall Clow if (__first1 == __s) 2479d835e592SMarshall Clow return make_pair(__last1, __last1); 2480d835e592SMarshall Clow if (__pred(*__first1, *__first2)) 2481d835e592SMarshall Clow break; 2482d835e592SMarshall Clow ++__first1; 2483d835e592SMarshall Clow } 2484d835e592SMarshall Clow 2485d835e592SMarshall Clow _RandomAccessIterator1 __m1 = __first1; 2486d835e592SMarshall Clow _RandomAccessIterator2 __m2 = __first2; 2487d835e592SMarshall Clow while (true) 2488d835e592SMarshall Clow { 2489d835e592SMarshall Clow if (++__m2 == __last2) 2490d835e592SMarshall Clow return make_pair(__first1, __first1 + __len2); 2491d835e592SMarshall Clow ++__m1; // no need to check range on __m1 because __s guarantees we have enough source 2492d835e592SMarshall Clow if (!__pred(*__m1, *__m2)) 2493d835e592SMarshall Clow { 2494d835e592SMarshall Clow ++__first1; 2495d835e592SMarshall Clow break; 2496d835e592SMarshall Clow } 2497d835e592SMarshall Clow } 2498d835e592SMarshall Clow } 2499d835e592SMarshall Clow} 2500d835e592SMarshall Clow 2501d835e592SMarshall Clow#if _LIBCPP_STD_VER > 14 2502d835e592SMarshall Clow 2503d835e592SMarshall Clow// default searcher 2504d835e592SMarshall Clowtemplate<class _ForwardIterator, class _BinaryPredicate = equal_to<>> 25051b1b80f4SDimitry Andricclass _LIBCPP_TYPE_VIS default_searcher { 2506d835e592SMarshall Clowpublic: 2507d835e592SMarshall Clow _LIBCPP_INLINE_VISIBILITY 2508d835e592SMarshall Clow default_searcher(_ForwardIterator __f, _ForwardIterator __l, 2509d835e592SMarshall Clow _BinaryPredicate __p = _BinaryPredicate()) 2510d835e592SMarshall Clow : __first_(__f), __last_(__l), __pred_(__p) {} 2511d835e592SMarshall Clow 2512d835e592SMarshall Clow template <typename _ForwardIterator2> 2513d835e592SMarshall Clow _LIBCPP_INLINE_VISIBILITY 2514d835e592SMarshall Clow pair<_ForwardIterator2, _ForwardIterator2> 2515d835e592SMarshall Clow operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const 2516d835e592SMarshall Clow { 2517d835e592SMarshall Clow return _VSTD::__search(__f, __l, __first_, __last_, __pred_, 2518d835e592SMarshall Clow typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(), 2519d835e592SMarshall Clow typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category()); 2520d835e592SMarshall Clow } 2521d835e592SMarshall Clow 2522d835e592SMarshall Clowprivate: 2523d835e592SMarshall Clow _ForwardIterator __first_; 2524d835e592SMarshall Clow _ForwardIterator __last_; 2525d835e592SMarshall Clow _BinaryPredicate __pred_; 2526d835e592SMarshall Clow }; 2527d835e592SMarshall Clow 2528d835e592SMarshall Clow#endif // _LIBCPP_STD_VER > 14 2529d835e592SMarshall Clow 25303e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 25313e519524SHoward Hinnant 25323e519524SHoward Hinnant#endif // _LIBCPP_FUNCTIONAL 2533