xref: /minix3/external/bsd/libc++/dist/libcxx/include/functional (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
14684ddb6SLionel Sambuc// -*- C++ -*-
24684ddb6SLionel Sambuc//===------------------------ functional ----------------------------------===//
34684ddb6SLionel Sambuc//
44684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
54684ddb6SLionel Sambuc//
64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
84684ddb6SLionel Sambuc//
94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
104684ddb6SLionel Sambuc
114684ddb6SLionel Sambuc#ifndef _LIBCPP_FUNCTIONAL
124684ddb6SLionel Sambuc#define _LIBCPP_FUNCTIONAL
134684ddb6SLionel Sambuc
144684ddb6SLionel Sambuc/*
154684ddb6SLionel Sambuc    functional synopsis
164684ddb6SLionel Sambuc
174684ddb6SLionel Sambucnamespace std
184684ddb6SLionel Sambuc{
194684ddb6SLionel Sambuc
204684ddb6SLionel Sambuctemplate <class Arg, class Result>
214684ddb6SLionel Sambucstruct unary_function
224684ddb6SLionel Sambuc{
234684ddb6SLionel Sambuc    typedef Arg    argument_type;
244684ddb6SLionel Sambuc    typedef Result result_type;
254684ddb6SLionel Sambuc};
264684ddb6SLionel Sambuc
274684ddb6SLionel Sambuctemplate <class Arg1, class Arg2, class Result>
284684ddb6SLionel Sambucstruct binary_function
294684ddb6SLionel Sambuc{
304684ddb6SLionel Sambuc    typedef Arg1   first_argument_type;
314684ddb6SLionel Sambuc    typedef Arg2   second_argument_type;
324684ddb6SLionel Sambuc    typedef Result result_type;
334684ddb6SLionel Sambuc};
344684ddb6SLionel Sambuc
354684ddb6SLionel Sambuctemplate <class T>
364684ddb6SLionel Sambucclass reference_wrapper
374684ddb6SLionel Sambuc    : public unary_function<T1, R> // if wrapping a unary functor
384684ddb6SLionel Sambuc    : public binary_function<T1, T2, R> // if wraping a binary functor
394684ddb6SLionel Sambuc{
404684ddb6SLionel Sambucpublic:
414684ddb6SLionel Sambuc    // types
424684ddb6SLionel Sambuc    typedef T type;
434684ddb6SLionel Sambuc    typedef see below result_type; // Not always defined
444684ddb6SLionel Sambuc
454684ddb6SLionel Sambuc    // construct/copy/destroy
464684ddb6SLionel Sambuc    reference_wrapper(T&) noexcept;
474684ddb6SLionel Sambuc    reference_wrapper(T&&) = delete; // do not bind to temps
484684ddb6SLionel Sambuc    reference_wrapper(const reference_wrapper<T>& x) noexcept;
494684ddb6SLionel Sambuc
504684ddb6SLionel Sambuc    // assignment
514684ddb6SLionel Sambuc    reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;
524684ddb6SLionel Sambuc
534684ddb6SLionel Sambuc    // access
544684ddb6SLionel Sambuc    operator T& () const noexcept;
554684ddb6SLionel Sambuc    T& get() const noexcept;
564684ddb6SLionel Sambuc
574684ddb6SLionel Sambuc    // invoke
584684ddb6SLionel Sambuc    template <class... ArgTypes>
594684ddb6SLionel Sambuc      typename result_of<T&(ArgTypes&&...)>::type
604684ddb6SLionel Sambuc          operator() (ArgTypes&&...) const;
614684ddb6SLionel Sambuc};
624684ddb6SLionel Sambuc
634684ddb6SLionel Sambuctemplate <class T> reference_wrapper<T> ref(T& t) noexcept;
644684ddb6SLionel Sambuctemplate <class T> void ref(const T&& t) = delete;
654684ddb6SLionel Sambuctemplate <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;
664684ddb6SLionel Sambuc
674684ddb6SLionel Sambuctemplate <class T> reference_wrapper<const T> cref(const T& t) noexcept;
684684ddb6SLionel Sambuctemplate <class T> void cref(const T&& t) = delete;
694684ddb6SLionel Sambuctemplate <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
704684ddb6SLionel Sambuc
714684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
724684ddb6SLionel Sambucstruct plus : binary_function<T, T, T>
734684ddb6SLionel Sambuc{
744684ddb6SLionel Sambuc    T operator()(const T& x, const T& y) const;
754684ddb6SLionel Sambuc};
764684ddb6SLionel Sambuc
774684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
784684ddb6SLionel Sambucstruct minus : binary_function<T, T, T>
794684ddb6SLionel Sambuc{
804684ddb6SLionel Sambuc    T operator()(const T& x, const T& y) const;
814684ddb6SLionel Sambuc};
824684ddb6SLionel Sambuc
834684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
844684ddb6SLionel Sambucstruct multiplies : binary_function<T, T, T>
854684ddb6SLionel Sambuc{
864684ddb6SLionel Sambuc    T operator()(const T& x, const T& y) const;
874684ddb6SLionel Sambuc};
884684ddb6SLionel Sambuc
894684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
904684ddb6SLionel Sambucstruct divides : binary_function<T, T, T>
914684ddb6SLionel Sambuc{
924684ddb6SLionel Sambuc    T operator()(const T& x, const T& y) const;
934684ddb6SLionel Sambuc};
944684ddb6SLionel Sambuc
954684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
964684ddb6SLionel Sambucstruct modulus : binary_function<T, T, T>
974684ddb6SLionel Sambuc{
984684ddb6SLionel Sambuc    T operator()(const T& x, const T& y) const;
994684ddb6SLionel Sambuc};
1004684ddb6SLionel Sambuc
1014684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1024684ddb6SLionel Sambucstruct negate : unary_function<T, T>
1034684ddb6SLionel Sambuc{
1044684ddb6SLionel Sambuc    T operator()(const T& x) const;
1054684ddb6SLionel Sambuc};
1064684ddb6SLionel Sambuc
1074684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1084684ddb6SLionel Sambucstruct equal_to : binary_function<T, T, bool>
1094684ddb6SLionel Sambuc{
1104684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1114684ddb6SLionel Sambuc};
1124684ddb6SLionel Sambuc
1134684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1144684ddb6SLionel Sambucstruct not_equal_to : binary_function<T, T, bool>
1154684ddb6SLionel Sambuc{
1164684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1174684ddb6SLionel Sambuc};
1184684ddb6SLionel Sambuc
1194684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1204684ddb6SLionel Sambucstruct greater : binary_function<T, T, bool>
1214684ddb6SLionel Sambuc{
1224684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1234684ddb6SLionel Sambuc};
1244684ddb6SLionel Sambuc
1254684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1264684ddb6SLionel Sambucstruct less : binary_function<T, T, bool>
1274684ddb6SLionel Sambuc{
1284684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1294684ddb6SLionel Sambuc};
1304684ddb6SLionel Sambuc
1314684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1324684ddb6SLionel Sambucstruct greater_equal : binary_function<T, T, bool>
1334684ddb6SLionel Sambuc{
1344684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1354684ddb6SLionel Sambuc};
1364684ddb6SLionel Sambuc
1374684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1384684ddb6SLionel Sambucstruct less_equal : binary_function<T, T, bool>
1394684ddb6SLionel Sambuc{
1404684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1414684ddb6SLionel Sambuc};
1424684ddb6SLionel Sambuc
1434684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1444684ddb6SLionel Sambucstruct logical_and : binary_function<T, T, bool>
1454684ddb6SLionel Sambuc{
1464684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1474684ddb6SLionel Sambuc};
1484684ddb6SLionel Sambuc
1494684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1504684ddb6SLionel Sambucstruct logical_or : binary_function<T, T, bool>
1514684ddb6SLionel Sambuc{
1524684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1534684ddb6SLionel Sambuc};
1544684ddb6SLionel Sambuc
1554684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1564684ddb6SLionel Sambucstruct logical_not : unary_function<T, bool>
1574684ddb6SLionel Sambuc{
1584684ddb6SLionel Sambuc    bool operator()(const T& x) const;
1594684ddb6SLionel Sambuc};
1604684ddb6SLionel Sambuc
1614684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1624684ddb6SLionel Sambucstruct bit_and : unary_function<T, bool>
1634684ddb6SLionel Sambuc{
1644684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1654684ddb6SLionel Sambuc};
1664684ddb6SLionel Sambuc
1674684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1684684ddb6SLionel Sambucstruct bit_or : unary_function<T, bool>
1694684ddb6SLionel Sambuc{
1704684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1714684ddb6SLionel Sambuc};
1724684ddb6SLionel Sambuc
1734684ddb6SLionel Sambuctemplate <class T> // <class T=void> in C++14
1744684ddb6SLionel Sambucstruct bit_xor : unary_function<T, bool>
1754684ddb6SLionel Sambuc{
1764684ddb6SLionel Sambuc    bool operator()(const T& x, const T& y) const;
1774684ddb6SLionel Sambuc};
1784684ddb6SLionel Sambuc
1794684ddb6SLionel Sambuctemplate <class T=void> // C++14
1804684ddb6SLionel Sambucstruct bit_xor : unary_function<T, bool>
1814684ddb6SLionel Sambuc{
1824684ddb6SLionel Sambuc    bool operator()(const T& x) const;
1834684ddb6SLionel Sambuc};
1844684ddb6SLionel Sambuc
1854684ddb6SLionel Sambuctemplate <class Predicate>
1864684ddb6SLionel Sambucclass unary_negate
1874684ddb6SLionel Sambuc    : public unary_function<typename Predicate::argument_type, bool>
1884684ddb6SLionel Sambuc{
1894684ddb6SLionel Sambucpublic:
1904684ddb6SLionel Sambuc    explicit unary_negate(const Predicate& pred);
1914684ddb6SLionel Sambuc    bool operator()(const typename Predicate::argument_type& x) const;
1924684ddb6SLionel Sambuc};
1934684ddb6SLionel Sambuc
1944684ddb6SLionel Sambuctemplate <class Predicate> unary_negate<Predicate> not1(const Predicate& pred);
1954684ddb6SLionel Sambuc
1964684ddb6SLionel Sambuctemplate <class Predicate>
1974684ddb6SLionel Sambucclass binary_negate
1984684ddb6SLionel Sambuc    : public binary_function<typename Predicate::first_argument_type,
1994684ddb6SLionel Sambuc                             typename Predicate::second_argument_type,
2004684ddb6SLionel Sambuc                             bool>
2014684ddb6SLionel Sambuc{
2024684ddb6SLionel Sambucpublic:
2034684ddb6SLionel Sambuc    explicit binary_negate(const Predicate& pred);
2044684ddb6SLionel Sambuc    bool operator()(const typename Predicate::first_argument_type& x,
2054684ddb6SLionel Sambuc                    const typename Predicate::second_argument_type& y) const;
2064684ddb6SLionel Sambuc};
2074684ddb6SLionel Sambuc
2084684ddb6SLionel Sambuctemplate <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);
2094684ddb6SLionel Sambuc
2104684ddb6SLionel Sambuctemplate<class T> struct is_bind_expression;
2114684ddb6SLionel Sambuctemplate<class T> struct is_placeholder;
2124684ddb6SLionel Sambuc
2134684ddb6SLionel Sambuctemplate<class Fn, class... BoundArgs>
2144684ddb6SLionel Sambuc  unspecified bind(Fn&&, BoundArgs&&...);
2154684ddb6SLionel Sambuctemplate<class R, class Fn, class... BoundArgs>
2164684ddb6SLionel Sambuc  unspecified bind(Fn&&, BoundArgs&&...);
2174684ddb6SLionel Sambuc
2184684ddb6SLionel Sambucnamespace placeholders {
2194684ddb6SLionel Sambuc  // M is the implementation-defined number of placeholders
2204684ddb6SLionel Sambuc  extern unspecified _1;
2214684ddb6SLionel Sambuc  extern unspecified _2;
2224684ddb6SLionel Sambuc  .
2234684ddb6SLionel Sambuc  .
2244684ddb6SLionel Sambuc  .
2254684ddb6SLionel Sambuc  extern unspecified _Mp;
2264684ddb6SLionel Sambuc}
2274684ddb6SLionel Sambuc
2284684ddb6SLionel Sambuctemplate <class Operation>
2294684ddb6SLionel Sambucclass binder1st
2304684ddb6SLionel Sambuc    : public unary_function<typename Operation::second_argument_type,
2314684ddb6SLionel Sambuc                            typename Operation::result_type>
2324684ddb6SLionel Sambuc{
2334684ddb6SLionel Sambucprotected:
2344684ddb6SLionel Sambuc    Operation                               op;
2354684ddb6SLionel Sambuc    typename Operation::first_argument_type value;
2364684ddb6SLionel Sambucpublic:
2374684ddb6SLionel Sambuc    binder1st(const Operation& x, const typename Operation::first_argument_type y);
2384684ddb6SLionel Sambuc    typename Operation::result_type operator()(      typename Operation::second_argument_type& x) const;
2394684ddb6SLionel Sambuc    typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
2404684ddb6SLionel Sambuc};
2414684ddb6SLionel Sambuc
2424684ddb6SLionel Sambuctemplate <class Operation, class T>
2434684ddb6SLionel Sambucbinder1st<Operation> bind1st(const Operation& op, const T& x);
2444684ddb6SLionel Sambuc
2454684ddb6SLionel Sambuctemplate <class Operation>
2464684ddb6SLionel Sambucclass binder2nd
2474684ddb6SLionel Sambuc    : public unary_function<typename Operation::first_argument_type,
2484684ddb6SLionel Sambuc                            typename Operation::result_type>
2494684ddb6SLionel Sambuc{
2504684ddb6SLionel Sambucprotected:
2514684ddb6SLionel Sambuc    Operation                                op;
2524684ddb6SLionel Sambuc    typename Operation::second_argument_type value;
2534684ddb6SLionel Sambucpublic:
2544684ddb6SLionel Sambuc    binder2nd(const Operation& x, const typename Operation::second_argument_type y);
2554684ddb6SLionel Sambuc    typename Operation::result_type operator()(      typename Operation::first_argument_type& x) const;
2564684ddb6SLionel Sambuc    typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
2574684ddb6SLionel Sambuc};
2584684ddb6SLionel Sambuc
2594684ddb6SLionel Sambuctemplate <class Operation, class T>
2604684ddb6SLionel Sambucbinder2nd<Operation> bind2nd(const Operation& op, const T& x);
2614684ddb6SLionel Sambuc
2624684ddb6SLionel Sambuctemplate <class Arg, class Result>
2634684ddb6SLionel Sambucclass pointer_to_unary_function : public unary_function<Arg, Result>
2644684ddb6SLionel Sambuc{
2654684ddb6SLionel Sambucpublic:
2664684ddb6SLionel Sambuc    explicit pointer_to_unary_function(Result (*f)(Arg));
2674684ddb6SLionel Sambuc    Result operator()(Arg x) const;
2684684ddb6SLionel Sambuc};
2694684ddb6SLionel Sambuc
2704684ddb6SLionel Sambuctemplate <class Arg, class Result>
2714684ddb6SLionel Sambucpointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));
2724684ddb6SLionel Sambuc
2734684ddb6SLionel Sambuctemplate <class Arg1, class Arg2, class Result>
2744684ddb6SLionel Sambucclass pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
2754684ddb6SLionel Sambuc{
2764684ddb6SLionel Sambucpublic:
2774684ddb6SLionel Sambuc    explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
2784684ddb6SLionel Sambuc    Result operator()(Arg1 x, Arg2 y) const;
2794684ddb6SLionel Sambuc};
2804684ddb6SLionel Sambuc
2814684ddb6SLionel Sambuctemplate <class Arg1, class Arg2, class Result>
2824684ddb6SLionel Sambucpointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));
2834684ddb6SLionel Sambuc
2844684ddb6SLionel Sambuctemplate<class S, class T>
2854684ddb6SLionel Sambucclass mem_fun_t : public unary_function<T*, S>
2864684ddb6SLionel Sambuc{
2874684ddb6SLionel Sambucpublic:
2884684ddb6SLionel Sambuc    explicit mem_fun_t(S (T::*p)());
2894684ddb6SLionel Sambuc    S operator()(T* p) const;
2904684ddb6SLionel Sambuc};
2914684ddb6SLionel Sambuc
2924684ddb6SLionel Sambuctemplate<class S, class T, class A>
2934684ddb6SLionel Sambucclass mem_fun1_t : public binary_function<T*, A, S>
2944684ddb6SLionel Sambuc{
2954684ddb6SLionel Sambucpublic:
2964684ddb6SLionel Sambuc    explicit mem_fun1_t(S (T::*p)(A));
2974684ddb6SLionel Sambuc    S operator()(T* p, A x) const;
2984684ddb6SLionel Sambuc};
2994684ddb6SLionel Sambuc
3004684ddb6SLionel Sambuctemplate<class S, class T>          mem_fun_t<S,T>    mem_fun(S (T::*f)());
3014684ddb6SLionel Sambuctemplate<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
3024684ddb6SLionel Sambuc
3034684ddb6SLionel Sambuctemplate<class S, class T>
3044684ddb6SLionel Sambucclass mem_fun_ref_t : public unary_function<T, S>
3054684ddb6SLionel Sambuc{
3064684ddb6SLionel Sambucpublic:
3074684ddb6SLionel Sambuc    explicit mem_fun_ref_t(S (T::*p)());
3084684ddb6SLionel Sambuc    S operator()(T& p) const;
3094684ddb6SLionel Sambuc};
3104684ddb6SLionel Sambuc
3114684ddb6SLionel Sambuctemplate<class S, class T, class A>
3124684ddb6SLionel Sambucclass mem_fun1_ref_t : public binary_function<T, A, S>
3134684ddb6SLionel Sambuc{
3144684ddb6SLionel Sambucpublic:
3154684ddb6SLionel Sambuc    explicit mem_fun1_ref_t(S (T::*p)(A));
3164684ddb6SLionel Sambuc    S operator()(T& p, A x) const;
3174684ddb6SLionel Sambuc};
3184684ddb6SLionel Sambuc
3194684ddb6SLionel Sambuctemplate<class S, class T>          mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)());
3204684ddb6SLionel Sambuctemplate<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));
3214684ddb6SLionel Sambuc
3224684ddb6SLionel Sambuctemplate <class S, class T>
3234684ddb6SLionel Sambucclass const_mem_fun_t : public unary_function<const T*, S>
3244684ddb6SLionel Sambuc{
3254684ddb6SLionel Sambucpublic:
3264684ddb6SLionel Sambuc    explicit const_mem_fun_t(S (T::*p)() const);
3274684ddb6SLionel Sambuc    S operator()(const T* p) const;
3284684ddb6SLionel Sambuc};
3294684ddb6SLionel Sambuc
3304684ddb6SLionel Sambuctemplate <class S, class T, class A>
3314684ddb6SLionel Sambucclass const_mem_fun1_t : public binary_function<const T*, A, S>
3324684ddb6SLionel Sambuc{
3334684ddb6SLionel Sambucpublic:
3344684ddb6SLionel Sambuc    explicit const_mem_fun1_t(S (T::*p)(A) const);
3354684ddb6SLionel Sambuc    S operator()(const T* p, A x) const;
3364684ddb6SLionel Sambuc};
3374684ddb6SLionel Sambuc
3384684ddb6SLionel Sambuctemplate <class S, class T>          const_mem_fun_t<S,T>    mem_fun(S (T::*f)() const);
3394684ddb6SLionel Sambuctemplate <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);
3404684ddb6SLionel Sambuc
3414684ddb6SLionel Sambuctemplate <class S, class T>
3424684ddb6SLionel Sambucclass const_mem_fun_ref_t : public unary_function<T, S>
3434684ddb6SLionel Sambuc{
3444684ddb6SLionel Sambucpublic:
3454684ddb6SLionel Sambuc    explicit const_mem_fun_ref_t(S (T::*p)() const);
3464684ddb6SLionel Sambuc    S operator()(const T& p) const;
3474684ddb6SLionel Sambuc};
3484684ddb6SLionel Sambuc
3494684ddb6SLionel Sambuctemplate <class S, class T, class A>
3504684ddb6SLionel Sambucclass const_mem_fun1_ref_t : public binary_function<T, A, S>
3514684ddb6SLionel Sambuc{
3524684ddb6SLionel Sambucpublic:
3534684ddb6SLionel Sambuc    explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
3544684ddb6SLionel Sambuc    S operator()(const T& p, A x) const;
3554684ddb6SLionel Sambuc};
3564684ddb6SLionel Sambuc
3574684ddb6SLionel Sambuctemplate <class S, class T>          const_mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)() const);
3584684ddb6SLionel Sambuctemplate <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
3594684ddb6SLionel Sambuc
3604684ddb6SLionel Sambuctemplate<class R, class T> unspecified mem_fn(R T::*);
3614684ddb6SLionel Sambuc
3624684ddb6SLionel Sambucclass bad_function_call
3634684ddb6SLionel Sambuc    : public exception
3644684ddb6SLionel Sambuc{
3654684ddb6SLionel Sambuc};
3664684ddb6SLionel Sambuc
3674684ddb6SLionel Sambuctemplate<class> class function; // undefined
3684684ddb6SLionel Sambuc
3694684ddb6SLionel Sambuctemplate<class R, class... ArgTypes>
3704684ddb6SLionel Sambucclass function<R(ArgTypes...)>
3714684ddb6SLionel Sambuc  : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and
3724684ddb6SLionel Sambuc                                      // ArgTypes contains T1
3734684ddb6SLionel Sambuc  : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
3744684ddb6SLionel Sambuc                                      // ArgTypes contains T1 and T2
3754684ddb6SLionel Sambuc{
3764684ddb6SLionel Sambucpublic:
3774684ddb6SLionel Sambuc    typedef R result_type;
3784684ddb6SLionel Sambuc
3794684ddb6SLionel Sambuc    // construct/copy/destroy:
3804684ddb6SLionel Sambuc    function() noexcept;
3814684ddb6SLionel Sambuc    function(nullptr_t) noexcept;
3824684ddb6SLionel Sambuc    function(const function&);
3834684ddb6SLionel Sambuc    function(function&&) noexcept;
3844684ddb6SLionel Sambuc    template<class F>
3854684ddb6SLionel Sambuc      function(F);
3864684ddb6SLionel Sambuc    template<Allocator Alloc>
3874684ddb6SLionel Sambuc      function(allocator_arg_t, const Alloc&) noexcept;
3884684ddb6SLionel Sambuc    template<Allocator Alloc>
3894684ddb6SLionel Sambuc      function(allocator_arg_t, const Alloc&, nullptr_t) noexcept;
3904684ddb6SLionel Sambuc    template<Allocator Alloc>
3914684ddb6SLionel Sambuc      function(allocator_arg_t, const Alloc&, const function&);
3924684ddb6SLionel Sambuc    template<Allocator Alloc>
3934684ddb6SLionel Sambuc      function(allocator_arg_t, const Alloc&, function&&);
3944684ddb6SLionel Sambuc    template<class F, Allocator Alloc>
3954684ddb6SLionel Sambuc      function(allocator_arg_t, const Alloc&, F);
3964684ddb6SLionel Sambuc
3974684ddb6SLionel Sambuc    function& operator=(const function&);
3984684ddb6SLionel Sambuc    function& operator=(function&&) noexcept;
3994684ddb6SLionel Sambuc    function& operator=(nullptr_t) noexcept;
4004684ddb6SLionel Sambuc    template<class F>
4014684ddb6SLionel Sambuc      function& operator=(F&&);
4024684ddb6SLionel Sambuc    template<class F>
4034684ddb6SLionel Sambuc      function& operator=(reference_wrapper<F>) noexcept;
4044684ddb6SLionel Sambuc
4054684ddb6SLionel Sambuc    ~function();
4064684ddb6SLionel Sambuc
4074684ddb6SLionel Sambuc    // function modifiers:
4084684ddb6SLionel Sambuc    void swap(function&) noexcept;
4094684ddb6SLionel Sambuc    template<class F, class Alloc>
4104684ddb6SLionel Sambuc      void assign(F&&, const Alloc&);
4114684ddb6SLionel Sambuc
4124684ddb6SLionel Sambuc    // function capacity:
4134684ddb6SLionel Sambuc    explicit operator bool() const noexcept;
4144684ddb6SLionel Sambuc
4154684ddb6SLionel Sambuc    // function invocation:
4164684ddb6SLionel Sambuc    R operator()(ArgTypes...) const;
4174684ddb6SLionel Sambuc
4184684ddb6SLionel Sambuc    // function target access:
4194684ddb6SLionel Sambuc    const std::type_info& target_type() const noexcept;
4204684ddb6SLionel Sambuc    template <typename T>       T* target() noexcept;
4214684ddb6SLionel Sambuc    template <typename T> const T* target() const noexcept;
4224684ddb6SLionel Sambuc};
4234684ddb6SLionel Sambuc
4244684ddb6SLionel Sambuc// Null pointer comparisons:
4254684ddb6SLionel Sambuctemplate <class R, class ... ArgTypes>
4264684ddb6SLionel Sambuc  bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
4274684ddb6SLionel Sambuc
4284684ddb6SLionel Sambuctemplate <class R, class ... ArgTypes>
4294684ddb6SLionel Sambuc  bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
4304684ddb6SLionel Sambuc
4314684ddb6SLionel Sambuctemplate <class R, class ... ArgTypes>
4324684ddb6SLionel Sambuc  bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
4334684ddb6SLionel Sambuc
4344684ddb6SLionel Sambuctemplate <class  R, class ... ArgTypes>
4354684ddb6SLionel Sambuc  bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
4364684ddb6SLionel Sambuc
4374684ddb6SLionel Sambuc// specialized algorithms:
4384684ddb6SLionel Sambuctemplate <class  R, class ... ArgTypes>
4394684ddb6SLionel Sambuc  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
4404684ddb6SLionel Sambuc
4414684ddb6SLionel Sambuctemplate <class T> struct hash;
4424684ddb6SLionel Sambuc
4434684ddb6SLionel Sambuctemplate <> struct hash<bool>;
4444684ddb6SLionel Sambuctemplate <> struct hash<char>;
4454684ddb6SLionel Sambuctemplate <> struct hash<signed char>;
4464684ddb6SLionel Sambuctemplate <> struct hash<unsigned char>;
4474684ddb6SLionel Sambuctemplate <> struct hash<char16_t>;
4484684ddb6SLionel Sambuctemplate <> struct hash<char32_t>;
4494684ddb6SLionel Sambuctemplate <> struct hash<wchar_t>;
4504684ddb6SLionel Sambuctemplate <> struct hash<short>;
4514684ddb6SLionel Sambuctemplate <> struct hash<unsigned short>;
4524684ddb6SLionel Sambuctemplate <> struct hash<int>;
4534684ddb6SLionel Sambuctemplate <> struct hash<unsigned int>;
4544684ddb6SLionel Sambuctemplate <> struct hash<long>;
4554684ddb6SLionel Sambuctemplate <> struct hash<long long>;
4564684ddb6SLionel Sambuctemplate <> struct hash<unsigned long>;
4574684ddb6SLionel Sambuctemplate <> struct hash<unsigned long long>;
4584684ddb6SLionel Sambuc
4594684ddb6SLionel Sambuctemplate <> struct hash<float>;
4604684ddb6SLionel Sambuctemplate <> struct hash<double>;
4614684ddb6SLionel Sambuctemplate <> struct hash<long double>;
4624684ddb6SLionel Sambuc
4634684ddb6SLionel Sambuctemplate<class T> struct hash<T*>;
4644684ddb6SLionel Sambuc
4654684ddb6SLionel Sambuc}  // std
4664684ddb6SLionel Sambuc
4674684ddb6SLionel SambucPOLICY:  For non-variadic implementations, the number of arguments is limited
4684684ddb6SLionel Sambuc         to 3.  It is hoped that the need for non-variadic implementations
4694684ddb6SLionel Sambuc         will be minimal.
4704684ddb6SLionel Sambuc
4714684ddb6SLionel Sambuc*/
4724684ddb6SLionel Sambuc
4734684ddb6SLionel Sambuc#include <__config>
4744684ddb6SLionel Sambuc#include <type_traits>
4754684ddb6SLionel Sambuc#include <typeinfo>
4764684ddb6SLionel Sambuc#include <exception>
4774684ddb6SLionel Sambuc#include <memory>
4784684ddb6SLionel Sambuc#include <tuple>
4794684ddb6SLionel Sambuc
4804684ddb6SLionel Sambuc#include <__functional_base>
4814684ddb6SLionel Sambuc
4824684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4834684ddb6SLionel Sambuc#pragma GCC system_header
4844684ddb6SLionel Sambuc#endif
4854684ddb6SLionel Sambuc
4864684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
4874684ddb6SLionel Sambuc
4884684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
4894684ddb6SLionel Sambuctemplate <class _Tp = void>
4904684ddb6SLionel Sambuc#else
4914684ddb6SLionel Sambuctemplate <class _Tp>
4924684ddb6SLionel Sambuc#endif
4934684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp>
4944684ddb6SLionel Sambuc{
4954684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4964684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
4974684ddb6SLionel Sambuc        {return __x + __y;}
4984684ddb6SLionel Sambuc};
4994684ddb6SLionel Sambuc
5004684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
5014684ddb6SLionel Sambuctemplate <>
5024684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY plus<void>
5034684ddb6SLionel Sambuc{
5044684ddb6SLionel Sambuc    template <class _T1, class _T2>
5054684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5064684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
507*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
508*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
5094684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
5104684ddb6SLionel Sambuc    typedef void is_transparent;
5114684ddb6SLionel Sambuc};
5124684ddb6SLionel Sambuc#endif
5134684ddb6SLionel Sambuc
5144684ddb6SLionel Sambuc
5154684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
5164684ddb6SLionel Sambuctemplate <class _Tp = void>
5174684ddb6SLionel Sambuc#else
5184684ddb6SLionel Sambuctemplate <class _Tp>
5194684ddb6SLionel Sambuc#endif
5204684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp>
5214684ddb6SLionel Sambuc{
5224684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5234684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
5244684ddb6SLionel Sambuc        {return __x - __y;}
5254684ddb6SLionel Sambuc};
5264684ddb6SLionel Sambuc
5274684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
5284684ddb6SLionel Sambuctemplate <>
5294684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY minus<void>
5304684ddb6SLionel Sambuc{
5314684ddb6SLionel Sambuc    template <class _T1, class _T2>
5324684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5334684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
534*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
535*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
5364684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
5374684ddb6SLionel Sambuc    typedef void is_transparent;
5384684ddb6SLionel Sambuc};
5394684ddb6SLionel Sambuc#endif
5404684ddb6SLionel Sambuc
5414684ddb6SLionel Sambuc
5424684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
5434684ddb6SLionel Sambuctemplate <class _Tp = void>
5444684ddb6SLionel Sambuc#else
5454684ddb6SLionel Sambuctemplate <class _Tp>
5464684ddb6SLionel Sambuc#endif
5474684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp>
5484684ddb6SLionel Sambuc{
5494684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5504684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
5514684ddb6SLionel Sambuc        {return __x * __y;}
5524684ddb6SLionel Sambuc};
5534684ddb6SLionel Sambuc
5544684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
5554684ddb6SLionel Sambuctemplate <>
5564684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
5574684ddb6SLionel Sambuc{
5584684ddb6SLionel Sambuc    template <class _T1, class _T2>
5594684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5604684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
561*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
562*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
5634684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
5644684ddb6SLionel Sambuc    typedef void is_transparent;
5654684ddb6SLionel Sambuc};
5664684ddb6SLionel Sambuc#endif
5674684ddb6SLionel Sambuc
5684684ddb6SLionel Sambuc
5694684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
5704684ddb6SLionel Sambuctemplate <class _Tp = void>
5714684ddb6SLionel Sambuc#else
5724684ddb6SLionel Sambuctemplate <class _Tp>
5734684ddb6SLionel Sambuc#endif
5744684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp>
5754684ddb6SLionel Sambuc{
5764684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5774684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
5784684ddb6SLionel Sambuc        {return __x / __y;}
5794684ddb6SLionel Sambuc};
5804684ddb6SLionel Sambuc
5814684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
5824684ddb6SLionel Sambuctemplate <>
5834684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY divides<void>
5844684ddb6SLionel Sambuc{
5854684ddb6SLionel Sambuc    template <class _T1, class _T2>
5864684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5874684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
588*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
589*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
5904684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
5914684ddb6SLionel Sambuc    typedef void is_transparent;
5924684ddb6SLionel Sambuc};
5934684ddb6SLionel Sambuc#endif
5944684ddb6SLionel Sambuc
5954684ddb6SLionel Sambuc
5964684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
5974684ddb6SLionel Sambuctemplate <class _Tp = void>
5984684ddb6SLionel Sambuc#else
5994684ddb6SLionel Sambuctemplate <class _Tp>
6004684ddb6SLionel Sambuc#endif
6014684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp>
6024684ddb6SLionel Sambuc{
6034684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6044684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
6054684ddb6SLionel Sambuc        {return __x % __y;}
6064684ddb6SLionel Sambuc};
6074684ddb6SLionel Sambuc
6084684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
6094684ddb6SLionel Sambuctemplate <>
6104684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY modulus<void>
6114684ddb6SLionel Sambuc{
6124684ddb6SLionel Sambuc    template <class _T1, class _T2>
6134684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6144684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
615*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
616*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
6174684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
6184684ddb6SLionel Sambuc    typedef void is_transparent;
6194684ddb6SLionel Sambuc};
6204684ddb6SLionel Sambuc#endif
6214684ddb6SLionel Sambuc
6224684ddb6SLionel Sambuc
6234684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
6244684ddb6SLionel Sambuctemplate <class _Tp = void>
6254684ddb6SLionel Sambuc#else
6264684ddb6SLionel Sambuctemplate <class _Tp>
6274684ddb6SLionel Sambuc#endif
6284684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp>
6294684ddb6SLionel Sambuc{
6304684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6314684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
6324684ddb6SLionel Sambuc        {return -__x;}
6334684ddb6SLionel Sambuc};
6344684ddb6SLionel Sambuc
6354684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
6364684ddb6SLionel Sambuctemplate <>
6374684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY negate<void>
6384684ddb6SLionel Sambuc{
6394684ddb6SLionel Sambuc    template <class _Tp>
6404684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6414684ddb6SLionel Sambuc    auto operator()(_Tp&& __x) const
642*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
643*0a6a1f1dSLionel Sambuc    -> decltype        (- _VSTD::forward<_Tp>(__x))
6444684ddb6SLionel Sambuc        { return        - _VSTD::forward<_Tp>(__x); }
6454684ddb6SLionel Sambuc    typedef void is_transparent;
6464684ddb6SLionel Sambuc};
6474684ddb6SLionel Sambuc#endif
6484684ddb6SLionel Sambuc
6494684ddb6SLionel Sambuc
6504684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
6514684ddb6SLionel Sambuctemplate <class _Tp = void>
6524684ddb6SLionel Sambuc#else
6534684ddb6SLionel Sambuctemplate <class _Tp>
6544684ddb6SLionel Sambuc#endif
6554684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool>
6564684ddb6SLionel Sambuc{
6574684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6584684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Tp& __y) const
6594684ddb6SLionel Sambuc        {return __x == __y;}
6604684ddb6SLionel Sambuc};
6614684ddb6SLionel Sambuc
6624684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
6634684ddb6SLionel Sambuctemplate <>
6644684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
6654684ddb6SLionel Sambuc{
6664684ddb6SLionel Sambuc    template <class _T1, class _T2>
6674684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6684684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
669*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
670*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
6714684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
6724684ddb6SLionel Sambuc    typedef void is_transparent;
6734684ddb6SLionel Sambuc};
6744684ddb6SLionel Sambuc#endif
6754684ddb6SLionel Sambuc
6764684ddb6SLionel Sambuc
6774684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
6784684ddb6SLionel Sambuctemplate <class _Tp = void>
6794684ddb6SLionel Sambuc#else
6804684ddb6SLionel Sambuctemplate <class _Tp>
6814684ddb6SLionel Sambuc#endif
6824684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool>
6834684ddb6SLionel Sambuc{
6844684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6854684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Tp& __y) const
6864684ddb6SLionel Sambuc        {return __x != __y;}
6874684ddb6SLionel Sambuc};
6884684ddb6SLionel Sambuc
6894684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
6904684ddb6SLionel Sambuctemplate <>
6914684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
6924684ddb6SLionel Sambuc{
6934684ddb6SLionel Sambuc    template <class _T1, class _T2>
6944684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6954684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
696*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
697*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
6984684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
6994684ddb6SLionel Sambuc    typedef void is_transparent;
7004684ddb6SLionel Sambuc};
7014684ddb6SLionel Sambuc#endif
7024684ddb6SLionel Sambuc
7034684ddb6SLionel Sambuc
7044684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
7054684ddb6SLionel Sambuctemplate <class _Tp = void>
7064684ddb6SLionel Sambuc#else
7074684ddb6SLionel Sambuctemplate <class _Tp>
7084684ddb6SLionel Sambuc#endif
7094684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool>
7104684ddb6SLionel Sambuc{
7114684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7124684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Tp& __y) const
7134684ddb6SLionel Sambuc        {return __x > __y;}
7144684ddb6SLionel Sambuc};
7154684ddb6SLionel Sambuc
7164684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
7174684ddb6SLionel Sambuctemplate <>
7184684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY greater<void>
7194684ddb6SLionel Sambuc{
7204684ddb6SLionel Sambuc    template <class _T1, class _T2>
7214684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7224684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
723*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
724*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
7254684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
7264684ddb6SLionel Sambuc    typedef void is_transparent;
7274684ddb6SLionel Sambuc};
7284684ddb6SLionel Sambuc#endif
7294684ddb6SLionel Sambuc
7304684ddb6SLionel Sambuc
7314684ddb6SLionel Sambuc// less in <__functional_base>
7324684ddb6SLionel Sambuc
7334684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
7344684ddb6SLionel Sambuctemplate <class _Tp = void>
7354684ddb6SLionel Sambuc#else
7364684ddb6SLionel Sambuctemplate <class _Tp>
7374684ddb6SLionel Sambuc#endif
7384684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool>
7394684ddb6SLionel Sambuc{
7404684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7414684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Tp& __y) const
7424684ddb6SLionel Sambuc        {return __x >= __y;}
7434684ddb6SLionel Sambuc};
7444684ddb6SLionel Sambuc
7454684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
7464684ddb6SLionel Sambuctemplate <>
7474684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
7484684ddb6SLionel Sambuc{
7494684ddb6SLionel Sambuc    template <class _T1, class _T2>
7504684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7514684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
752*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
753*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
7544684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
7554684ddb6SLionel Sambuc    typedef void is_transparent;
7564684ddb6SLionel Sambuc};
7574684ddb6SLionel Sambuc#endif
7584684ddb6SLionel Sambuc
7594684ddb6SLionel Sambuc
7604684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
7614684ddb6SLionel Sambuctemplate <class _Tp = void>
7624684ddb6SLionel Sambuc#else
7634684ddb6SLionel Sambuctemplate <class _Tp>
7644684ddb6SLionel Sambuc#endif
7654684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool>
7664684ddb6SLionel Sambuc{
7674684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7684684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Tp& __y) const
7694684ddb6SLionel Sambuc        {return __x <= __y;}
7704684ddb6SLionel Sambuc};
7714684ddb6SLionel Sambuc
7724684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
7734684ddb6SLionel Sambuctemplate <>
7744684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
7754684ddb6SLionel Sambuc{
7764684ddb6SLionel Sambuc    template <class _T1, class _T2>
7774684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7784684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
779*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
780*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
7814684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
7824684ddb6SLionel Sambuc    typedef void is_transparent;
7834684ddb6SLionel Sambuc};
7844684ddb6SLionel Sambuc#endif
7854684ddb6SLionel Sambuc
7864684ddb6SLionel Sambuc
7874684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
7884684ddb6SLionel Sambuctemplate <class _Tp = void>
7894684ddb6SLionel Sambuc#else
7904684ddb6SLionel Sambuctemplate <class _Tp>
7914684ddb6SLionel Sambuc#endif
7924684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool>
7934684ddb6SLionel Sambuc{
7944684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7954684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Tp& __y) const
7964684ddb6SLionel Sambuc        {return __x && __y;}
7974684ddb6SLionel Sambuc};
7984684ddb6SLionel Sambuc
7994684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
8004684ddb6SLionel Sambuctemplate <>
8014684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
8024684ddb6SLionel Sambuc{
8034684ddb6SLionel Sambuc    template <class _T1, class _T2>
8044684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8054684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
806*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
807*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
8084684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
8094684ddb6SLionel Sambuc    typedef void is_transparent;
8104684ddb6SLionel Sambuc};
8114684ddb6SLionel Sambuc#endif
8124684ddb6SLionel Sambuc
8134684ddb6SLionel Sambuc
8144684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
8154684ddb6SLionel Sambuctemplate <class _Tp = void>
8164684ddb6SLionel Sambuc#else
8174684ddb6SLionel Sambuctemplate <class _Tp>
8184684ddb6SLionel Sambuc#endif
8194684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool>
8204684ddb6SLionel Sambuc{
8214684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8224684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Tp& __y) const
8234684ddb6SLionel Sambuc        {return __x || __y;}
8244684ddb6SLionel Sambuc};
8254684ddb6SLionel Sambuc
8264684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
8274684ddb6SLionel Sambuctemplate <>
8284684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
8294684ddb6SLionel Sambuc{
8304684ddb6SLionel Sambuc    template <class _T1, class _T2>
8314684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8324684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
833*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
834*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
8354684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
8364684ddb6SLionel Sambuc    typedef void is_transparent;
8374684ddb6SLionel Sambuc};
8384684ddb6SLionel Sambuc#endif
8394684ddb6SLionel Sambuc
8404684ddb6SLionel Sambuc
8414684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
8424684ddb6SLionel Sambuctemplate <class _Tp = void>
8434684ddb6SLionel Sambuc#else
8444684ddb6SLionel Sambuctemplate <class _Tp>
8454684ddb6SLionel Sambuc#endif
8464684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool>
8474684ddb6SLionel Sambuc{
8484684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8494684ddb6SLionel Sambuc    bool operator()(const _Tp& __x) const
8504684ddb6SLionel Sambuc        {return !__x;}
8514684ddb6SLionel Sambuc};
8524684ddb6SLionel Sambuc
8534684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
8544684ddb6SLionel Sambuctemplate <>
8554684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
8564684ddb6SLionel Sambuc{
8574684ddb6SLionel Sambuc    template <class _Tp>
8584684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8594684ddb6SLionel Sambuc    auto operator()(_Tp&& __x) const
860*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
861*0a6a1f1dSLionel Sambuc    -> decltype        (!_VSTD::forward<_Tp>(__x))
8624684ddb6SLionel Sambuc        { return        !_VSTD::forward<_Tp>(__x); }
8634684ddb6SLionel Sambuc    typedef void is_transparent;
8644684ddb6SLionel Sambuc};
8654684ddb6SLionel Sambuc#endif
8664684ddb6SLionel Sambuc
8674684ddb6SLionel Sambuc
8684684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
8694684ddb6SLionel Sambuctemplate <class _Tp = void>
8704684ddb6SLionel Sambuc#else
8714684ddb6SLionel Sambuctemplate <class _Tp>
8724684ddb6SLionel Sambuc#endif
8734684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp>
8744684ddb6SLionel Sambuc{
8754684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8764684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
8774684ddb6SLionel Sambuc        {return __x & __y;}
8784684ddb6SLionel Sambuc};
8794684ddb6SLionel Sambuc
8804684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
8814684ddb6SLionel Sambuctemplate <>
8824684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
8834684ddb6SLionel Sambuc{
8844684ddb6SLionel Sambuc    template <class _T1, class _T2>
8854684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8864684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
887*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
888*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
8894684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
8904684ddb6SLionel Sambuc    typedef void is_transparent;
8914684ddb6SLionel Sambuc};
8924684ddb6SLionel Sambuc#endif
8934684ddb6SLionel Sambuc
8944684ddb6SLionel Sambuc
8954684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
8964684ddb6SLionel Sambuctemplate <class _Tp = void>
8974684ddb6SLionel Sambuc#else
8984684ddb6SLionel Sambuctemplate <class _Tp>
8994684ddb6SLionel Sambuc#endif
9004684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp>
9014684ddb6SLionel Sambuc{
9024684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9034684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
9044684ddb6SLionel Sambuc        {return __x | __y;}
9054684ddb6SLionel Sambuc};
9064684ddb6SLionel Sambuc
9074684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
9084684ddb6SLionel Sambuctemplate <>
9094684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
9104684ddb6SLionel Sambuc{
9114684ddb6SLionel Sambuc    template <class _T1, class _T2>
9124684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9134684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
914*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
915*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
9164684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
9174684ddb6SLionel Sambuc    typedef void is_transparent;
9184684ddb6SLionel Sambuc};
9194684ddb6SLionel Sambuc#endif
9204684ddb6SLionel Sambuc
9214684ddb6SLionel Sambuc
9224684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
9234684ddb6SLionel Sambuctemplate <class _Tp = void>
9244684ddb6SLionel Sambuc#else
9254684ddb6SLionel Sambuctemplate <class _Tp>
9264684ddb6SLionel Sambuc#endif
9274684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp>
9284684ddb6SLionel Sambuc{
9294684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9304684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
9314684ddb6SLionel Sambuc        {return __x ^ __y;}
9324684ddb6SLionel Sambuc};
9334684ddb6SLionel Sambuc
9344684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
9354684ddb6SLionel Sambuctemplate <>
9364684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
9374684ddb6SLionel Sambuc{
9384684ddb6SLionel Sambuc    template <class _T1, class _T2>
9394684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9404684ddb6SLionel Sambuc    auto operator()(_T1&& __t, _T2&& __u) const
941*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
942*0a6a1f1dSLionel Sambuc    -> decltype        (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
9434684ddb6SLionel Sambuc        { return        _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
9444684ddb6SLionel Sambuc    typedef void is_transparent;
9454684ddb6SLionel Sambuc};
9464684ddb6SLionel Sambuc#endif
9474684ddb6SLionel Sambuc
9484684ddb6SLionel Sambuc
9494684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
9504684ddb6SLionel Sambuctemplate <class _Tp = void>
9514684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp>
9524684ddb6SLionel Sambuc{
9534684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9544684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
9554684ddb6SLionel Sambuc        {return ~__x;}
9564684ddb6SLionel Sambuc};
9574684ddb6SLionel Sambuc
9584684ddb6SLionel Sambuctemplate <>
9594684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
9604684ddb6SLionel Sambuc{
9614684ddb6SLionel Sambuc    template <class _Tp>
9624684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9634684ddb6SLionel Sambuc    auto operator()(_Tp&& __x) const
964*0a6a1f1dSLionel Sambuc    _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
965*0a6a1f1dSLionel Sambuc    -> decltype        (~_VSTD::forward<_Tp>(__x))
9664684ddb6SLionel Sambuc        { return        ~_VSTD::forward<_Tp>(__x); }
9674684ddb6SLionel Sambuc    typedef void is_transparent;
9684684ddb6SLionel Sambuc};
9694684ddb6SLionel Sambuc#endif
9704684ddb6SLionel Sambuc
9714684ddb6SLionel Sambuctemplate <class _Predicate>
9724684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY unary_negate
9734684ddb6SLionel Sambuc    : public unary_function<typename _Predicate::argument_type, bool>
9744684ddb6SLionel Sambuc{
9754684ddb6SLionel Sambuc    _Predicate __pred_;
9764684ddb6SLionel Sambucpublic:
9774684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9784684ddb6SLionel Sambuc    explicit unary_negate(const _Predicate& __pred)
9794684ddb6SLionel Sambuc        : __pred_(__pred) {}
9804684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9814684ddb6SLionel Sambuc    bool operator()(const typename _Predicate::argument_type& __x) const
9824684ddb6SLionel Sambuc        {return !__pred_(__x);}
9834684ddb6SLionel Sambuc};
9844684ddb6SLionel Sambuc
9854684ddb6SLionel Sambuctemplate <class _Predicate>
9864684ddb6SLionel Sambucinline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
9874684ddb6SLionel Sambucunary_negate<_Predicate>
9884684ddb6SLionel Sambucnot1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
9894684ddb6SLionel Sambuc
9904684ddb6SLionel Sambuctemplate <class _Predicate>
9914684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY binary_negate
9924684ddb6SLionel Sambuc    : public binary_function<typename _Predicate::first_argument_type,
9934684ddb6SLionel Sambuc                             typename _Predicate::second_argument_type,
9944684ddb6SLionel Sambuc                             bool>
9954684ddb6SLionel Sambuc{
9964684ddb6SLionel Sambuc    _Predicate __pred_;
9974684ddb6SLionel Sambucpublic:
9984684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
9994684ddb6SLionel Sambuc    binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
10004684ddb6SLionel Sambuc
10014684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
10024684ddb6SLionel Sambuc    bool operator()(const typename _Predicate::first_argument_type& __x,
10034684ddb6SLionel Sambuc                    const typename _Predicate::second_argument_type& __y) const
10044684ddb6SLionel Sambuc        {return !__pred_(__x, __y);}
10054684ddb6SLionel Sambuc};
10064684ddb6SLionel Sambuc
10074684ddb6SLionel Sambuctemplate <class _Predicate>
10084684ddb6SLionel Sambucinline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
10094684ddb6SLionel Sambucbinary_negate<_Predicate>
10104684ddb6SLionel Sambucnot2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
10114684ddb6SLionel Sambuc
10124684ddb6SLionel Sambuctemplate <class __Operation>
10134684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY binder1st
10144684ddb6SLionel Sambuc    : public unary_function<typename __Operation::second_argument_type,
10154684ddb6SLionel Sambuc                            typename __Operation::result_type>
10164684ddb6SLionel Sambuc{
10174684ddb6SLionel Sambucprotected:
10184684ddb6SLionel Sambuc    __Operation                               op;
10194684ddb6SLionel Sambuc    typename __Operation::first_argument_type value;
10204684ddb6SLionel Sambucpublic:
10214684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
10224684ddb6SLionel Sambuc                               const typename __Operation::first_argument_type __y)
10234684ddb6SLionel Sambuc        : op(__x), value(__y) {}
10244684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
10254684ddb6SLionel Sambuc        (typename __Operation::second_argument_type& __x) const
10264684ddb6SLionel Sambuc            {return op(value, __x);}
10274684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
10284684ddb6SLionel Sambuc        (const typename __Operation::second_argument_type& __x) const
10294684ddb6SLionel Sambuc            {return op(value, __x);}
10304684ddb6SLionel Sambuc};
10314684ddb6SLionel Sambuc
10324684ddb6SLionel Sambuctemplate <class __Operation, class _Tp>
10334684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
10344684ddb6SLionel Sambucbinder1st<__Operation>
10354684ddb6SLionel Sambucbind1st(const __Operation& __op, const _Tp& __x)
10364684ddb6SLionel Sambuc    {return binder1st<__Operation>(__op, __x);}
10374684ddb6SLionel Sambuc
10384684ddb6SLionel Sambuctemplate <class __Operation>
10394684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY binder2nd
10404684ddb6SLionel Sambuc    : public unary_function<typename __Operation::first_argument_type,
10414684ddb6SLionel Sambuc                            typename __Operation::result_type>
10424684ddb6SLionel Sambuc{
10434684ddb6SLionel Sambucprotected:
10444684ddb6SLionel Sambuc    __Operation                                op;
10454684ddb6SLionel Sambuc    typename __Operation::second_argument_type value;
10464684ddb6SLionel Sambucpublic:
10474684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
10484684ddb6SLionel Sambuc    binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
10494684ddb6SLionel Sambuc        : op(__x), value(__y) {}
10504684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
10514684ddb6SLionel Sambuc        (      typename __Operation::first_argument_type& __x) const
10524684ddb6SLionel Sambuc            {return op(__x, value);}
10534684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
10544684ddb6SLionel Sambuc        (const typename __Operation::first_argument_type& __x) const
10554684ddb6SLionel Sambuc            {return op(__x, value);}
10564684ddb6SLionel Sambuc};
10574684ddb6SLionel Sambuc
10584684ddb6SLionel Sambuctemplate <class __Operation, class _Tp>
10594684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
10604684ddb6SLionel Sambucbinder2nd<__Operation>
10614684ddb6SLionel Sambucbind2nd(const __Operation& __op, const _Tp& __x)
10624684ddb6SLionel Sambuc    {return binder2nd<__Operation>(__op, __x);}
10634684ddb6SLionel Sambuc
10644684ddb6SLionel Sambuctemplate <class _Arg, class _Result>
10654684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function
10664684ddb6SLionel Sambuc    : public unary_function<_Arg, _Result>
10674684ddb6SLionel Sambuc{
10684684ddb6SLionel Sambuc    _Result (*__f_)(_Arg);
10694684ddb6SLionel Sambucpublic:
10704684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
10714684ddb6SLionel Sambuc        : __f_(__f) {}
10724684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
10734684ddb6SLionel Sambuc        {return __f_(__x);}
10744684ddb6SLionel Sambuc};
10754684ddb6SLionel Sambuc
10764684ddb6SLionel Sambuctemplate <class _Arg, class _Result>
10774684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
10784684ddb6SLionel Sambucpointer_to_unary_function<_Arg,_Result>
10794684ddb6SLionel Sambucptr_fun(_Result (*__f)(_Arg))
10804684ddb6SLionel Sambuc    {return pointer_to_unary_function<_Arg,_Result>(__f);}
10814684ddb6SLionel Sambuc
10824684ddb6SLionel Sambuctemplate <class _Arg1, class _Arg2, class _Result>
10834684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function
10844684ddb6SLionel Sambuc    : public binary_function<_Arg1, _Arg2, _Result>
10854684ddb6SLionel Sambuc{
10864684ddb6SLionel Sambuc    _Result (*__f_)(_Arg1, _Arg2);
10874684ddb6SLionel Sambucpublic:
10884684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
10894684ddb6SLionel Sambuc        : __f_(__f) {}
10904684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
10914684ddb6SLionel Sambuc        {return __f_(__x, __y);}
10924684ddb6SLionel Sambuc};
10934684ddb6SLionel Sambuc
10944684ddb6SLionel Sambuctemplate <class _Arg1, class _Arg2, class _Result>
10954684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
10964684ddb6SLionel Sambucpointer_to_binary_function<_Arg1,_Arg2,_Result>
10974684ddb6SLionel Sambucptr_fun(_Result (*__f)(_Arg1,_Arg2))
10984684ddb6SLionel Sambuc    {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
10994684ddb6SLionel Sambuc
11004684ddb6SLionel Sambuctemplate<class _Sp, class _Tp>
11014684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp>
11024684ddb6SLionel Sambuc{
11034684ddb6SLionel Sambuc    _Sp (_Tp::*__p_)();
11044684ddb6SLionel Sambucpublic:
11054684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
11064684ddb6SLionel Sambuc        : __p_(__p) {}
11074684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
11084684ddb6SLionel Sambuc        {return (__p->*__p_)();}
11094684ddb6SLionel Sambuc};
11104684ddb6SLionel Sambuc
11114684ddb6SLionel Sambuctemplate<class _Sp, class _Tp, class _Ap>
11124684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
11134684ddb6SLionel Sambuc{
11144684ddb6SLionel Sambuc    _Sp (_Tp::*__p_)(_Ap);
11154684ddb6SLionel Sambucpublic:
11164684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
11174684ddb6SLionel Sambuc        : __p_(__p) {}
11184684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
11194684ddb6SLionel Sambuc        {return (__p->*__p_)(__x);}
11204684ddb6SLionel Sambuc};
11214684ddb6SLionel Sambuc
11224684ddb6SLionel Sambuctemplate<class _Sp, class _Tp>
11234684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
11244684ddb6SLionel Sambucmem_fun_t<_Sp,_Tp>
11254684ddb6SLionel Sambucmem_fun(_Sp (_Tp::*__f)())
11264684ddb6SLionel Sambuc    {return mem_fun_t<_Sp,_Tp>(__f);}
11274684ddb6SLionel Sambuc
11284684ddb6SLionel Sambuctemplate<class _Sp, class _Tp, class _Ap>
11294684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
11304684ddb6SLionel Sambucmem_fun1_t<_Sp,_Tp,_Ap>
11314684ddb6SLionel Sambucmem_fun(_Sp (_Tp::*__f)(_Ap))
11324684ddb6SLionel Sambuc    {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
11334684ddb6SLionel Sambuc
11344684ddb6SLionel Sambuctemplate<class _Sp, class _Tp>
11354684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp>
11364684ddb6SLionel Sambuc{
11374684ddb6SLionel Sambuc    _Sp (_Tp::*__p_)();
11384684ddb6SLionel Sambucpublic:
11394684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
11404684ddb6SLionel Sambuc        : __p_(__p) {}
11414684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
11424684ddb6SLionel Sambuc        {return (__p.*__p_)();}
11434684ddb6SLionel Sambuc};
11444684ddb6SLionel Sambuc
11454684ddb6SLionel Sambuctemplate<class _Sp, class _Tp, class _Ap>
11464684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
11474684ddb6SLionel Sambuc{
11484684ddb6SLionel Sambuc    _Sp (_Tp::*__p_)(_Ap);
11494684ddb6SLionel Sambucpublic:
11504684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
11514684ddb6SLionel Sambuc        : __p_(__p) {}
11524684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
11534684ddb6SLionel Sambuc        {return (__p.*__p_)(__x);}
11544684ddb6SLionel Sambuc};
11554684ddb6SLionel Sambuc
11564684ddb6SLionel Sambuctemplate<class _Sp, class _Tp>
11574684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
11584684ddb6SLionel Sambucmem_fun_ref_t<_Sp,_Tp>
11594684ddb6SLionel Sambucmem_fun_ref(_Sp (_Tp::*__f)())
11604684ddb6SLionel Sambuc    {return mem_fun_ref_t<_Sp,_Tp>(__f);}
11614684ddb6SLionel Sambuc
11624684ddb6SLionel Sambuctemplate<class _Sp, class _Tp, class _Ap>
11634684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
11644684ddb6SLionel Sambucmem_fun1_ref_t<_Sp,_Tp,_Ap>
11654684ddb6SLionel Sambucmem_fun_ref(_Sp (_Tp::*__f)(_Ap))
11664684ddb6SLionel Sambuc    {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
11674684ddb6SLionel Sambuc
11684684ddb6SLionel Sambuctemplate <class _Sp, class _Tp>
11694684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp>
11704684ddb6SLionel Sambuc{
11714684ddb6SLionel Sambuc    _Sp (_Tp::*__p_)() const;
11724684ddb6SLionel Sambucpublic:
11734684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
11744684ddb6SLionel Sambuc        : __p_(__p) {}
11754684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
11764684ddb6SLionel Sambuc        {return (__p->*__p_)();}
11774684ddb6SLionel Sambuc};
11784684ddb6SLionel Sambuc
11794684ddb6SLionel Sambuctemplate <class _Sp, class _Tp, class _Ap>
11804684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
11814684ddb6SLionel Sambuc{
11824684ddb6SLionel Sambuc    _Sp (_Tp::*__p_)(_Ap) const;
11834684ddb6SLionel Sambucpublic:
11844684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
11854684ddb6SLionel Sambuc        : __p_(__p) {}
11864684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
11874684ddb6SLionel Sambuc        {return (__p->*__p_)(__x);}
11884684ddb6SLionel Sambuc};
11894684ddb6SLionel Sambuc
11904684ddb6SLionel Sambuctemplate <class _Sp, class _Tp>
11914684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
11924684ddb6SLionel Sambucconst_mem_fun_t<_Sp,_Tp>
11934684ddb6SLionel Sambucmem_fun(_Sp (_Tp::*__f)() const)
11944684ddb6SLionel Sambuc    {return const_mem_fun_t<_Sp,_Tp>(__f);}
11954684ddb6SLionel Sambuc
11964684ddb6SLionel Sambuctemplate <class _Sp, class _Tp, class _Ap>
11974684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
11984684ddb6SLionel Sambucconst_mem_fun1_t<_Sp,_Tp,_Ap>
11994684ddb6SLionel Sambucmem_fun(_Sp (_Tp::*__f)(_Ap) const)
12004684ddb6SLionel Sambuc    {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
12014684ddb6SLionel Sambuc
12024684ddb6SLionel Sambuctemplate <class _Sp, class _Tp>
12034684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
12044684ddb6SLionel Sambuc{
12054684ddb6SLionel Sambuc    _Sp (_Tp::*__p_)() const;
12064684ddb6SLionel Sambucpublic:
12074684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
12084684ddb6SLionel Sambuc        : __p_(__p) {}
12094684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
12104684ddb6SLionel Sambuc        {return (__p.*__p_)();}
12114684ddb6SLionel Sambuc};
12124684ddb6SLionel Sambuc
12134684ddb6SLionel Sambuctemplate <class _Sp, class _Tp, class _Ap>
12144684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t
12154684ddb6SLionel Sambuc    : public binary_function<_Tp, _Ap, _Sp>
12164684ddb6SLionel Sambuc{
12174684ddb6SLionel Sambuc    _Sp (_Tp::*__p_)(_Ap) const;
12184684ddb6SLionel Sambucpublic:
12194684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
12204684ddb6SLionel Sambuc        : __p_(__p) {}
12214684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
12224684ddb6SLionel Sambuc        {return (__p.*__p_)(__x);}
12234684ddb6SLionel Sambuc};
12244684ddb6SLionel Sambuc
12254684ddb6SLionel Sambuctemplate <class _Sp, class _Tp>
12264684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
12274684ddb6SLionel Sambucconst_mem_fun_ref_t<_Sp,_Tp>
12284684ddb6SLionel Sambucmem_fun_ref(_Sp (_Tp::*__f)() const)
12294684ddb6SLionel Sambuc    {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
12304684ddb6SLionel Sambuc
12314684ddb6SLionel Sambuctemplate <class _Sp, class _Tp, class _Ap>
12324684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
12334684ddb6SLionel Sambucconst_mem_fun1_ref_t<_Sp,_Tp,_Ap>
12344684ddb6SLionel Sambucmem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
12354684ddb6SLionel Sambuc    {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
12364684ddb6SLionel Sambuc
1237*0a6a1f1dSLionel Sambuc////////////////////////////////////////////////////////////////////////////////
1238*0a6a1f1dSLionel Sambuc//                                MEMFUN
1239*0a6a1f1dSLionel Sambuc//==============================================================================
12404684ddb6SLionel Sambuc
12414684ddb6SLionel Sambuctemplate <class _Tp>
12424684ddb6SLionel Sambucclass __mem_fn
12434684ddb6SLionel Sambuc    : public __weak_result_type<_Tp>
12444684ddb6SLionel Sambuc{
12454684ddb6SLionel Sambucpublic:
12464684ddb6SLionel Sambuc    // types
12474684ddb6SLionel Sambuc    typedef _Tp type;
12484684ddb6SLionel Sambucprivate:
12494684ddb6SLionel Sambuc    type __f_;
12504684ddb6SLionel Sambuc
12514684ddb6SLionel Sambucpublic:
12524684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}
12534684ddb6SLionel Sambuc
1254*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS
12554684ddb6SLionel Sambuc    // invoke
12564684ddb6SLionel Sambuc    template <class... _ArgTypes>
12574684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
12584684ddb6SLionel Sambuc    typename __invoke_return<type, _ArgTypes...>::type
1259*0a6a1f1dSLionel Sambuc    operator() (_ArgTypes&&... __args) const {
12604684ddb6SLionel Sambuc        return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
12614684ddb6SLionel Sambuc    }
1262*0a6a1f1dSLionel Sambuc#else
1263*0a6a1f1dSLionel Sambuc
1264*0a6a1f1dSLionel Sambuc    template <class _A0>
1265*0a6a1f1dSLionel Sambuc    typename __invoke_return0<type, _A0>::type
1266*0a6a1f1dSLionel Sambuc    operator() (_A0& __a0) const {
1267*0a6a1f1dSLionel Sambuc        return __invoke(__f_, __a0);
1268*0a6a1f1dSLionel Sambuc    }
1269*0a6a1f1dSLionel Sambuc
1270*0a6a1f1dSLionel Sambuc    template <class _A0, class _A1>
1271*0a6a1f1dSLionel Sambuc    typename __invoke_return1<type, _A0, _A1>::type
1272*0a6a1f1dSLionel Sambuc    operator() (_A0& __a0, _A1& __a1) const {
1273*0a6a1f1dSLionel Sambuc        return __invoke(__f_, __a0, __a1);
1274*0a6a1f1dSLionel Sambuc    }
1275*0a6a1f1dSLionel Sambuc
1276*0a6a1f1dSLionel Sambuc    template <class _A0, class _A1, class _A2>
1277*0a6a1f1dSLionel Sambuc    typename __invoke_return2<type, _A0, _A1, _A2>::type
1278*0a6a1f1dSLionel Sambuc    operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
1279*0a6a1f1dSLionel Sambuc        return __invoke(__f_, __a0, __a1, __a2);
1280*0a6a1f1dSLionel Sambuc    }
1281*0a6a1f1dSLionel Sambuc#endif
12824684ddb6SLionel Sambuc};
12834684ddb6SLionel Sambuc
12844684ddb6SLionel Sambuctemplate<class _Rp, class _Tp>
12854684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
12864684ddb6SLionel Sambuc__mem_fn<_Rp _Tp::*>
12874684ddb6SLionel Sambucmem_fn(_Rp _Tp::* __pm)
12884684ddb6SLionel Sambuc{
12894684ddb6SLionel Sambuc    return __mem_fn<_Rp _Tp::*>(__pm);
12904684ddb6SLionel Sambuc}
12914684ddb6SLionel Sambuc
1292*0a6a1f1dSLionel Sambuc////////////////////////////////////////////////////////////////////////////////
1293*0a6a1f1dSLionel Sambuc//                                FUNCTION
1294*0a6a1f1dSLionel Sambuc//==============================================================================
1295*0a6a1f1dSLionel Sambuc
12964684ddb6SLionel Sambuc// bad_function_call
12974684ddb6SLionel Sambuc
12984684ddb6SLionel Sambucclass _LIBCPP_EXCEPTION_ABI bad_function_call
12994684ddb6SLionel Sambuc    : public exception
13004684ddb6SLionel Sambuc{
13014684ddb6SLionel Sambuc};
13024684ddb6SLionel Sambuc
13034684ddb6SLionel Sambuctemplate<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
13044684ddb6SLionel Sambuc
13054684ddb6SLionel Sambucnamespace __function
13064684ddb6SLionel Sambuc{
13074684ddb6SLionel Sambuc
1308*0a6a1f1dSLionel Sambuctemplate<class _Rp>
13094684ddb6SLionel Sambucstruct __maybe_derive_from_unary_function
13104684ddb6SLionel Sambuc{
13114684ddb6SLionel Sambuc};
13124684ddb6SLionel Sambuc
13134684ddb6SLionel Sambuctemplate<class _Rp, class _A1>
13144684ddb6SLionel Sambucstruct __maybe_derive_from_unary_function<_Rp(_A1)>
13154684ddb6SLionel Sambuc    : public unary_function<_A1, _Rp>
13164684ddb6SLionel Sambuc{
13174684ddb6SLionel Sambuc};
13184684ddb6SLionel Sambuc
1319*0a6a1f1dSLionel Sambuctemplate<class _Rp>
13204684ddb6SLionel Sambucstruct __maybe_derive_from_binary_function
13214684ddb6SLionel Sambuc{
13224684ddb6SLionel Sambuc};
13234684ddb6SLionel Sambuc
13244684ddb6SLionel Sambuctemplate<class _Rp, class _A1, class _A2>
13254684ddb6SLionel Sambucstruct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
13264684ddb6SLionel Sambuc    : public binary_function<_A1, _A2, _Rp>
13274684ddb6SLionel Sambuc{
13284684ddb6SLionel Sambuc};
13294684ddb6SLionel Sambuc
1330*0a6a1f1dSLionel Sambuctemplate <class _Fp>
1331*0a6a1f1dSLionel Sambuc_LIBCPP_INLINE_VISIBILITY
1332*0a6a1f1dSLionel Sambucbool __not_null(_Fp const&) { return true; }
1333*0a6a1f1dSLionel Sambuc
1334*0a6a1f1dSLionel Sambuctemplate <class _Fp>
1335*0a6a1f1dSLionel Sambuc_LIBCPP_INLINE_VISIBILITY
1336*0a6a1f1dSLionel Sambucbool __not_null(_Fp* __ptr) { return __ptr; }
1337*0a6a1f1dSLionel Sambuc
1338*0a6a1f1dSLionel Sambuctemplate <class _Ret, class _Class>
1339*0a6a1f1dSLionel Sambuc_LIBCPP_INLINE_VISIBILITY
1340*0a6a1f1dSLionel Sambucbool __not_null(_Ret _Class::*__ptr) { return __ptr; }
1341*0a6a1f1dSLionel Sambuc
1342*0a6a1f1dSLionel Sambuctemplate <class _Fp>
1343*0a6a1f1dSLionel Sambuc_LIBCPP_INLINE_VISIBILITY
1344*0a6a1f1dSLionel Sambucbool __not_null(function<_Fp> const& __f) { return !!__f; }
1345*0a6a1f1dSLionel Sambuc
1346*0a6a1f1dSLionel Sambuc} // namespace __function
1347*0a6a1f1dSLionel Sambuc
1348*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS
1349*0a6a1f1dSLionel Sambuc
1350*0a6a1f1dSLionel Sambucnamespace __function {
1351*0a6a1f1dSLionel Sambuc
13524684ddb6SLionel Sambuctemplate<class _Fp> class __base;
13534684ddb6SLionel Sambuc
13544684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
13554684ddb6SLionel Sambucclass __base<_Rp(_ArgTypes...)>
13564684ddb6SLionel Sambuc{
13574684ddb6SLionel Sambuc    __base(const __base&);
13584684ddb6SLionel Sambuc    __base& operator=(const __base&);
13594684ddb6SLionel Sambucpublic:
13604684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY __base() {}
13614684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
13624684ddb6SLionel Sambuc    virtual __base* __clone() const = 0;
13634684ddb6SLionel Sambuc    virtual void __clone(__base*) const = 0;
13644684ddb6SLionel Sambuc    virtual void destroy() _NOEXCEPT = 0;
13654684ddb6SLionel Sambuc    virtual void destroy_deallocate() _NOEXCEPT = 0;
13664684ddb6SLionel Sambuc    virtual _Rp operator()(_ArgTypes&& ...) = 0;
13674684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI
13684684ddb6SLionel Sambuc    virtual const void* target(const type_info&) const _NOEXCEPT = 0;
13694684ddb6SLionel Sambuc    virtual const std::type_info& target_type() const _NOEXCEPT = 0;
13704684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_RTTI
13714684ddb6SLionel Sambuc};
13724684ddb6SLionel Sambuc
13734684ddb6SLionel Sambuctemplate<class _FD, class _Alloc, class _FB> class __func;
13744684ddb6SLionel Sambuc
13754684ddb6SLionel Sambuctemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
13764684ddb6SLionel Sambucclass __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
13774684ddb6SLionel Sambuc    : public  __base<_Rp(_ArgTypes...)>
13784684ddb6SLionel Sambuc{
13794684ddb6SLionel Sambuc    __compressed_pair<_Fp, _Alloc> __f_;
13804684ddb6SLionel Sambucpublic:
13814684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
13824684ddb6SLionel Sambuc    explicit __func(_Fp&& __f)
13834684ddb6SLionel Sambuc        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
13844684ddb6SLionel Sambuc                                    _VSTD::forward_as_tuple()) {}
13854684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
13864684ddb6SLionel Sambuc    explicit __func(const _Fp& __f, const _Alloc& __a)
13874684ddb6SLionel Sambuc        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
13884684ddb6SLionel Sambuc                                    _VSTD::forward_as_tuple(__a)) {}
13894684ddb6SLionel Sambuc
13904684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
13914684ddb6SLionel Sambuc    explicit __func(const _Fp& __f, _Alloc&& __a)
13924684ddb6SLionel Sambuc        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
13934684ddb6SLionel Sambuc                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
13944684ddb6SLionel Sambuc
13954684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
13964684ddb6SLionel Sambuc    explicit __func(_Fp&& __f, _Alloc&& __a)
13974684ddb6SLionel Sambuc        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
13984684ddb6SLionel Sambuc                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
13994684ddb6SLionel Sambuc    virtual __base<_Rp(_ArgTypes...)>* __clone() const;
14004684ddb6SLionel Sambuc    virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
14014684ddb6SLionel Sambuc    virtual void destroy() _NOEXCEPT;
14024684ddb6SLionel Sambuc    virtual void destroy_deallocate() _NOEXCEPT;
14034684ddb6SLionel Sambuc    virtual _Rp operator()(_ArgTypes&& ... __arg);
14044684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI
14054684ddb6SLionel Sambuc    virtual const void* target(const type_info&) const _NOEXCEPT;
14064684ddb6SLionel Sambuc    virtual const std::type_info& target_type() const _NOEXCEPT;
14074684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_RTTI
14084684ddb6SLionel Sambuc};
14094684ddb6SLionel Sambuc
14104684ddb6SLionel Sambuctemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
14114684ddb6SLionel Sambuc__base<_Rp(_ArgTypes...)>*
14124684ddb6SLionel Sambuc__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
14134684ddb6SLionel Sambuc{
1414*0a6a1f1dSLionel Sambuc    typedef allocator_traits<_Alloc> __alloc_traits;
1415*0a6a1f1dSLionel Sambuc    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
14164684ddb6SLionel Sambuc    _Ap __a(__f_.second());
14174684ddb6SLionel Sambuc    typedef __allocator_destructor<_Ap> _Dp;
14184684ddb6SLionel Sambuc    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
14194684ddb6SLionel Sambuc    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
14204684ddb6SLionel Sambuc    return __hold.release();
14214684ddb6SLionel Sambuc}
14224684ddb6SLionel Sambuc
14234684ddb6SLionel Sambuctemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
14244684ddb6SLionel Sambucvoid
14254684ddb6SLionel Sambuc__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
14264684ddb6SLionel Sambuc{
14274684ddb6SLionel Sambuc    ::new (__p) __func(__f_.first(), __f_.second());
14284684ddb6SLionel Sambuc}
14294684ddb6SLionel Sambuc
14304684ddb6SLionel Sambuctemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
14314684ddb6SLionel Sambucvoid
14324684ddb6SLionel Sambuc__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
14334684ddb6SLionel Sambuc{
14344684ddb6SLionel Sambuc    __f_.~__compressed_pair<_Fp, _Alloc>();
14354684ddb6SLionel Sambuc}
14364684ddb6SLionel Sambuc
14374684ddb6SLionel Sambuctemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
14384684ddb6SLionel Sambucvoid
14394684ddb6SLionel Sambuc__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
14404684ddb6SLionel Sambuc{
1441*0a6a1f1dSLionel Sambuc    typedef allocator_traits<_Alloc> __alloc_traits;
1442*0a6a1f1dSLionel Sambuc    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
14434684ddb6SLionel Sambuc    _Ap __a(__f_.second());
14444684ddb6SLionel Sambuc    __f_.~__compressed_pair<_Fp, _Alloc>();
14454684ddb6SLionel Sambuc    __a.deallocate(this, 1);
14464684ddb6SLionel Sambuc}
14474684ddb6SLionel Sambuc
14484684ddb6SLionel Sambuctemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
14494684ddb6SLionel Sambuc_Rp
14504684ddb6SLionel Sambuc__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
14514684ddb6SLionel Sambuc{
1452*0a6a1f1dSLionel Sambuc    typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1453*0a6a1f1dSLionel Sambuc    return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
14544684ddb6SLionel Sambuc}
14554684ddb6SLionel Sambuc
14564684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI
14574684ddb6SLionel Sambuc
14584684ddb6SLionel Sambuctemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
14594684ddb6SLionel Sambucconst void*
14604684ddb6SLionel Sambuc__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
14614684ddb6SLionel Sambuc{
14624684ddb6SLionel Sambuc    if (__ti == typeid(_Fp))
14634684ddb6SLionel Sambuc        return &__f_.first();
14644684ddb6SLionel Sambuc    return (const void*)0;
14654684ddb6SLionel Sambuc}
14664684ddb6SLionel Sambuc
14674684ddb6SLionel Sambuctemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
14684684ddb6SLionel Sambucconst std::type_info&
14694684ddb6SLionel Sambuc__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
14704684ddb6SLionel Sambuc{
14714684ddb6SLionel Sambuc    return typeid(_Fp);
14724684ddb6SLionel Sambuc}
14734684ddb6SLionel Sambuc
14744684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_RTTI
14754684ddb6SLionel Sambuc
14764684ddb6SLionel Sambuc}  // __function
14774684ddb6SLionel Sambuc
14784684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
14794684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
14804684ddb6SLionel Sambuc    : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
14814684ddb6SLionel Sambuc      public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
14824684ddb6SLionel Sambuc{
14834684ddb6SLionel Sambuc    typedef __function::__base<_Rp(_ArgTypes...)> __base;
14844684ddb6SLionel Sambuc    typename aligned_storage<3*sizeof(void*)>::type __buf_;
14854684ddb6SLionel Sambuc    __base* __f_;
14864684ddb6SLionel Sambuc
14874684ddb6SLionel Sambuc    template <class _Fp, bool = !is_same<_Fp, function>::value &&
14884684ddb6SLionel Sambuc                                __invokable<_Fp&, _ArgTypes...>::value>
14894684ddb6SLionel Sambuc        struct __callable;
14904684ddb6SLionel Sambuc    template <class _Fp>
14914684ddb6SLionel Sambuc        struct __callable<_Fp, true>
14924684ddb6SLionel Sambuc        {
1493*0a6a1f1dSLionel Sambuc            static const bool value = is_same<void, _Rp>::value ||
14944684ddb6SLionel Sambuc                is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
14954684ddb6SLionel Sambuc                               _Rp>::value;
14964684ddb6SLionel Sambuc        };
14974684ddb6SLionel Sambuc    template <class _Fp>
14984684ddb6SLionel Sambuc        struct __callable<_Fp, false>
14994684ddb6SLionel Sambuc        {
15004684ddb6SLionel Sambuc            static const bool value = false;
15014684ddb6SLionel Sambuc        };
15024684ddb6SLionel Sambucpublic:
15034684ddb6SLionel Sambuc    typedef _Rp result_type;
15044684ddb6SLionel Sambuc
15054684ddb6SLionel Sambuc    // construct/copy/destroy:
15064684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
15074684ddb6SLionel Sambuc    function() _NOEXCEPT : __f_(0) {}
15084684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
15094684ddb6SLionel Sambuc    function(nullptr_t) _NOEXCEPT : __f_(0) {}
15104684ddb6SLionel Sambuc    function(const function&);
15114684ddb6SLionel Sambuc    function(function&&) _NOEXCEPT;
15124684ddb6SLionel Sambuc    template<class _Fp>
15134684ddb6SLionel Sambuc      function(_Fp, typename enable_if
15144684ddb6SLionel Sambuc                                     <
15154684ddb6SLionel Sambuc                                        __callable<_Fp>::value &&
15164684ddb6SLionel Sambuc                                        !is_same<_Fp, function>::value
15174684ddb6SLionel Sambuc                                      >::type* = 0);
15184684ddb6SLionel Sambuc
15194684ddb6SLionel Sambuc    template<class _Alloc>
15204684ddb6SLionel Sambuc      _LIBCPP_INLINE_VISIBILITY
15214684ddb6SLionel Sambuc      function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
15224684ddb6SLionel Sambuc    template<class _Alloc>
15234684ddb6SLionel Sambuc      _LIBCPP_INLINE_VISIBILITY
15244684ddb6SLionel Sambuc      function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
15254684ddb6SLionel Sambuc    template<class _Alloc>
15264684ddb6SLionel Sambuc      function(allocator_arg_t, const _Alloc&, const function&);
15274684ddb6SLionel Sambuc    template<class _Alloc>
15284684ddb6SLionel Sambuc      function(allocator_arg_t, const _Alloc&, function&&);
15294684ddb6SLionel Sambuc    template<class _Fp, class _Alloc>
15304684ddb6SLionel Sambuc      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
15314684ddb6SLionel Sambuc               typename enable_if<__callable<_Fp>::value>::type* = 0);
15324684ddb6SLionel Sambuc
15334684ddb6SLionel Sambuc    function& operator=(const function&);
15344684ddb6SLionel Sambuc    function& operator=(function&&) _NOEXCEPT;
15354684ddb6SLionel Sambuc    function& operator=(nullptr_t) _NOEXCEPT;
15364684ddb6SLionel Sambuc    template<class _Fp>
15374684ddb6SLionel Sambuc      typename enable_if
15384684ddb6SLionel Sambuc      <
15394684ddb6SLionel Sambuc        __callable<typename decay<_Fp>::type>::value &&
15404684ddb6SLionel Sambuc        !is_same<typename remove_reference<_Fp>::type, function>::value,
15414684ddb6SLionel Sambuc        function&
15424684ddb6SLionel Sambuc      >::type
15434684ddb6SLionel Sambuc      operator=(_Fp&&);
15444684ddb6SLionel Sambuc
15454684ddb6SLionel Sambuc    ~function();
15464684ddb6SLionel Sambuc
15474684ddb6SLionel Sambuc    // function modifiers:
15484684ddb6SLionel Sambuc    void swap(function&) _NOEXCEPT;
15494684ddb6SLionel Sambuc    template<class _Fp, class _Alloc>
15504684ddb6SLionel Sambuc      _LIBCPP_INLINE_VISIBILITY
15514684ddb6SLionel Sambuc      void assign(_Fp&& __f, const _Alloc& __a)
15524684ddb6SLionel Sambuc        {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
15534684ddb6SLionel Sambuc
15544684ddb6SLionel Sambuc    // function capacity:
15554684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
15564684ddb6SLionel Sambuc        _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
15574684ddb6SLionel Sambuc
15584684ddb6SLionel Sambuc    // deleted overloads close possible hole in the type system
15594684ddb6SLionel Sambuc    template<class _R2, class... _ArgTypes2>
15604684ddb6SLionel Sambuc      bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
15614684ddb6SLionel Sambuc    template<class _R2, class... _ArgTypes2>
15624684ddb6SLionel Sambuc      bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
15634684ddb6SLionel Sambucpublic:
15644684ddb6SLionel Sambuc    // function invocation:
15654684ddb6SLionel Sambuc    _Rp operator()(_ArgTypes...) const;
15664684ddb6SLionel Sambuc
15674684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI
15684684ddb6SLionel Sambuc    // function target access:
15694684ddb6SLionel Sambuc    const std::type_info& target_type() const _NOEXCEPT;
15704684ddb6SLionel Sambuc    template <typename _Tp> _Tp* target() _NOEXCEPT;
15714684ddb6SLionel Sambuc    template <typename _Tp> const _Tp* target() const _NOEXCEPT;
15724684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_RTTI
15734684ddb6SLionel Sambuc};
15744684ddb6SLionel Sambuc
15754684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
15764684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::function(const function& __f)
15774684ddb6SLionel Sambuc{
15784684ddb6SLionel Sambuc    if (__f.__f_ == 0)
15794684ddb6SLionel Sambuc        __f_ = 0;
15804684ddb6SLionel Sambuc    else if (__f.__f_ == (const __base*)&__f.__buf_)
15814684ddb6SLionel Sambuc    {
15824684ddb6SLionel Sambuc        __f_ = (__base*)&__buf_;
15834684ddb6SLionel Sambuc        __f.__f_->__clone(__f_);
15844684ddb6SLionel Sambuc    }
15854684ddb6SLionel Sambuc    else
15864684ddb6SLionel Sambuc        __f_ = __f.__f_->__clone();
15874684ddb6SLionel Sambuc}
15884684ddb6SLionel Sambuc
15894684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
15904684ddb6SLionel Sambuctemplate <class _Alloc>
15914684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
15924684ddb6SLionel Sambuc                                     const function& __f)
15934684ddb6SLionel Sambuc{
15944684ddb6SLionel Sambuc    if (__f.__f_ == 0)
15954684ddb6SLionel Sambuc        __f_ = 0;
15964684ddb6SLionel Sambuc    else if (__f.__f_ == (const __base*)&__f.__buf_)
15974684ddb6SLionel Sambuc    {
15984684ddb6SLionel Sambuc        __f_ = (__base*)&__buf_;
15994684ddb6SLionel Sambuc        __f.__f_->__clone(__f_);
16004684ddb6SLionel Sambuc    }
16014684ddb6SLionel Sambuc    else
16024684ddb6SLionel Sambuc        __f_ = __f.__f_->__clone();
16034684ddb6SLionel Sambuc}
16044684ddb6SLionel Sambuc
16054684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
16064684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
16074684ddb6SLionel Sambuc{
16084684ddb6SLionel Sambuc    if (__f.__f_ == 0)
16094684ddb6SLionel Sambuc        __f_ = 0;
16104684ddb6SLionel Sambuc    else if (__f.__f_ == (__base*)&__f.__buf_)
16114684ddb6SLionel Sambuc    {
16124684ddb6SLionel Sambuc        __f_ = (__base*)&__buf_;
16134684ddb6SLionel Sambuc        __f.__f_->__clone(__f_);
16144684ddb6SLionel Sambuc    }
16154684ddb6SLionel Sambuc    else
16164684ddb6SLionel Sambuc    {
16174684ddb6SLionel Sambuc        __f_ = __f.__f_;
16184684ddb6SLionel Sambuc        __f.__f_ = 0;
16194684ddb6SLionel Sambuc    }
16204684ddb6SLionel Sambuc}
16214684ddb6SLionel Sambuc
16224684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
16234684ddb6SLionel Sambuctemplate <class _Alloc>
16244684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
16254684ddb6SLionel Sambuc                                     function&& __f)
16264684ddb6SLionel Sambuc{
16274684ddb6SLionel Sambuc    if (__f.__f_ == 0)
16284684ddb6SLionel Sambuc        __f_ = 0;
16294684ddb6SLionel Sambuc    else if (__f.__f_ == (__base*)&__f.__buf_)
16304684ddb6SLionel Sambuc    {
16314684ddb6SLionel Sambuc        __f_ = (__base*)&__buf_;
16324684ddb6SLionel Sambuc        __f.__f_->__clone(__f_);
16334684ddb6SLionel Sambuc    }
16344684ddb6SLionel Sambuc    else
16354684ddb6SLionel Sambuc    {
16364684ddb6SLionel Sambuc        __f_ = __f.__f_;
16374684ddb6SLionel Sambuc        __f.__f_ = 0;
16384684ddb6SLionel Sambuc    }
16394684ddb6SLionel Sambuc}
16404684ddb6SLionel Sambuc
16414684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
16424684ddb6SLionel Sambuctemplate <class _Fp>
16434684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::function(_Fp __f,
16444684ddb6SLionel Sambuc                                     typename enable_if
16454684ddb6SLionel Sambuc                                     <
16464684ddb6SLionel Sambuc                                        __callable<_Fp>::value &&
16474684ddb6SLionel Sambuc                                        !is_same<_Fp, function>::value
16484684ddb6SLionel Sambuc                                     >::type*)
16494684ddb6SLionel Sambuc    : __f_(0)
16504684ddb6SLionel Sambuc{
1651*0a6a1f1dSLionel Sambuc    if (__function::__not_null(__f))
16524684ddb6SLionel Sambuc    {
16534684ddb6SLionel Sambuc        typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
16544684ddb6SLionel Sambuc        if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
16554684ddb6SLionel Sambuc        {
16564684ddb6SLionel Sambuc            __f_ = (__base*)&__buf_;
16574684ddb6SLionel Sambuc            ::new (__f_) _FF(_VSTD::move(__f));
16584684ddb6SLionel Sambuc        }
16594684ddb6SLionel Sambuc        else
16604684ddb6SLionel Sambuc        {
16614684ddb6SLionel Sambuc            typedef allocator<_FF> _Ap;
16624684ddb6SLionel Sambuc            _Ap __a;
16634684ddb6SLionel Sambuc            typedef __allocator_destructor<_Ap> _Dp;
16644684ddb6SLionel Sambuc            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
16654684ddb6SLionel Sambuc            ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
16664684ddb6SLionel Sambuc            __f_ = __hold.release();
16674684ddb6SLionel Sambuc        }
16684684ddb6SLionel Sambuc    }
16694684ddb6SLionel Sambuc}
16704684ddb6SLionel Sambuc
16714684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
16724684ddb6SLionel Sambuctemplate <class _Fp, class _Alloc>
16734684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
16744684ddb6SLionel Sambuc                                     typename enable_if<__callable<_Fp>::value>::type*)
16754684ddb6SLionel Sambuc    : __f_(0)
16764684ddb6SLionel Sambuc{
16774684ddb6SLionel Sambuc    typedef allocator_traits<_Alloc> __alloc_traits;
1678*0a6a1f1dSLionel Sambuc    if (__function::__not_null(__f))
16794684ddb6SLionel Sambuc    {
16804684ddb6SLionel Sambuc        typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
1681*0a6a1f1dSLionel Sambuc        typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1682*0a6a1f1dSLionel Sambuc        _Ap __a(__a0);
1683*0a6a1f1dSLionel Sambuc        if (sizeof(_FF) <= sizeof(__buf_) &&
1684*0a6a1f1dSLionel Sambuc            is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
16854684ddb6SLionel Sambuc        {
16864684ddb6SLionel Sambuc            __f_ = (__base*)&__buf_;
1687*0a6a1f1dSLionel Sambuc            ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));
16884684ddb6SLionel Sambuc        }
16894684ddb6SLionel Sambuc        else
16904684ddb6SLionel Sambuc        {
16914684ddb6SLionel Sambuc            typedef __allocator_destructor<_Ap> _Dp;
16924684ddb6SLionel Sambuc            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
16934684ddb6SLionel Sambuc            ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
16944684ddb6SLionel Sambuc            __f_ = __hold.release();
16954684ddb6SLionel Sambuc        }
16964684ddb6SLionel Sambuc    }
16974684ddb6SLionel Sambuc}
16984684ddb6SLionel Sambuc
16994684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
17004684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>&
17014684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::operator=(const function& __f)
17024684ddb6SLionel Sambuc{
17034684ddb6SLionel Sambuc    function(__f).swap(*this);
17044684ddb6SLionel Sambuc    return *this;
17054684ddb6SLionel Sambuc}
17064684ddb6SLionel Sambuc
17074684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
17084684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>&
17094684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
17104684ddb6SLionel Sambuc{
17114684ddb6SLionel Sambuc    if (__f_ == (__base*)&__buf_)
17124684ddb6SLionel Sambuc        __f_->destroy();
17134684ddb6SLionel Sambuc    else if (__f_)
17144684ddb6SLionel Sambuc        __f_->destroy_deallocate();
17154684ddb6SLionel Sambuc    __f_ = 0;
17164684ddb6SLionel Sambuc    if (__f.__f_ == 0)
17174684ddb6SLionel Sambuc        __f_ = 0;
17184684ddb6SLionel Sambuc    else if (__f.__f_ == (__base*)&__f.__buf_)
17194684ddb6SLionel Sambuc    {
17204684ddb6SLionel Sambuc        __f_ = (__base*)&__buf_;
17214684ddb6SLionel Sambuc        __f.__f_->__clone(__f_);
17224684ddb6SLionel Sambuc    }
17234684ddb6SLionel Sambuc    else
17244684ddb6SLionel Sambuc    {
17254684ddb6SLionel Sambuc        __f_ = __f.__f_;
17264684ddb6SLionel Sambuc        __f.__f_ = 0;
17274684ddb6SLionel Sambuc    }
17284684ddb6SLionel Sambuc    return *this;
17294684ddb6SLionel Sambuc}
17304684ddb6SLionel Sambuc
17314684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
17324684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>&
17334684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
17344684ddb6SLionel Sambuc{
17354684ddb6SLionel Sambuc    if (__f_ == (__base*)&__buf_)
17364684ddb6SLionel Sambuc        __f_->destroy();
17374684ddb6SLionel Sambuc    else if (__f_)
17384684ddb6SLionel Sambuc        __f_->destroy_deallocate();
17394684ddb6SLionel Sambuc    __f_ = 0;
17404684ddb6SLionel Sambuc    return *this;
17414684ddb6SLionel Sambuc}
17424684ddb6SLionel Sambuc
17434684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
17444684ddb6SLionel Sambuctemplate <class _Fp>
17454684ddb6SLionel Sambuctypename enable_if
17464684ddb6SLionel Sambuc<
17474684ddb6SLionel Sambuc    function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
17484684ddb6SLionel Sambuc    !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
17494684ddb6SLionel Sambuc    function<_Rp(_ArgTypes...)>&
17504684ddb6SLionel Sambuc>::type
17514684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
17524684ddb6SLionel Sambuc{
17534684ddb6SLionel Sambuc    function(_VSTD::forward<_Fp>(__f)).swap(*this);
17544684ddb6SLionel Sambuc    return *this;
17554684ddb6SLionel Sambuc}
17564684ddb6SLionel Sambuc
17574684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
17584684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::~function()
17594684ddb6SLionel Sambuc{
17604684ddb6SLionel Sambuc    if (__f_ == (__base*)&__buf_)
17614684ddb6SLionel Sambuc        __f_->destroy();
17624684ddb6SLionel Sambuc    else if (__f_)
17634684ddb6SLionel Sambuc        __f_->destroy_deallocate();
17644684ddb6SLionel Sambuc}
17654684ddb6SLionel Sambuc
17664684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
17674684ddb6SLionel Sambucvoid
17684684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
17694684ddb6SLionel Sambuc{
17704684ddb6SLionel Sambuc    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
17714684ddb6SLionel Sambuc    {
17724684ddb6SLionel Sambuc        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
17734684ddb6SLionel Sambuc        __base* __t = (__base*)&__tempbuf;
17744684ddb6SLionel Sambuc        __f_->__clone(__t);
17754684ddb6SLionel Sambuc        __f_->destroy();
17764684ddb6SLionel Sambuc        __f_ = 0;
17774684ddb6SLionel Sambuc        __f.__f_->__clone((__base*)&__buf_);
17784684ddb6SLionel Sambuc        __f.__f_->destroy();
17794684ddb6SLionel Sambuc        __f.__f_ = 0;
17804684ddb6SLionel Sambuc        __f_ = (__base*)&__buf_;
17814684ddb6SLionel Sambuc        __t->__clone((__base*)&__f.__buf_);
17824684ddb6SLionel Sambuc        __t->destroy();
17834684ddb6SLionel Sambuc        __f.__f_ = (__base*)&__f.__buf_;
17844684ddb6SLionel Sambuc    }
17854684ddb6SLionel Sambuc    else if (__f_ == (__base*)&__buf_)
17864684ddb6SLionel Sambuc    {
17874684ddb6SLionel Sambuc        __f_->__clone((__base*)&__f.__buf_);
17884684ddb6SLionel Sambuc        __f_->destroy();
17894684ddb6SLionel Sambuc        __f_ = __f.__f_;
17904684ddb6SLionel Sambuc        __f.__f_ = (__base*)&__f.__buf_;
17914684ddb6SLionel Sambuc    }
17924684ddb6SLionel Sambuc    else if (__f.__f_ == (__base*)&__f.__buf_)
17934684ddb6SLionel Sambuc    {
17944684ddb6SLionel Sambuc        __f.__f_->__clone((__base*)&__buf_);
17954684ddb6SLionel Sambuc        __f.__f_->destroy();
17964684ddb6SLionel Sambuc        __f.__f_ = __f_;
17974684ddb6SLionel Sambuc        __f_ = (__base*)&__buf_;
17984684ddb6SLionel Sambuc    }
17994684ddb6SLionel Sambuc    else
18004684ddb6SLionel Sambuc        _VSTD::swap(__f_, __f.__f_);
18014684ddb6SLionel Sambuc}
18024684ddb6SLionel Sambuc
18034684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
18044684ddb6SLionel Sambuc_Rp
18054684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
18064684ddb6SLionel Sambuc{
18074684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
18084684ddb6SLionel Sambuc    if (__f_ == 0)
18094684ddb6SLionel Sambuc        throw bad_function_call();
18104684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
18114684ddb6SLionel Sambuc    return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
18124684ddb6SLionel Sambuc}
18134684ddb6SLionel Sambuc
18144684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI
18154684ddb6SLionel Sambuc
18164684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
18174684ddb6SLionel Sambucconst std::type_info&
18184684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
18194684ddb6SLionel Sambuc{
18204684ddb6SLionel Sambuc    if (__f_ == 0)
18214684ddb6SLionel Sambuc        return typeid(void);
18224684ddb6SLionel Sambuc    return __f_->target_type();
18234684ddb6SLionel Sambuc}
18244684ddb6SLionel Sambuc
18254684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
18264684ddb6SLionel Sambuctemplate <typename _Tp>
18274684ddb6SLionel Sambuc_Tp*
18284684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::target() _NOEXCEPT
18294684ddb6SLionel Sambuc{
18304684ddb6SLionel Sambuc    if (__f_ == 0)
18314684ddb6SLionel Sambuc        return (_Tp*)0;
18324684ddb6SLionel Sambuc    return (_Tp*)__f_->target(typeid(_Tp));
18334684ddb6SLionel Sambuc}
18344684ddb6SLionel Sambuc
18354684ddb6SLionel Sambuctemplate<class _Rp, class ..._ArgTypes>
18364684ddb6SLionel Sambuctemplate <typename _Tp>
18374684ddb6SLionel Sambucconst _Tp*
18384684ddb6SLionel Sambucfunction<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
18394684ddb6SLionel Sambuc{
18404684ddb6SLionel Sambuc    if (__f_ == 0)
18414684ddb6SLionel Sambuc        return (const _Tp*)0;
18424684ddb6SLionel Sambuc    return (const _Tp*)__f_->target(typeid(_Tp));
18434684ddb6SLionel Sambuc}
18444684ddb6SLionel Sambuc
18454684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_RTTI
18464684ddb6SLionel Sambuc
18474684ddb6SLionel Sambuctemplate <class _Rp, class... _ArgTypes>
18484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
18494684ddb6SLionel Sambucbool
18504684ddb6SLionel Sambucoperator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
18514684ddb6SLionel Sambuc
18524684ddb6SLionel Sambuctemplate <class _Rp, class... _ArgTypes>
18534684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
18544684ddb6SLionel Sambucbool
18554684ddb6SLionel Sambucoperator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
18564684ddb6SLionel Sambuc
18574684ddb6SLionel Sambuctemplate <class _Rp, class... _ArgTypes>
18584684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
18594684ddb6SLionel Sambucbool
18604684ddb6SLionel Sambucoperator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
18614684ddb6SLionel Sambuc
18624684ddb6SLionel Sambuctemplate <class _Rp, class... _ArgTypes>
18634684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
18644684ddb6SLionel Sambucbool
18654684ddb6SLionel Sambucoperator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
18664684ddb6SLionel Sambuc
18674684ddb6SLionel Sambuctemplate <class _Rp, class... _ArgTypes>
18684684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
18694684ddb6SLionel Sambucvoid
18704684ddb6SLionel Sambucswap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
18714684ddb6SLionel Sambuc{return __x.swap(__y);}
18724684ddb6SLionel Sambuc
1873*0a6a1f1dSLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS
1874*0a6a1f1dSLionel Sambuc
1875*0a6a1f1dSLionel Sambuc#include <__functional_03>
1876*0a6a1f1dSLionel Sambuc
1877*0a6a1f1dSLionel Sambuc#endif
1878*0a6a1f1dSLionel Sambuc
1879*0a6a1f1dSLionel Sambuc////////////////////////////////////////////////////////////////////////////////
1880*0a6a1f1dSLionel Sambuc//                                  BIND
1881*0a6a1f1dSLionel Sambuc//==============================================================================
1882*0a6a1f1dSLionel Sambuc
18834684ddb6SLionel Sambuctemplate<class _Tp> struct __is_bind_expression : public false_type {};
18844684ddb6SLionel Sambuctemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
18854684ddb6SLionel Sambuc    : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
18864684ddb6SLionel Sambuc
18874684ddb6SLionel Sambuctemplate<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
18884684ddb6SLionel Sambuctemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
18894684ddb6SLionel Sambuc    : public __is_placeholder<typename remove_cv<_Tp>::type> {};
18904684ddb6SLionel Sambuc
18914684ddb6SLionel Sambucnamespace placeholders
18924684ddb6SLionel Sambuc{
18934684ddb6SLionel Sambuc
18944684ddb6SLionel Sambuctemplate <int _Np> struct __ph {};
18954684ddb6SLionel Sambuc
18964684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<1>   _1;
18974684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<2>   _2;
18984684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<3>   _3;
18994684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<4>   _4;
19004684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<5>   _5;
19014684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<6>   _6;
19024684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<7>   _7;
19034684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<8>   _8;
19044684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<9>   _9;
19054684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS extern __ph<10> _10;
19064684ddb6SLionel Sambuc
19074684ddb6SLionel Sambuc}  // placeholders
19084684ddb6SLionel Sambuc
19094684ddb6SLionel Sambuctemplate<int _Np>
19104684ddb6SLionel Sambucstruct __is_placeholder<placeholders::__ph<_Np> >
19114684ddb6SLionel Sambuc    : public integral_constant<int, _Np> {};
19124684ddb6SLionel Sambuc
1913*0a6a1f1dSLionel Sambuc
1914*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS
1915*0a6a1f1dSLionel Sambuc
19164684ddb6SLionel Sambuctemplate <class _Tp, class _Uj>
19174684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
19184684ddb6SLionel Sambuc_Tp&
19194684ddb6SLionel Sambuc__mu(reference_wrapper<_Tp> __t, _Uj&)
19204684ddb6SLionel Sambuc{
19214684ddb6SLionel Sambuc    return __t.get();
19224684ddb6SLionel Sambuc}
19234684ddb6SLionel Sambuc
19244684ddb6SLionel Sambuctemplate <class _Ti, class ..._Uj, size_t ..._Indx>
19254684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
19264684ddb6SLionel Sambuctypename __invoke_of<_Ti&, _Uj...>::type
19274684ddb6SLionel Sambuc__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
19284684ddb6SLionel Sambuc{
1929*0a6a1f1dSLionel Sambuc    return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
19304684ddb6SLionel Sambuc}
19314684ddb6SLionel Sambuc
19324684ddb6SLionel Sambuctemplate <class _Ti, class ..._Uj>
19334684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1934*0a6a1f1dSLionel Sambuctypename __lazy_enable_if
19354684ddb6SLionel Sambuc<
19364684ddb6SLionel Sambuc    is_bind_expression<_Ti>::value,
1937*0a6a1f1dSLionel Sambuc    __invoke_of<_Ti&, _Uj...>
19384684ddb6SLionel Sambuc>::type
19394684ddb6SLionel Sambuc__mu(_Ti& __ti, tuple<_Uj...>& __uj)
19404684ddb6SLionel Sambuc{
19414684ddb6SLionel Sambuc    typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
19424684ddb6SLionel Sambuc    return  __mu_expand(__ti, __uj, __indices());
19434684ddb6SLionel Sambuc}
19444684ddb6SLionel Sambuc
19454684ddb6SLionel Sambuctemplate <bool IsPh, class _Ti, class _Uj>
19464684ddb6SLionel Sambucstruct __mu_return2 {};
19474684ddb6SLionel Sambuc
19484684ddb6SLionel Sambuctemplate <class _Ti, class _Uj>
19494684ddb6SLionel Sambucstruct __mu_return2<true, _Ti, _Uj>
19504684ddb6SLionel Sambuc{
19514684ddb6SLionel Sambuc    typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
19524684ddb6SLionel Sambuc};
19534684ddb6SLionel Sambuc
19544684ddb6SLionel Sambuctemplate <class _Ti, class _Uj>
19554684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
19564684ddb6SLionel Sambuctypename enable_if
19574684ddb6SLionel Sambuc<
19584684ddb6SLionel Sambuc    0 < is_placeholder<_Ti>::value,
19594684ddb6SLionel Sambuc    typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
19604684ddb6SLionel Sambuc>::type
19614684ddb6SLionel Sambuc__mu(_Ti&, _Uj& __uj)
19624684ddb6SLionel Sambuc{
19634684ddb6SLionel Sambuc    const size_t _Indx = is_placeholder<_Ti>::value - 1;
1964*0a6a1f1dSLionel Sambuc    return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
19654684ddb6SLionel Sambuc}
19664684ddb6SLionel Sambuc
19674684ddb6SLionel Sambuctemplate <class _Ti, class _Uj>
19684684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
19694684ddb6SLionel Sambuctypename enable_if
19704684ddb6SLionel Sambuc<
19714684ddb6SLionel Sambuc    !is_bind_expression<_Ti>::value &&
19724684ddb6SLionel Sambuc    is_placeholder<_Ti>::value == 0 &&
19734684ddb6SLionel Sambuc    !__is_reference_wrapper<_Ti>::value,
19744684ddb6SLionel Sambuc    _Ti&
19754684ddb6SLionel Sambuc>::type
19764684ddb6SLionel Sambuc__mu(_Ti& __ti, _Uj&)
19774684ddb6SLionel Sambuc{
19784684ddb6SLionel Sambuc    return __ti;
19794684ddb6SLionel Sambuc}
19804684ddb6SLionel Sambuc
19814684ddb6SLionel Sambuctemplate <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
19824684ddb6SLionel Sambuc          class _TupleUj>
19834684ddb6SLionel Sambucstruct ____mu_return;
19844684ddb6SLionel Sambuc
19854684ddb6SLionel Sambuctemplate <bool _Invokable, class _Ti, class ..._Uj>
19864684ddb6SLionel Sambucstruct ____mu_return_invokable  // false
19874684ddb6SLionel Sambuc{
19884684ddb6SLionel Sambuc    typedef __nat type;
19894684ddb6SLionel Sambuc};
19904684ddb6SLionel Sambuc
19914684ddb6SLionel Sambuctemplate <class _Ti, class ..._Uj>
19924684ddb6SLionel Sambucstruct ____mu_return_invokable<true, _Ti, _Uj...>
19934684ddb6SLionel Sambuc{
19944684ddb6SLionel Sambuc    typedef typename __invoke_of<_Ti&, _Uj...>::type type;
19954684ddb6SLionel Sambuc};
19964684ddb6SLionel Sambuc
19974684ddb6SLionel Sambuctemplate <class _Ti, class ..._Uj>
19984684ddb6SLionel Sambucstruct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
19994684ddb6SLionel Sambuc    : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
20004684ddb6SLionel Sambuc{
20014684ddb6SLionel Sambuc};
20024684ddb6SLionel Sambuc
20034684ddb6SLionel Sambuctemplate <class _Ti, class _TupleUj>
20044684ddb6SLionel Sambucstruct ____mu_return<_Ti, false, false, true, _TupleUj>
20054684ddb6SLionel Sambuc{
20064684ddb6SLionel Sambuc    typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
20074684ddb6SLionel Sambuc                                   _TupleUj>::type&& type;
20084684ddb6SLionel Sambuc};
20094684ddb6SLionel Sambuc
20104684ddb6SLionel Sambuctemplate <class _Ti, class _TupleUj>
20114684ddb6SLionel Sambucstruct ____mu_return<_Ti, true, false, false, _TupleUj>
20124684ddb6SLionel Sambuc{
20134684ddb6SLionel Sambuc    typedef typename _Ti::type& type;
20144684ddb6SLionel Sambuc};
20154684ddb6SLionel Sambuc
20164684ddb6SLionel Sambuctemplate <class _Ti, class _TupleUj>
20174684ddb6SLionel Sambucstruct ____mu_return<_Ti, false, false, false, _TupleUj>
20184684ddb6SLionel Sambuc{
20194684ddb6SLionel Sambuc    typedef _Ti& type;
20204684ddb6SLionel Sambuc};
20214684ddb6SLionel Sambuc
20224684ddb6SLionel Sambuctemplate <class _Ti, class _TupleUj>
20234684ddb6SLionel Sambucstruct __mu_return
20244684ddb6SLionel Sambuc    : public ____mu_return<_Ti,
20254684ddb6SLionel Sambuc                           __is_reference_wrapper<_Ti>::value,
20264684ddb6SLionel Sambuc                           is_bind_expression<_Ti>::value,
20274684ddb6SLionel Sambuc                           0 < is_placeholder<_Ti>::value &&
20284684ddb6SLionel Sambuc                           is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
20294684ddb6SLionel Sambuc                           _TupleUj>
20304684ddb6SLionel Sambuc{
20314684ddb6SLionel Sambuc};
20324684ddb6SLionel Sambuc
20334684ddb6SLionel Sambuctemplate <class _Fp, class _BoundArgs, class _TupleUj>
2034*0a6a1f1dSLionel Sambucstruct __is_valid_bind_return
20354684ddb6SLionel Sambuc{
20364684ddb6SLionel Sambuc    static const bool value = false;
20374684ddb6SLionel Sambuc};
20384684ddb6SLionel Sambuc
20394684ddb6SLionel Sambuctemplate <class _Fp, class ..._BoundArgs, class _TupleUj>
2040*0a6a1f1dSLionel Sambucstruct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
20414684ddb6SLionel Sambuc{
20424684ddb6SLionel Sambuc    static const bool value = __invokable<_Fp,
20434684ddb6SLionel Sambuc                    typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
20444684ddb6SLionel Sambuc};
20454684ddb6SLionel Sambuc
20464684ddb6SLionel Sambuctemplate <class _Fp, class ..._BoundArgs, class _TupleUj>
2047*0a6a1f1dSLionel Sambucstruct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
20484684ddb6SLionel Sambuc{
20494684ddb6SLionel Sambuc    static const bool value = __invokable<_Fp,
20504684ddb6SLionel Sambuc                    typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
20514684ddb6SLionel Sambuc};
20524684ddb6SLionel Sambuc
20534684ddb6SLionel Sambuctemplate <class _Fp, class _BoundArgs, class _TupleUj,
2054*0a6a1f1dSLionel Sambuc          bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
20554684ddb6SLionel Sambucstruct __bind_return;
20564684ddb6SLionel Sambuc
20574684ddb6SLionel Sambuctemplate <class _Fp, class ..._BoundArgs, class _TupleUj>
20584684ddb6SLionel Sambucstruct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
20594684ddb6SLionel Sambuc{
20604684ddb6SLionel Sambuc    typedef typename __invoke_of
20614684ddb6SLionel Sambuc    <
20624684ddb6SLionel Sambuc        _Fp&,
20634684ddb6SLionel Sambuc        typename __mu_return
20644684ddb6SLionel Sambuc        <
20654684ddb6SLionel Sambuc            _BoundArgs,
20664684ddb6SLionel Sambuc            _TupleUj
20674684ddb6SLionel Sambuc        >::type...
20684684ddb6SLionel Sambuc    >::type type;
20694684ddb6SLionel Sambuc};
20704684ddb6SLionel Sambuc
20714684ddb6SLionel Sambuctemplate <class _Fp, class ..._BoundArgs, class _TupleUj>
20724684ddb6SLionel Sambucstruct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
20734684ddb6SLionel Sambuc{
20744684ddb6SLionel Sambuc    typedef typename __invoke_of
20754684ddb6SLionel Sambuc    <
20764684ddb6SLionel Sambuc        _Fp&,
20774684ddb6SLionel Sambuc        typename __mu_return
20784684ddb6SLionel Sambuc        <
20794684ddb6SLionel Sambuc            const _BoundArgs,
20804684ddb6SLionel Sambuc            _TupleUj
20814684ddb6SLionel Sambuc        >::type...
20824684ddb6SLionel Sambuc    >::type type;
20834684ddb6SLionel Sambuc};
20844684ddb6SLionel Sambuc
20854684ddb6SLionel Sambuctemplate <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
20864684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
20874684ddb6SLionel Sambuctypename __bind_return<_Fp, _BoundArgs, _Args>::type
20884684ddb6SLionel Sambuc__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
20894684ddb6SLionel Sambuc                _Args&& __args)
20904684ddb6SLionel Sambuc{
2091*0a6a1f1dSLionel Sambuc    return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
20924684ddb6SLionel Sambuc}
20934684ddb6SLionel Sambuc
20944684ddb6SLionel Sambuctemplate<class _Fp, class ..._BoundArgs>
20954684ddb6SLionel Sambucclass __bind
20964684ddb6SLionel Sambuc    : public __weak_result_type<typename decay<_Fp>::type>
20974684ddb6SLionel Sambuc{
20984684ddb6SLionel Sambucprotected:
20994684ddb6SLionel Sambuc    typedef typename decay<_Fp>::type _Fd;
21004684ddb6SLionel Sambuc    typedef tuple<typename decay<_BoundArgs>::type...> _Td;
21014684ddb6SLionel Sambucprivate:
21024684ddb6SLionel Sambuc    _Fd __f_;
21034684ddb6SLionel Sambuc    _Td __bound_args_;
21044684ddb6SLionel Sambuc
21054684ddb6SLionel Sambuc    typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
21064684ddb6SLionel Sambucpublic:
21074684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
21084684ddb6SLionel Sambuc
21094684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
21104684ddb6SLionel Sambuc    __bind(const __bind& __b)
21114684ddb6SLionel Sambuc        : __f_(__b.__f_),
21124684ddb6SLionel Sambuc          __bound_args_(__b.__bound_args_) {}
21134684ddb6SLionel Sambuc
21144684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
21154684ddb6SLionel Sambuc    __bind& operator=(const __bind& __b)
21164684ddb6SLionel Sambuc    {
21174684ddb6SLionel Sambuc        __f_ = __b.__f_;
21184684ddb6SLionel Sambuc        __bound_args_ = __b.__bound_args_;
21194684ddb6SLionel Sambuc        return *this;
21204684ddb6SLionel Sambuc    }
21214684ddb6SLionel Sambuc
21224684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
21234684ddb6SLionel Sambuc    __bind(__bind&& __b)
21244684ddb6SLionel Sambuc        : __f_(_VSTD::move(__b.__f_)),
21254684ddb6SLionel Sambuc          __bound_args_(_VSTD::move(__b.__bound_args_)) {}
21264684ddb6SLionel Sambuc
21274684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
21284684ddb6SLionel Sambuc    __bind& operator=(__bind&& __b)
21294684ddb6SLionel Sambuc    {
21304684ddb6SLionel Sambuc        __f_ = _VSTD::move(__b.__f_);
21314684ddb6SLionel Sambuc        __bound_args_ = _VSTD::move(__b.__bound_args_);
21324684ddb6SLionel Sambuc        return *this;
21334684ddb6SLionel Sambuc    }
21344684ddb6SLionel Sambuc
21354684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
21364684ddb6SLionel Sambuc
21374684ddb6SLionel Sambuc    template <class _Gp, class ..._BA,
21384684ddb6SLionel Sambuc              class = typename enable_if
21394684ddb6SLionel Sambuc                               <
21404684ddb6SLionel Sambuc                                  is_constructible<_Fd, _Gp>::value &&
21414684ddb6SLionel Sambuc                                  !is_same<typename remove_reference<_Gp>::type,
21424684ddb6SLionel Sambuc                                           __bind>::value
21434684ddb6SLionel Sambuc                               >::type>
21444684ddb6SLionel Sambuc      _LIBCPP_INLINE_VISIBILITY
21454684ddb6SLionel Sambuc      explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
21464684ddb6SLionel Sambuc        : __f_(_VSTD::forward<_Gp>(__f)),
21474684ddb6SLionel Sambuc          __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
21484684ddb6SLionel Sambuc
21494684ddb6SLionel Sambuc    template <class ..._Args>
21504684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
21514684ddb6SLionel Sambuc        typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
21524684ddb6SLionel Sambuc        operator()(_Args&& ...__args)
21534684ddb6SLionel Sambuc        {
21544684ddb6SLionel Sambuc            return __apply_functor(__f_, __bound_args_, __indices(),
21554684ddb6SLionel Sambuc                                  tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
21564684ddb6SLionel Sambuc        }
21574684ddb6SLionel Sambuc
21584684ddb6SLionel Sambuc    template <class ..._Args>
21594684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
21604684ddb6SLionel Sambuc        typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
21614684ddb6SLionel Sambuc        operator()(_Args&& ...__args) const
21624684ddb6SLionel Sambuc        {
21634684ddb6SLionel Sambuc            return __apply_functor(__f_, __bound_args_, __indices(),
21644684ddb6SLionel Sambuc                                   tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
21654684ddb6SLionel Sambuc        }
21664684ddb6SLionel Sambuc};
21674684ddb6SLionel Sambuc
21684684ddb6SLionel Sambuctemplate<class _Fp, class ..._BoundArgs>
21694684ddb6SLionel Sambucstruct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
21704684ddb6SLionel Sambuc
21714684ddb6SLionel Sambuctemplate<class _Rp, class _Fp, class ..._BoundArgs>
21724684ddb6SLionel Sambucclass __bind_r
21734684ddb6SLionel Sambuc    : public __bind<_Fp, _BoundArgs...>
21744684ddb6SLionel Sambuc{
21754684ddb6SLionel Sambuc    typedef __bind<_Fp, _BoundArgs...> base;
21764684ddb6SLionel Sambuc    typedef typename base::_Fd _Fd;
21774684ddb6SLionel Sambuc    typedef typename base::_Td _Td;
21784684ddb6SLionel Sambucpublic:
21794684ddb6SLionel Sambuc    typedef _Rp result_type;
21804684ddb6SLionel Sambuc
21814684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
21824684ddb6SLionel Sambuc
21834684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
21844684ddb6SLionel Sambuc    __bind_r(const __bind_r& __b)
21854684ddb6SLionel Sambuc        : base(_VSTD::forward<const base&>(__b)) {}
21864684ddb6SLionel Sambuc
21874684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
21884684ddb6SLionel Sambuc    __bind_r& operator=(const __bind_r& __b)
21894684ddb6SLionel Sambuc    {
21904684ddb6SLionel Sambuc        base::operator=(_VSTD::forward<const base&>(__b));
21914684ddb6SLionel Sambuc        return *this;
21924684ddb6SLionel Sambuc    }
21934684ddb6SLionel Sambuc
21944684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
21954684ddb6SLionel Sambuc    __bind_r(__bind_r&& __b)
21964684ddb6SLionel Sambuc        : base(_VSTD::forward<base>(__b)) {}
21974684ddb6SLionel Sambuc
21984684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
21994684ddb6SLionel Sambuc    __bind_r& operator=(__bind_r&& __b)
22004684ddb6SLionel Sambuc    {
22014684ddb6SLionel Sambuc        base::operator=(_VSTD::forward<base>(__b));
22024684ddb6SLionel Sambuc        return *this;
22034684ddb6SLionel Sambuc    }
22044684ddb6SLionel Sambuc
22054684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
22064684ddb6SLionel Sambuc
22074684ddb6SLionel Sambuc    template <class _Gp, class ..._BA,
22084684ddb6SLionel Sambuc              class = typename enable_if
22094684ddb6SLionel Sambuc                               <
22104684ddb6SLionel Sambuc                                  is_constructible<_Fd, _Gp>::value &&
22114684ddb6SLionel Sambuc                                  !is_same<typename remove_reference<_Gp>::type,
22124684ddb6SLionel Sambuc                                           __bind_r>::value
22134684ddb6SLionel Sambuc                               >::type>
22144684ddb6SLionel Sambuc      _LIBCPP_INLINE_VISIBILITY
22154684ddb6SLionel Sambuc      explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
22164684ddb6SLionel Sambuc        : base(_VSTD::forward<_Gp>(__f),
22174684ddb6SLionel Sambuc               _VSTD::forward<_BA>(__bound_args)...) {}
22184684ddb6SLionel Sambuc
22194684ddb6SLionel Sambuc    template <class ..._Args>
22204684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
22214684ddb6SLionel Sambuc        typename enable_if
22224684ddb6SLionel Sambuc        <
22234684ddb6SLionel Sambuc            is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
2224*0a6a1f1dSLionel Sambuc                           result_type>::value || is_void<_Rp>::value,
22254684ddb6SLionel Sambuc            result_type
22264684ddb6SLionel Sambuc        >::type
22274684ddb6SLionel Sambuc        operator()(_Args&& ...__args)
22284684ddb6SLionel Sambuc        {
2229*0a6a1f1dSLionel Sambuc            typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2230*0a6a1f1dSLionel Sambuc            return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
22314684ddb6SLionel Sambuc        }
22324684ddb6SLionel Sambuc
22334684ddb6SLionel Sambuc    template <class ..._Args>
22344684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
22354684ddb6SLionel Sambuc        typename enable_if
22364684ddb6SLionel Sambuc        <
22374684ddb6SLionel Sambuc            is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
2238*0a6a1f1dSLionel Sambuc                           result_type>::value || is_void<_Rp>::value,
22394684ddb6SLionel Sambuc            result_type
22404684ddb6SLionel Sambuc        >::type
22414684ddb6SLionel Sambuc        operator()(_Args&& ...__args) const
22424684ddb6SLionel Sambuc        {
2243*0a6a1f1dSLionel Sambuc            typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2244*0a6a1f1dSLionel Sambuc            return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
22454684ddb6SLionel Sambuc        }
22464684ddb6SLionel Sambuc};
22474684ddb6SLionel Sambuc
22484684ddb6SLionel Sambuctemplate<class _Rp, class _Fp, class ..._BoundArgs>
22494684ddb6SLionel Sambucstruct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
22504684ddb6SLionel Sambuc
22514684ddb6SLionel Sambuctemplate<class _Fp, class ..._BoundArgs>
22524684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
22534684ddb6SLionel Sambuc__bind<_Fp, _BoundArgs...>
22544684ddb6SLionel Sambucbind(_Fp&& __f, _BoundArgs&&... __bound_args)
22554684ddb6SLionel Sambuc{
22564684ddb6SLionel Sambuc    typedef __bind<_Fp, _BoundArgs...> type;
22574684ddb6SLionel Sambuc    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
22584684ddb6SLionel Sambuc}
22594684ddb6SLionel Sambuc
22604684ddb6SLionel Sambuctemplate<class _Rp, class _Fp, class ..._BoundArgs>
22614684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
22624684ddb6SLionel Sambuc__bind_r<_Rp, _Fp, _BoundArgs...>
22634684ddb6SLionel Sambucbind(_Fp&& __f, _BoundArgs&&... __bound_args)
22644684ddb6SLionel Sambuc{
22654684ddb6SLionel Sambuc    typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
22664684ddb6SLionel Sambuc    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
22674684ddb6SLionel Sambuc}
22684684ddb6SLionel Sambuc
22694684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_VARIADICS
22704684ddb6SLionel Sambuc
22714684ddb6SLionel Sambuctemplate <>
22724684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<bool>
22734684ddb6SLionel Sambuc    : public unary_function<bool, size_t>
22744684ddb6SLionel Sambuc{
22754684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
22764684ddb6SLionel Sambuc    size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
22774684ddb6SLionel Sambuc};
22784684ddb6SLionel Sambuc
22794684ddb6SLionel Sambuctemplate <>
22804684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<char>
22814684ddb6SLionel Sambuc    : public unary_function<char, size_t>
22824684ddb6SLionel Sambuc{
22834684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
22844684ddb6SLionel Sambuc    size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
22854684ddb6SLionel Sambuc};
22864684ddb6SLionel Sambuc
22874684ddb6SLionel Sambuctemplate <>
22884684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
22894684ddb6SLionel Sambuc    : public unary_function<signed char, size_t>
22904684ddb6SLionel Sambuc{
22914684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
22924684ddb6SLionel Sambuc    size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
22934684ddb6SLionel Sambuc};
22944684ddb6SLionel Sambuc
22954684ddb6SLionel Sambuctemplate <>
22964684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
22974684ddb6SLionel Sambuc    : public unary_function<unsigned char, size_t>
22984684ddb6SLionel Sambuc{
22994684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23004684ddb6SLionel Sambuc    size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23014684ddb6SLionel Sambuc};
23024684ddb6SLionel Sambuc
23034684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
23044684ddb6SLionel Sambuc
23054684ddb6SLionel Sambuctemplate <>
23064684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<char16_t>
23074684ddb6SLionel Sambuc    : public unary_function<char16_t, size_t>
23084684ddb6SLionel Sambuc{
23094684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23104684ddb6SLionel Sambuc    size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23114684ddb6SLionel Sambuc};
23124684ddb6SLionel Sambuc
23134684ddb6SLionel Sambuctemplate <>
23144684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<char32_t>
23154684ddb6SLionel Sambuc    : public unary_function<char32_t, size_t>
23164684ddb6SLionel Sambuc{
23174684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23184684ddb6SLionel Sambuc    size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23194684ddb6SLionel Sambuc};
23204684ddb6SLionel Sambuc
23214684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
23224684ddb6SLionel Sambuc
23234684ddb6SLionel Sambuctemplate <>
23244684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t>
23254684ddb6SLionel Sambuc    : public unary_function<wchar_t, size_t>
23264684ddb6SLionel Sambuc{
23274684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23284684ddb6SLionel Sambuc    size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23294684ddb6SLionel Sambuc};
23304684ddb6SLionel Sambuc
23314684ddb6SLionel Sambuctemplate <>
23324684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<short>
23334684ddb6SLionel Sambuc    : public unary_function<short, size_t>
23344684ddb6SLionel Sambuc{
23354684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23364684ddb6SLionel Sambuc    size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23374684ddb6SLionel Sambuc};
23384684ddb6SLionel Sambuc
23394684ddb6SLionel Sambuctemplate <>
23404684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
23414684ddb6SLionel Sambuc    : public unary_function<unsigned short, size_t>
23424684ddb6SLionel Sambuc{
23434684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23444684ddb6SLionel Sambuc    size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23454684ddb6SLionel Sambuc};
23464684ddb6SLionel Sambuc
23474684ddb6SLionel Sambuctemplate <>
23484684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<int>
23494684ddb6SLionel Sambuc    : public unary_function<int, size_t>
23504684ddb6SLionel Sambuc{
23514684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23524684ddb6SLionel Sambuc    size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23534684ddb6SLionel Sambuc};
23544684ddb6SLionel Sambuc
23554684ddb6SLionel Sambuctemplate <>
23564684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
23574684ddb6SLionel Sambuc    : public unary_function<unsigned int, size_t>
23584684ddb6SLionel Sambuc{
23594684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23604684ddb6SLionel Sambuc    size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23614684ddb6SLionel Sambuc};
23624684ddb6SLionel Sambuc
23634684ddb6SLionel Sambuctemplate <>
23644684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<long>
23654684ddb6SLionel Sambuc    : public unary_function<long, size_t>
23664684ddb6SLionel Sambuc{
23674684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23684684ddb6SLionel Sambuc    size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23694684ddb6SLionel Sambuc};
23704684ddb6SLionel Sambuc
23714684ddb6SLionel Sambuctemplate <>
23724684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
23734684ddb6SLionel Sambuc    : public unary_function<unsigned long, size_t>
23744684ddb6SLionel Sambuc{
23754684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23764684ddb6SLionel Sambuc    size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
23774684ddb6SLionel Sambuc};
23784684ddb6SLionel Sambuc
23794684ddb6SLionel Sambuctemplate <>
23804684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<long long>
23814684ddb6SLionel Sambuc    : public __scalar_hash<long long>
23824684ddb6SLionel Sambuc{
23834684ddb6SLionel Sambuc};
23844684ddb6SLionel Sambuc
23854684ddb6SLionel Sambuctemplate <>
23864684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
23874684ddb6SLionel Sambuc    : public __scalar_hash<unsigned long long>
23884684ddb6SLionel Sambuc{
23894684ddb6SLionel Sambuc};
23904684ddb6SLionel Sambuc
23914684ddb6SLionel Sambuctemplate <>
23924684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<float>
23934684ddb6SLionel Sambuc    : public __scalar_hash<float>
23944684ddb6SLionel Sambuc{
23954684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
23964684ddb6SLionel Sambuc    size_t operator()(float __v) const _NOEXCEPT
23974684ddb6SLionel Sambuc    {
23984684ddb6SLionel Sambuc        // -0.0 and 0.0 should return same hash
23994684ddb6SLionel Sambuc       if (__v == 0)
24004684ddb6SLionel Sambuc           return 0;
24014684ddb6SLionel Sambuc        return __scalar_hash<float>::operator()(__v);
24024684ddb6SLionel Sambuc    }
24034684ddb6SLionel Sambuc};
24044684ddb6SLionel Sambuc
24054684ddb6SLionel Sambuctemplate <>
24064684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<double>
24074684ddb6SLionel Sambuc    : public __scalar_hash<double>
24084684ddb6SLionel Sambuc{
24094684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
24104684ddb6SLionel Sambuc    size_t operator()(double __v) const _NOEXCEPT
24114684ddb6SLionel Sambuc    {
24124684ddb6SLionel Sambuc        // -0.0 and 0.0 should return same hash
24134684ddb6SLionel Sambuc       if (__v == 0)
24144684ddb6SLionel Sambuc           return 0;
24154684ddb6SLionel Sambuc        return __scalar_hash<double>::operator()(__v);
24164684ddb6SLionel Sambuc    }
24174684ddb6SLionel Sambuc};
24184684ddb6SLionel Sambuc
24194684ddb6SLionel Sambuctemplate <>
24204684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<long double>
24214684ddb6SLionel Sambuc    : public __scalar_hash<long double>
24224684ddb6SLionel Sambuc{
24234684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
24244684ddb6SLionel Sambuc    size_t operator()(long double __v) const _NOEXCEPT
24254684ddb6SLionel Sambuc    {
24264684ddb6SLionel Sambuc        // -0.0 and 0.0 should return same hash
24274684ddb6SLionel Sambuc        if (__v == 0)
24284684ddb6SLionel Sambuc            return 0;
24294684ddb6SLionel Sambuc#if defined(__i386__)
24304684ddb6SLionel Sambuc        // Zero out padding bits
24314684ddb6SLionel Sambuc        union
24324684ddb6SLionel Sambuc        {
24334684ddb6SLionel Sambuc            long double __t;
24344684ddb6SLionel Sambuc            struct
24354684ddb6SLionel Sambuc            {
24364684ddb6SLionel Sambuc                size_t __a;
24374684ddb6SLionel Sambuc                size_t __b;
24384684ddb6SLionel Sambuc                size_t __c;
24394684ddb6SLionel Sambuc                size_t __d;
2440*0a6a1f1dSLionel Sambuc            } __s;
24414684ddb6SLionel Sambuc        } __u;
2442*0a6a1f1dSLionel Sambuc        __u.__s.__a = 0;
2443*0a6a1f1dSLionel Sambuc        __u.__s.__b = 0;
2444*0a6a1f1dSLionel Sambuc        __u.__s.__c = 0;
2445*0a6a1f1dSLionel Sambuc        __u.__s.__d = 0;
24464684ddb6SLionel Sambuc        __u.__t = __v;
2447*0a6a1f1dSLionel Sambuc        return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
24484684ddb6SLionel Sambuc#elif defined(__x86_64__)
24494684ddb6SLionel Sambuc        // Zero out padding bits
24504684ddb6SLionel Sambuc        union
24514684ddb6SLionel Sambuc        {
24524684ddb6SLionel Sambuc            long double __t;
24534684ddb6SLionel Sambuc            struct
24544684ddb6SLionel Sambuc            {
24554684ddb6SLionel Sambuc                size_t __a;
24564684ddb6SLionel Sambuc                size_t __b;
2457*0a6a1f1dSLionel Sambuc            } __s;
24584684ddb6SLionel Sambuc        } __u;
2459*0a6a1f1dSLionel Sambuc        __u.__s.__a = 0;
2460*0a6a1f1dSLionel Sambuc        __u.__s.__b = 0;
24614684ddb6SLionel Sambuc        __u.__t = __v;
2462*0a6a1f1dSLionel Sambuc        return __u.__s.__a ^ __u.__s.__b;
24634684ddb6SLionel Sambuc#else
24644684ddb6SLionel Sambuc        return __scalar_hash<long double>::operator()(__v);
24654684ddb6SLionel Sambuc#endif
24664684ddb6SLionel Sambuc    }
24674684ddb6SLionel Sambuc};
24684684ddb6SLionel Sambuc
24694684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
24704684ddb6SLionel Sambuctemplate <class _Tp>
24714684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash
24724684ddb6SLionel Sambuc    : public unary_function<_Tp, size_t>
24734684ddb6SLionel Sambuc{
24744684ddb6SLionel Sambuc    static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types");
24754684ddb6SLionel Sambuc
24764684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
24774684ddb6SLionel Sambuc    size_t operator()(_Tp __v) const _NOEXCEPT
24784684ddb6SLionel Sambuc    {
24794684ddb6SLionel Sambuc        typedef typename underlying_type<_Tp>::type type;
24804684ddb6SLionel Sambuc        return hash<type>{}(static_cast<type>(__v));
24814684ddb6SLionel Sambuc    }
24824684ddb6SLionel Sambuc};
24834684ddb6SLionel Sambuc#endif
24844684ddb6SLionel Sambuc
2485*0a6a1f1dSLionel Sambuc
2486*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 14
2487*0a6a1f1dSLionel Sambuctemplate <class _Fn, class ..._Args>
2488*0a6a1f1dSLionel Sambucresult_of_t<_Fn&&(_Args&&...)>
2489*0a6a1f1dSLionel Sambucinvoke(_Fn&& __f, _Args&&... __args) {
2490*0a6a1f1dSLionel Sambuc    return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
2491*0a6a1f1dSLionel Sambuc}
2492*0a6a1f1dSLionel Sambuc#endif
2493*0a6a1f1dSLionel Sambuc
24944684ddb6SLionel Sambuc// struct hash<T*> in <memory>
24954684ddb6SLionel Sambuc
24964684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
24974684ddb6SLionel Sambuc
24984684ddb6SLionel Sambuc#endif  // _LIBCPP_FUNCTIONAL
2499