head	1.6;
access;
symbols
	RELENG_9_1_0_RELEASE:1.2.2.2
	RELENG_9_1:1.2.2.2.0.2
	RELENG_9_1_BP:1.2.2.2
	RELENG_9:1.2.0.2;
locks; strict;
comment	@# @;


1.6
date	2013.07.11.00.34.38;	author svnexp;	state Exp;
branches;
next	1.5;

1.5
date	2013.04.28.00.41.54;	author svnexp;	state Exp;
branches;
next	1.4;

1.4
date	2013.02.08.05.09.54;	author svnexp;	state Exp;
branches;
next	1.3;

1.3
date	2012.10.22.18.25.04;	author dim;	state Exp;
branches;
next	1.2;

1.2
date	2012.03.14.00.09.36;	author theraven;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2011.11.25.20.59.04;	author theraven;	state Exp;
branches;
next	;

1.2.2.1
date	2012.05.22.18.30.14;	author theraven;	state dead;
branches;
next	1.2.2.2;

1.2.2.2
date	2012.05.22.18.30.14;	author theraven;	state Exp;
branches;
next	1.2.2.3;

1.2.2.3
date	2012.11.21.18.41.40;	author svnexp;	state Exp;
branches;
next	1.2.2.4;

1.2.2.4
date	2013.05.11.17.01.44;	author svnexp;	state Exp;
branches;
next	1.2.2.5;

1.2.2.5
date	2013.07.11.22.01.44;	author svnexp;	state Exp;
branches;
next	1.2.2.6;

1.2.2.6
date	2014.03.05.20.01.45;	author svnexp;	state Exp;
branches;
next	1.2.2.7;

1.2.2.7
date	2014.03.09.22.01.44;	author svnexp;	state Exp;
branches;
next	;


desc
@@


1.6
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/253159
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@// -*- C++ -*-
//===------------------------ functional ----------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_FUNCTIONAL
#define _LIBCPP_FUNCTIONAL

/*
    functional synopsis

namespace std
{

template <class Arg, class Result>
struct unary_function
{
    typedef Arg    argument_type;
    typedef Result result_type;
};

template <class Arg1, class Arg2, class Result>
struct binary_function
{
    typedef Arg1   first_argument_type;
    typedef Arg2   second_argument_type;
    typedef Result result_type;
};

template <class T>
class reference_wrapper
    : public unary_function<T1, R> // if wrapping a unary functor
    : public binary_function<T1, T2, R> // if wraping a binary functor
{
public:
    // types
    typedef T type;
    typedef see below result_type; // Not always defined

    // construct/copy/destroy
    reference_wrapper(T&) noexcept;
    reference_wrapper(T&&) = delete; // do not bind to temps
    reference_wrapper(const reference_wrapper<T>& x) noexcept;

    // assignment
    reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;

    // access
    operator T& () const noexcept;
    T& get() const noexcept;

    // invoke
    template <class... ArgTypes>
      typename result_of<T(ArgTypes...)>::type
          operator() (ArgTypes&&...) const;
};

template <class T> reference_wrapper<T> ref(T& t) noexcept;
template <class T> void ref(const T&& t) = delete;
template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;

template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
template <class T> void cref(const T&& t) = delete;
template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;

template <class T>
struct plus : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct minus : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct multiplies : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct divides : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct modulus : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct negate : unary_function<T, T>
{
    T operator()(const T& x) const;
};

template <class T>
struct equal_to : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct not_equal_to : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct greater : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct less : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct greater_equal : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct less_equal : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct logical_and : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct logical_or : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct logical_not : unary_function<T, bool>
{
    bool operator()(const T& x) const;
};

template <class Predicate>
class unary_negate
    : public unary_function<typename Predicate::argument_type, bool>
{
public:
    explicit unary_negate(const Predicate& pred);
    bool operator()(const typename Predicate::argument_type& x) const;
};

template <class Predicate> unary_negate<Predicate> not1(const Predicate& pred);

template <class Predicate>
class binary_negate
    : public binary_function<typename Predicate::first_argument_type,
                             typename Predicate::second_argument_type,
                             bool>
{
public:
    explicit binary_negate(const Predicate& pred);
    bool operator()(const typename Predicate::first_argument_type& x,
                    const typename Predicate::second_argument_type& y) const;
};

template <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);

template<class T> struct is_bind_expression;
template<class T> struct is_placeholder;

template<class Fn, class... BoundArgs>
  unspecified bind(Fn&&, BoundArgs&&...);
template<class R, class Fn, class... BoundArgs>
  unspecified bind(Fn&&, BoundArgs&&...);

namespace placeholders {
  // M is the implementation-defined number of placeholders
  extern unspecified _1;
  extern unspecified _2;
  .
  .
  .
  extern unspecified _Mp;
}

template <class Operation>
class binder1st
    : public unary_function<typename Operation::second_argument_type,
                            typename Operation::result_type>
{
protected:
    Operation                               op;
    typename Operation::first_argument_type value;
public:
    binder1st(const Operation& x, const typename Operation::first_argument_type y);
    typename Operation::result_type operator()(      typename Operation::second_argument_type& x) const;
    typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
};

template <class Operation, class T>
binder1st<Operation> bind1st(const Operation& op, const T& x);

template <class Operation>
class binder2nd
    : public unary_function<typename Operation::first_argument_type,
                            typename Operation::result_type>
{
protected:
    Operation                                op;
    typename Operation::second_argument_type value;
public:
    binder2nd(const Operation& x, const typename Operation::second_argument_type y);
    typename Operation::result_type operator()(      typename Operation::first_argument_type& x) const;
    typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
};

template <class Operation, class T>
binder2nd<Operation> bind2nd(const Operation& op, const T& x);

template <class Arg, class Result>
class pointer_to_unary_function : public unary_function<Arg, Result>
{
public:
    explicit pointer_to_unary_function(Result (*f)(Arg));
    Result operator()(Arg x) const;
};

template <class Arg, class Result>
pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));

template <class Arg1, class Arg2, class Result>
class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
{
public:
    explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
    Result operator()(Arg1 x, Arg2 y) const;
};

template <class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));

template<class S, class T>
class mem_fun_t : public unary_function<T*, S>
{
public:
    explicit mem_fun_t(S (T::*p)());
    S operator()(T* p) const;
};

template<class S, class T, class A>
class mem_fun1_t : public binary_function<T*, A, S>
{
public:
    explicit mem_fun1_t(S (T::*p)(A));
    S operator()(T* p, A x) const;
};

template<class S, class T>          mem_fun_t<S,T>    mem_fun(S (T::*f)());
template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));

template<class S, class T>
class mem_fun_ref_t : public unary_function<T, S>
{
public:
    explicit mem_fun_ref_t(S (T::*p)());
    S operator()(T& p) const;
};

template<class S, class T, class A>
class mem_fun1_ref_t : public binary_function<T, A, S>
{
public:
    explicit mem_fun1_ref_t(S (T::*p)(A));
    S operator()(T& p, A x) const;
};

template<class S, class T>          mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)());
template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));

template <class S, class T>
class const_mem_fun_t : public unary_function<const T*, S>
{
public:
    explicit const_mem_fun_t(S (T::*p)() const);
    S operator()(const T* p) const;
};

template <class S, class T, class A>
class const_mem_fun1_t : public binary_function<const T*, A, S>
{
public:
    explicit const_mem_fun1_t(S (T::*p)(A) const);
    S operator()(const T* p, A x) const;
};

template <class S, class T>          const_mem_fun_t<S,T>    mem_fun(S (T::*f)() const);
template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);

template <class S, class T>
class const_mem_fun_ref_t : public unary_function<T, S>
{
public:
    explicit const_mem_fun_ref_t(S (T::*p)() const);
    S operator()(const T& p) const;
};

template <class S, class T, class A>
class const_mem_fun1_ref_t : public binary_function<T, A, S>
{
public:
    explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
    S operator()(const T& p, A x) const;
};

template <class S, class T>          const_mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)() const);
template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);

template<class R, class T> unspecified mem_fn(R T::*);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...));
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &&);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &&);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &&);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &&);

class bad_function_call
    : public exception
{
};

template<class> class function; // undefined

template<class R, class... ArgTypes>
class function<R(ArgTypes...)>
  : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and
                                      // ArgTypes contains T1
  : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
                                      // ArgTypes contains T1 and T2
{
public:
    typedef R result_type;

    // construct/copy/destroy:
    function() noexcept;
    function(nullptr_t) noexcept;
    function(const function&);
    function(function&&) noexcept;
    template<class F>
      function(F);
    template<Allocator Alloc>
      function(allocator_arg_t, const Alloc&) noexcept;
    template<Allocator Alloc>
      function(allocator_arg_t, const Alloc&, nullptr_t) noexcept;
    template<Allocator Alloc>
      function(allocator_arg_t, const Alloc&, const function&);
    template<Allocator Alloc>
      function(allocator_arg_t, const Alloc&, function&&);
    template<class F, Allocator Alloc>
      function(allocator_arg_t, const Alloc&, F);

    function& operator=(const function&);
    function& operator=(function&&) noexcept;
    function& operator=(nullptr_t) noexcept;
    template<class F>
      function& operator=(F&&);
    template<class F>
      function& operator=(reference_wrapper<F>) noexcept;

    ~function();

    // function modifiers:
    void swap(function&) noexcept;
    template<class F, class Alloc>
      void assign(F&&, const Alloc&);

    // function capacity:
    explicit operator bool() const noexcept;

    // function invocation:
    R operator()(ArgTypes...) const;

    // function target access:
    const std::type_info& target_type() const noexcept;
    template <typename T>       T* target() noexcept;
    template <typename T> const T* target() const noexcept;
};

// Null pointer comparisons:
template <class R, class ... ArgTypes>
  bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;

template <class R, class ... ArgTypes>
  bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;

template <class R, class ... ArgTypes>
  bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;

template <class  R, class ... ArgTypes>
  bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;

// specialized algorithms:
template <class  R, class ... ArgTypes>
  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;

template <class T> struct hash;

template <> struct hash<bool>;
template <> struct hash<char>;
template <> struct hash<signed char>;
template <> struct hash<unsigned char>;
template <> struct hash<char16_t>;
template <> struct hash<char32_t>;
template <> struct hash<wchar_t>;
template <> struct hash<short>;
template <> struct hash<unsigned short>;
template <> struct hash<int>;
template <> struct hash<unsigned int>;
template <> struct hash<long>;
template <> struct hash<long long>;
template <> struct hash<unsigned long>;
template <> struct hash<unsigned long long>;

template <> struct hash<float>;
template <> struct hash<double>;
template <> struct hash<long double>;

template<class T> struct hash<T*>;

}  // std

POLICY:  For non-variadic implementations, the number of arguments is limited
         to 3.  It is hoped that the need for non-variadic implementations
         will be minimal.

*/

#include <__config>
#include <type_traits>
#include <typeinfo>
#include <exception>
#include <memory>
#include <tuple>

#include <__functional_base>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

template <class _Tp>
struct _LIBCPP_TYPE_VIS plus : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x + __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS minus : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x - __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS multiplies : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x * __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS divides : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x / __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS modulus : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x % __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS negate : unary_function<_Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const
        {return -__x;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS equal_to : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x == __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS not_equal_to : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x != __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS greater : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x > __y;}
};

// less in <__functional_base>

template <class _Tp>
struct _LIBCPP_TYPE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x >= __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS less_equal : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x <= __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS logical_and : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x && __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS logical_or : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x || __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS logical_not : unary_function<_Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const
        {return !__x;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS bit_and : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x & __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS bit_or : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x | __y;}
};

template <class _Tp>
struct _LIBCPP_TYPE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x ^ __y;}
};

template <class _Predicate>
class _LIBCPP_TYPE_VIS unary_negate
    : public unary_function<typename _Predicate::argument_type, bool>
{
    _Predicate __pred_;
public:
    _LIBCPP_INLINE_VISIBILITY explicit unary_negate(const _Predicate& __pred)
        : __pred_(__pred) {}
    _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::argument_type& __x) const
        {return !__pred_(__x);}
};

template <class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
unary_negate<_Predicate>
not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}

template <class _Predicate>
class _LIBCPP_TYPE_VIS binary_negate
    : public binary_function<typename _Predicate::first_argument_type,
                             typename _Predicate::second_argument_type,
                             bool>
{
    _Predicate __pred_;
public:
    _LIBCPP_INLINE_VISIBILITY explicit binary_negate(const _Predicate& __pred)
        : __pred_(__pred) {}
    _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::first_argument_type& __x,
                    const typename _Predicate::second_argument_type& __y) const
        {return !__pred_(__x, __y);}
};

template <class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
binary_negate<_Predicate>
not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}

template <class __Operation>
class _LIBCPP_TYPE_VIS binder1st
    : public unary_function<typename __Operation::second_argument_type,
                            typename __Operation::result_type>
{
protected:
    __Operation                               op;
    typename __Operation::first_argument_type value;
public:
    _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
                               const typename __Operation::first_argument_type __y)
        : op(__x), value(__y) {}
    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
        (typename __Operation::second_argument_type& __x) const
            {return op(value, __x);}
    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
        (const typename __Operation::second_argument_type& __x) const
            {return op(value, __x);}
};

template <class __Operation, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
binder1st<__Operation>
bind1st(const __Operation& __op, const _Tp& __x)
    {return binder1st<__Operation>(__op, __x);}

template <class __Operation>
class _LIBCPP_TYPE_VIS binder2nd
    : public unary_function<typename __Operation::first_argument_type,
                            typename __Operation::result_type>
{
protected:
    __Operation                                op;
    typename __Operation::second_argument_type value;
public:
    _LIBCPP_INLINE_VISIBILITY
    binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
        : op(__x), value(__y) {}
    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
        (      typename __Operation::first_argument_type& __x) const
            {return op(__x, value);}
    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
        (const typename __Operation::first_argument_type& __x) const
            {return op(__x, value);}
};

template <class __Operation, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
binder2nd<__Operation>
bind2nd(const __Operation& __op, const _Tp& __x)
    {return binder2nd<__Operation>(__op, __x);}

template <class _Arg, class _Result>
class _LIBCPP_TYPE_VIS pointer_to_unary_function
    : public unary_function<_Arg, _Result>
{
    _Result (*__f_)(_Arg);
public:
    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
        : __f_(__f) {}
    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
        {return __f_(__x);}
};

template <class _Arg, class _Result>
inline _LIBCPP_INLINE_VISIBILITY
pointer_to_unary_function<_Arg,_Result>
ptr_fun(_Result (*__f)(_Arg))
    {return pointer_to_unary_function<_Arg,_Result>(__f);}

template <class _Arg1, class _Arg2, class _Result>
class _LIBCPP_TYPE_VIS pointer_to_binary_function
    : public binary_function<_Arg1, _Arg2, _Result>
{
    _Result (*__f_)(_Arg1, _Arg2);
public:
    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
        : __f_(__f) {}
    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
        {return __f_(__x, __y);}
};

template <class _Arg1, class _Arg2, class _Result>
inline _LIBCPP_INLINE_VISIBILITY
pointer_to_binary_function<_Arg1,_Arg2,_Result>
ptr_fun(_Result (*__f)(_Arg1,_Arg2))
    {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}

template<class _Sp, class _Tp>
class _LIBCPP_TYPE_VIS mem_fun_t : public unary_function<_Tp*, _Sp>
{
    _Sp (_Tp::*__p_)();
public:
    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
        {return (__p->*__p_)();}
};

template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_TYPE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
{
    _Sp (_Tp::*__p_)(_Ap);
public:
    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
        {return (__p->*__p_)(__x);}
};

template<class _Sp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
mem_fun_t<_Sp,_Tp>
mem_fun(_Sp (_Tp::*__f)())
    {return mem_fun_t<_Sp,_Tp>(__f);}

template<class _Sp, class _Tp, class _Ap>
inline _LIBCPP_INLINE_VISIBILITY
mem_fun1_t<_Sp,_Tp,_Ap>
mem_fun(_Sp (_Tp::*__f)(_Ap))
    {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}

template<class _Sp, class _Tp>
class _LIBCPP_TYPE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp>
{
    _Sp (_Tp::*__p_)();
public:
    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
        {return (__p.*__p_)();}
};

template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_TYPE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
{
    _Sp (_Tp::*__p_)(_Ap);
public:
    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
        {return (__p.*__p_)(__x);}
};

template<class _Sp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
mem_fun_ref_t<_Sp,_Tp>
mem_fun_ref(_Sp (_Tp::*__f)())
    {return mem_fun_ref_t<_Sp,_Tp>(__f);}

template<class _Sp, class _Tp, class _Ap>
inline _LIBCPP_INLINE_VISIBILITY
mem_fun1_ref_t<_Sp,_Tp,_Ap>
mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
    {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}

template <class _Sp, class _Tp>
class _LIBCPP_TYPE_VIS const_mem_fun_t : public unary_function<const _Tp*, _Sp>
{
    _Sp (_Tp::*__p_)() const;
public:
    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
        {return (__p->*__p_)();}
};

template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_TYPE_VIS const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
{
    _Sp (_Tp::*__p_)(_Ap) const;
public:
    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
        {return (__p->*__p_)(__x);}
};

template <class _Sp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
const_mem_fun_t<_Sp,_Tp>
mem_fun(_Sp (_Tp::*__f)() const)
    {return const_mem_fun_t<_Sp,_Tp>(__f);}

template <class _Sp, class _Tp, class _Ap>
inline _LIBCPP_INLINE_VISIBILITY
const_mem_fun1_t<_Sp,_Tp,_Ap>
mem_fun(_Sp (_Tp::*__f)(_Ap) const)
    {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}

template <class _Sp, class _Tp>
class _LIBCPP_TYPE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
{
    _Sp (_Tp::*__p_)() const;
public:
    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
        {return (__p.*__p_)();}
};

template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_TYPE_VIS const_mem_fun1_ref_t
    : public binary_function<_Tp, _Ap, _Sp>
{
    _Sp (_Tp::*__p_)(_Ap) const;
public:
    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
        {return (__p.*__p_)(__x);}
};

template <class _Sp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
const_mem_fun_ref_t<_Sp,_Tp>
mem_fun_ref(_Sp (_Tp::*__f)() const)
    {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}

template <class _Sp, class _Tp, class _Ap>
inline _LIBCPP_INLINE_VISIBILITY
const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
    {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}

#ifdef _LIBCPP_HAS_NO_VARIADICS

#include <__functional_03>

#else  // _LIBCPP_HAS_NO_VARIADICS

template <class _Tp>
class __mem_fn
    : public __weak_result_type<_Tp>
{
public:
    // types
    typedef _Tp type;
private:
    type __f_;

public:
    _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}

    // invoke
    template <class... _ArgTypes>
       _LIBCPP_INLINE_VISIBILITY
       typename __invoke_return<type, _ArgTypes...>::type
          operator() (_ArgTypes&&... __args)
          {
              return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
          }
};

template<class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp _Tp::*>
mem_fn(_Rp _Tp::* __pm)
{
    return __mem_fn<_Rp _Tp::*>(__pm);
}

template<class _Rp, class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_Args...)>
mem_fn(_Rp (_Tp::* __pm)(_Args...))
{
    return __mem_fn<_Rp (_Tp::*)(_Args...)>(__pm);
}

template<class _Rp, class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_Args...) const>
mem_fn(_Rp (_Tp::* __pm)(_Args...) const)
{
    return __mem_fn<_Rp (_Tp::*)(_Args...) const>(__pm);
}

template<class _Rp, class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_Args...) volatile>
mem_fn(_Rp (_Tp::* __pm)(_Args...) volatile)
{
    return __mem_fn<_Rp (_Tp::*)(_Args...) volatile>(__pm);
}

template<class _Rp, class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_Args...) const volatile>
mem_fn(_Rp (_Tp::* __pm)(_Args...) const volatile)
{
    return __mem_fn<_Rp (_Tp::*)(_Args...) const volatile>(__pm);
}

// bad_function_call

class _LIBCPP_EXCEPTION_ABI bad_function_call
    : public exception
{
};

template<class _Fp> class _LIBCPP_TYPE_VIS function; // undefined

namespace __function
{

template<class _Rp, class ..._ArgTypes>
struct __maybe_derive_from_unary_function
{
};

template<class _Rp, class _A1>
struct __maybe_derive_from_unary_function<_Rp(_A1)>
    : public unary_function<_A1, _Rp>
{
};

template<class _Rp, class ..._ArgTypes>
struct __maybe_derive_from_binary_function
{
};

template<class _Rp, class _A1, class _A2>
struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
    : public binary_function<_A1, _A2, _Rp>
{
};

template<class _Fp> class __base;

template<class _Rp, class ..._ArgTypes>
class __base<_Rp(_ArgTypes...)>
{
    __base(const __base&);
    __base& operator=(const __base&);
public:
    _LIBCPP_INLINE_VISIBILITY __base() {}
    _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
    virtual __base* __clone() const = 0;
    virtual void __clone(__base*) const = 0;
    virtual void destroy() _NOEXCEPT = 0;
    virtual void destroy_deallocate() _NOEXCEPT = 0;
    virtual _Rp operator()(_ArgTypes&& ...) = 0;
#ifndef _LIBCPP_NO_RTTI
    virtual const void* target(const type_info&) const _NOEXCEPT = 0;
    virtual const std::type_info& target_type() const _NOEXCEPT = 0;
#endif  // _LIBCPP_NO_RTTI
};

template<class _FD, class _Alloc, class _FB> class __func;

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
    : public  __base<_Rp(_ArgTypes...)>
{
    __compressed_pair<_Fp, _Alloc> __f_;
public:
    _LIBCPP_INLINE_VISIBILITY
    explicit __func(_Fp&& __f)
        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
                                    _VSTD::forward_as_tuple()) {}
    _LIBCPP_INLINE_VISIBILITY
    explicit __func(const _Fp& __f, const _Alloc& __a)
        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
                                    _VSTD::forward_as_tuple(__a)) {}

    _LIBCPP_INLINE_VISIBILITY
    explicit __func(const _Fp& __f, _Alloc&& __a)
        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}

    _LIBCPP_INLINE_VISIBILITY
    explicit __func(_Fp&& __f, _Alloc&& __a)
        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
    virtual __base<_Rp(_ArgTypes...)>* __clone() const;
    virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
    virtual void destroy() _NOEXCEPT;
    virtual void destroy_deallocate() _NOEXCEPT;
    virtual _Rp operator()(_ArgTypes&& ... __arg);
#ifndef _LIBCPP_NO_RTTI
    virtual const void* target(const type_info&) const _NOEXCEPT;
    virtual const std::type_info& target_type() const _NOEXCEPT;
#endif  // _LIBCPP_NO_RTTI
};

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
__base<_Rp(_ArgTypes...)>*
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
{
    typedef typename _Alloc::template rebind<__func>::other _Ap;
    _Ap __a(__f_.second());
    typedef __allocator_destructor<_Ap> _Dp;
    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
    return __hold.release();
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
{
    ::new (__p) __func(__f_.first(), __f_.second());
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
{
    __f_.~__compressed_pair<_Fp, _Alloc>();
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
{
    typedef typename _Alloc::template rebind<__func>::other _Ap;
    _Ap __a(__f_.second());
    __f_.~__compressed_pair<_Fp, _Alloc>();
    __a.deallocate(this, 1);
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
_Rp
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
{
    return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
}

#ifndef _LIBCPP_NO_RTTI

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
const void*
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
{
    if (__ti == typeid(_Fp))
        return &__f_.first();
    return (const void*)0;
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
const std::type_info&
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
{
    return typeid(_Fp);
}

#endif  // _LIBCPP_NO_RTTI

}  // __function

template<class _Rp, class ..._ArgTypes>
class _LIBCPP_TYPE_VIS function<_Rp(_ArgTypes...)>
    : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
      public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
{
    typedef __function::__base<_Rp(_ArgTypes...)> __base;
    typename aligned_storage<3*sizeof(void*)>::type __buf_;
    __base* __f_;

    template <class _Fp>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(const _Fp&) {return true;}
    template <class _R2, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;}
    template <class _R2, class _Cp, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;}
    template <class _R2, class _Cp, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;}
    template <class _R2, class _Cp, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;}
    template <class _R2, class _Cp, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;}
    template <class _R2, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;}

    template <class _Fp, bool = !is_same<_Fp, function>::value &&
                                __invokable<_Fp&, _ArgTypes...>::value>
        struct __callable;
    template <class _Fp>
        struct __callable<_Fp, true>
        {
            static const bool value =
                is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
                               _Rp>::value;
        };
    template <class _Fp>
        struct __callable<_Fp, false>
        {
            static const bool value = false;
        };
public:
    typedef _Rp result_type;

    // construct/copy/destroy:
    _LIBCPP_INLINE_VISIBILITY
    function() _NOEXCEPT : __f_(0) {}
    _LIBCPP_INLINE_VISIBILITY
    function(nullptr_t) _NOEXCEPT : __f_(0) {}
    function(const function&);
    function(function&&) _NOEXCEPT;
    template<class _Fp>
      function(_Fp, typename enable_if
                                     <
                                        __callable<_Fp>::value &&
                                        !is_same<_Fp, function>::value
                                      >::type* = 0);

    template<class _Alloc>
      _LIBCPP_INLINE_VISIBILITY
      function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
    template<class _Alloc>
      _LIBCPP_INLINE_VISIBILITY
      function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
    template<class _Alloc>
      function(allocator_arg_t, const _Alloc&, const function&);
    template<class _Alloc>
      function(allocator_arg_t, const _Alloc&, function&&);
    template<class _Fp, class _Alloc>
      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
               typename enable_if<__callable<_Fp>::value>::type* = 0);

    function& operator=(const function&);
    function& operator=(function&&) _NOEXCEPT;
    function& operator=(nullptr_t) _NOEXCEPT;
    template<class _Fp>
      typename enable_if
      <
        __callable<typename decay<_Fp>::type>::value &&
        !is_same<typename remove_reference<_Fp>::type, function>::value,
        function&
      >::type
      operator=(_Fp&&);

    ~function();

    // function modifiers:
    void swap(function&) _NOEXCEPT;
    template<class _Fp, class _Alloc>
      _LIBCPP_INLINE_VISIBILITY
      void assign(_Fp&& __f, const _Alloc& __a)
        {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}

    // function capacity:
    _LIBCPP_INLINE_VISIBILITY
        _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}

    // deleted overloads close possible hole in the type system
    template<class _R2, class... _ArgTypes2>
      bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
    template<class _R2, class... _ArgTypes2>
      bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
public:
    // function invocation:
    _Rp operator()(_ArgTypes...) const;

#ifndef _LIBCPP_NO_RTTI
    // function target access:
    const std::type_info& target_type() const _NOEXCEPT;
    template <typename _Tp> _Tp* target() _NOEXCEPT;
    template <typename _Tp> const _Tp* target() const _NOEXCEPT;
#endif  // _LIBCPP_NO_RTTI
};

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>::function(const function& __f)
{
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (const __base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
        __f_ = __f.__f_->__clone();
}

template<class _Rp, class ..._ArgTypes>
template <class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
                                     const function& __f)
{
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (const __base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
        __f_ = __f.__f_->__clone();
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
{
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (__base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
    {
        __f_ = __f.__f_;
        __f.__f_ = 0;
    }
}

template<class _Rp, class ..._ArgTypes>
template <class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
                                     function&& __f)
{
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (__base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
    {
        __f_ = __f.__f_;
        __f.__f_ = 0;
    }
}

template<class _Rp, class ..._ArgTypes>
template <class _Fp>
function<_Rp(_ArgTypes...)>::function(_Fp __f,
                                     typename enable_if
                                     <
                                        __callable<_Fp>::value &&
                                        !is_same<_Fp, function>::value
                                     >::type*)
    : __f_(0)
{
    if (__not_null(__f))
    {
        typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
        if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
        {
            __f_ = (__base*)&__buf_;
            ::new (__f_) _FF(_VSTD::move(__f));
        }
        else
        {
            typedef allocator<_FF> _Ap;
            _Ap __a;
            typedef __allocator_destructor<_Ap> _Dp;
            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
            ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
            __f_ = __hold.release();
        }
    }
}

template<class _Rp, class ..._ArgTypes>
template <class _Fp, class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
                                     typename enable_if<__callable<_Fp>::value>::type*)
    : __f_(0)
{
    typedef allocator_traits<_Alloc> __alloc_traits;
    if (__not_null(__f))
    {
        typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
        if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
        {
            __f_ = (__base*)&__buf_;
            ::new (__f_) _FF(_VSTD::move(__f));
        }
        else
        {
            typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
                rebind_alloc<_FF>
#else
                rebind_alloc<_FF>::other
#endif
                                                         _Ap;
            _Ap __a(__a0);
            typedef __allocator_destructor<_Ap> _Dp;
            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
            ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
            __f_ = __hold.release();
        }
    }
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>&
function<_Rp(_ArgTypes...)>::operator=(const function& __f)
{
    function(__f).swap(*this);
    return *this;
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>&
function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
{
    if (__f_ == (__base*)&__buf_)
        __f_->destroy();
    else if (__f_)
        __f_->destroy_deallocate();
    __f_ = 0;
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (__base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
    {
        __f_ = __f.__f_;
        __f.__f_ = 0;
    }
    return *this;
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>&
function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
{
    if (__f_ == (__base*)&__buf_)
        __f_->destroy();
    else if (__f_)
        __f_->destroy_deallocate();
    __f_ = 0;
    return *this;
}

template<class _Rp, class ..._ArgTypes>
template <class _Fp>
typename enable_if
<
    function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
    !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
    function<_Rp(_ArgTypes...)>&
>::type
function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
{
    function(_VSTD::forward<_Fp>(__f)).swap(*this);
    return *this;
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>::~function()
{
    if (__f_ == (__base*)&__buf_)
        __f_->destroy();
    else if (__f_)
        __f_->destroy_deallocate();
}

template<class _Rp, class ..._ArgTypes>
void
function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
{
    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
    {
        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
        __base* __t = (__base*)&__tempbuf;
        __f_->__clone(__t);
        __f_->destroy();
        __f_ = 0;
        __f.__f_->__clone((__base*)&__buf_);
        __f.__f_->destroy();
        __f.__f_ = 0;
        __f_ = (__base*)&__buf_;
        __t->__clone((__base*)&__f.__buf_);
        __t->destroy();
        __f.__f_ = (__base*)&__f.__buf_;
    }
    else if (__f_ == (__base*)&__buf_)
    {
        __f_->__clone((__base*)&__f.__buf_);
        __f_->destroy();
        __f_ = __f.__f_;
        __f.__f_ = (__base*)&__f.__buf_;
    }
    else if (__f.__f_ == (__base*)&__f.__buf_)
    {
        __f.__f_->__clone((__base*)&__buf_);
        __f.__f_->destroy();
        __f.__f_ = __f_;
        __f_ = (__base*)&__buf_;
    }
    else
        _VSTD::swap(__f_, __f.__f_);
}

template<class _Rp, class ..._ArgTypes>
_Rp
function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
{
#ifndef _LIBCPP_NO_EXCEPTIONS
    if (__f_ == 0)
        throw bad_function_call();
#endif  // _LIBCPP_NO_EXCEPTIONS
    return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
}

#ifndef _LIBCPP_NO_RTTI

template<class _Rp, class ..._ArgTypes>
const std::type_info&
function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
{
    if (__f_ == 0)
        return typeid(void);
    return __f_->target_type();
}

template<class _Rp, class ..._ArgTypes>
template <typename _Tp>
_Tp*
function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
{
    if (__f_ == 0)
        return (_Tp*)0;
    return (_Tp*)__f_->target(typeid(_Tp));
}

template<class _Rp, class ..._ArgTypes>
template <typename _Tp>
const _Tp*
function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
{
    if (__f_ == 0)
        return (const _Tp*)0;
    return (const _Tp*)__f_->target(typeid(_Tp));
}

#endif  // _LIBCPP_NO_RTTI

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
{return __x.swap(__y);}

template<class _Tp> struct __is_bind_expression : public false_type {};
template<class _Tp> struct _LIBCPP_TYPE_VIS is_bind_expression
    : public __is_bind_expression<typename remove_cv<_Tp>::type> {};

template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
template<class _Tp> struct _LIBCPP_TYPE_VIS is_placeholder
    : public __is_placeholder<typename remove_cv<_Tp>::type> {};

namespace placeholders
{

template <int _Np> struct __ph {};

extern __ph<1>   _1;
extern __ph<2>   _2;
extern __ph<3>   _3;
extern __ph<4>   _4;
extern __ph<5>   _5;
extern __ph<6>   _6;
extern __ph<7>   _7;
extern __ph<8>   _8;
extern __ph<9>   _9;
extern __ph<10> _10;

}  // placeholders

template<int _Np>
struct __is_placeholder<placeholders::__ph<_Np> >
    : public integral_constant<int, _Np> {};

template <class _Tp, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
_Tp&
__mu(reference_wrapper<_Tp> __t, _Uj&)
{
    return __t.get();
}

template <class _Ti, class ..._Uj, size_t ..._Indx>
inline _LIBCPP_INLINE_VISIBILITY
typename __invoke_of<_Ti&, _Uj...>::type
__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
{
    return __ti(_VSTD::forward<_Uj>(get<_Indx>(__uj))...);
}

template <class _Ti, class ..._Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
    is_bind_expression<_Ti>::value,
    typename __invoke_of<_Ti&, _Uj...>::type
>::type
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
{
    typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
    return  __mu_expand(__ti, __uj, __indices());
}

template <bool IsPh, class _Ti, class _Uj>
struct __mu_return2 {};

template <class _Ti, class _Uj>
struct __mu_return2<true, _Ti, _Uj>
{
    typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
};

template <class _Ti, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
    0 < is_placeholder<_Ti>::value,
    typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
>::type
__mu(_Ti&, _Uj& __uj)
{
    const size_t _Indx = is_placeholder<_Ti>::value - 1;
    return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj));
}

template <class _Ti, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
    !is_bind_expression<_Ti>::value &&
    is_placeholder<_Ti>::value == 0 &&
    !__is_reference_wrapper<_Ti>::value,
    _Ti&
>::type
__mu(_Ti& __ti, _Uj&)
{
    return __ti;
}

template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
          class _TupleUj>
struct ____mu_return;

template <bool _Invokable, class _Ti, class ..._Uj>
struct ____mu_return_invokable  // false
{
    typedef __nat type;
};

template <class _Ti, class ..._Uj>
struct ____mu_return_invokable<true, _Ti, _Uj...>
{
    typedef typename __invoke_of<_Ti&, _Uj...>::type type;
};

template <class _Ti, class ..._Uj>
struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
    : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
{
};

template <class _Ti, class _TupleUj>
struct ____mu_return<_Ti, false, false, true, _TupleUj>
{
    typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
                                   _TupleUj>::type&& type;
};

template <class _Ti, class _TupleUj>
struct ____mu_return<_Ti, true, false, false, _TupleUj>
{
    typedef typename _Ti::type& type;
};

template <class _Ti, class _TupleUj>
struct ____mu_return<_Ti, false, false, false, _TupleUj>
{
    typedef _Ti& type;
};

template <class _Ti, class _TupleUj>
struct __mu_return
    : public ____mu_return<_Ti,
                           __is_reference_wrapper<_Ti>::value,
                           is_bind_expression<_Ti>::value,
                           0 < is_placeholder<_Ti>::value &&
                           is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
                           _TupleUj>
{
};

template <class _Fp, class _BoundArgs, class _TupleUj>
struct _is_valid_bind_return
{
    static const bool value = false;
};

template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
{
    static const bool value = __invokable<_Fp,
                    typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
};

template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
{
    static const bool value = __invokable<_Fp,
                    typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
};

template <class _Fp, class _BoundArgs, class _TupleUj,
          bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
struct __bind_return;

template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
{
    typedef typename __invoke_of
    <
        _Fp&,
        typename __mu_return
        <
            _BoundArgs,
            _TupleUj
        >::type...
    >::type type;
};

template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
{
    typedef typename __invoke_of
    <
        _Fp&,
        typename __mu_return
        <
            const _BoundArgs,
            _TupleUj
        >::type...
    >::type type;
};

template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
inline _LIBCPP_INLINE_VISIBILITY
typename __bind_return<_Fp, _BoundArgs, _Args>::type
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
                _Args&& __args)
{
    return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...);
}

template<class _Fp, class ..._BoundArgs>
class __bind
    : public __weak_result_type<typename decay<_Fp>::type>
{
protected:
    typedef typename decay<_Fp>::type _Fd;
    typedef tuple<typename decay<_BoundArgs>::type...> _Td;
private:
    _Fd __f_;
    _Td __bound_args_;

    typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
public:
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

    _LIBCPP_INLINE_VISIBILITY
    __bind(const __bind& __b)
        : __f_(__b.__f_),
          __bound_args_(__b.__bound_args_) {}

    _LIBCPP_INLINE_VISIBILITY
    __bind& operator=(const __bind& __b)
    {
        __f_ = __b.__f_;
        __bound_args_ = __b.__bound_args_;
        return *this;
    }

    _LIBCPP_INLINE_VISIBILITY
    __bind(__bind&& __b)
        : __f_(_VSTD::move(__b.__f_)),
          __bound_args_(_VSTD::move(__b.__bound_args_)) {}

    _LIBCPP_INLINE_VISIBILITY
    __bind& operator=(__bind&& __b)
    {
        __f_ = _VSTD::move(__b.__f_);
        __bound_args_ = _VSTD::move(__b.__bound_args_);
        return *this;
    }

#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

    template <class _Gp, class ..._BA,
              class = typename enable_if
                               <
                                  is_constructible<_Fd, _Gp>::value &&
                                  !is_same<typename remove_reference<_Gp>::type,
                                           __bind>::value
                               >::type>
      _LIBCPP_INLINE_VISIBILITY
      explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
        : __f_(_VSTD::forward<_Gp>(__f)),
          __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}

    template <class ..._Args>
        _LIBCPP_INLINE_VISIBILITY
        typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
        operator()(_Args&& ...__args)
        {
            return __apply_functor(__f_, __bound_args_, __indices(),
                                  tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
        }

    template <class ..._Args>
        _LIBCPP_INLINE_VISIBILITY
        typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
        operator()(_Args&& ...__args) const
        {
            return __apply_functor(__f_, __bound_args_, __indices(),
                                   tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
        }
};

template<class _Fp, class ..._BoundArgs>
struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};

template<class _Rp, class _Fp, class ..._BoundArgs>
class __bind_r
    : public __bind<_Fp, _BoundArgs...>
{
    typedef __bind<_Fp, _BoundArgs...> base;
    typedef typename base::_Fd _Fd;
    typedef typename base::_Td _Td;
public:
    typedef _Rp result_type;

#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

    _LIBCPP_INLINE_VISIBILITY
    __bind_r(const __bind_r& __b)
        : base(_VSTD::forward<const base&>(__b)) {}

    _LIBCPP_INLINE_VISIBILITY
    __bind_r& operator=(const __bind_r& __b)
    {
        base::operator=(_VSTD::forward<const base&>(__b));
        return *this;
    }

    _LIBCPP_INLINE_VISIBILITY
    __bind_r(__bind_r&& __b)
        : base(_VSTD::forward<base>(__b)) {}

    _LIBCPP_INLINE_VISIBILITY
    __bind_r& operator=(__bind_r&& __b)
    {
        base::operator=(_VSTD::forward<base>(__b));
        return *this;
    }

#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

    template <class _Gp, class ..._BA,
              class = typename enable_if
                               <
                                  is_constructible<_Fd, _Gp>::value &&
                                  !is_same<typename remove_reference<_Gp>::type,
                                           __bind_r>::value
                               >::type>
      _LIBCPP_INLINE_VISIBILITY
      explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
        : base(_VSTD::forward<_Gp>(__f),
               _VSTD::forward<_BA>(__bound_args)...) {}

    template <class ..._Args>
        _LIBCPP_INLINE_VISIBILITY
        typename enable_if
        <
            is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
                           result_type>::value,
            result_type
        >::type
        operator()(_Args&& ...__args)
        {
            return base::operator()(_VSTD::forward<_Args>(__args)...);
        }

    template <class ..._Args>
        _LIBCPP_INLINE_VISIBILITY
        typename enable_if
        <
            is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
                           result_type>::value,
            result_type
        >::type
        operator()(_Args&& ...__args) const
        {
            return base::operator()(_VSTD::forward<_Args>(__args)...);
        }
};

template<class _Rp, class _Fp, class ..._BoundArgs>
struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};

template<class _Fp, class ..._BoundArgs>
inline _LIBCPP_INLINE_VISIBILITY
__bind<_Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
    typedef __bind<_Fp, _BoundArgs...> type;
    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
}

template<class _Rp, class _Fp, class ..._BoundArgs>
inline _LIBCPP_INLINE_VISIBILITY
__bind_r<_Rp, _Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
    typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
}

#endif  // _LIBCPP_HAS_NO_VARIADICS

template <>
struct _LIBCPP_TYPE_VIS hash<bool>
    : public unary_function<bool, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<char>
    : public unary_function<char, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<signed char>
    : public unary_function<signed char, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<unsigned char>
    : public unary_function<unsigned char, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS

template <>
struct _LIBCPP_TYPE_VIS hash<char16_t>
    : public unary_function<char16_t, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<char32_t>
    : public unary_function<char32_t, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS

template <>
struct _LIBCPP_TYPE_VIS hash<wchar_t>
    : public unary_function<wchar_t, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<short>
    : public unary_function<short, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<unsigned short>
    : public unary_function<unsigned short, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<int>
    : public unary_function<int, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<unsigned int>
    : public unary_function<unsigned int, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<long>
    : public unary_function<long, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<unsigned long>
    : public unary_function<unsigned long, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_TYPE_VIS hash<long long>
    : public __scalar_hash<long long>
{
};

template <>
struct _LIBCPP_TYPE_VIS hash<unsigned long long>
    : public __scalar_hash<unsigned long long>
{
};

template <>
struct _LIBCPP_TYPE_VIS hash<float>
    : public __scalar_hash<float>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(float __v) const _NOEXCEPT
    {
        // -0.0 and 0.0 should return same hash
       if (__v == 0)
           return 0;
        return __scalar_hash<float>::operator()(__v);
    }
};

template <>
struct _LIBCPP_TYPE_VIS hash<double>
    : public __scalar_hash<double>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(double __v) const _NOEXCEPT
    {
        // -0.0 and 0.0 should return same hash
       if (__v == 0)
           return 0;
        return __scalar_hash<double>::operator()(__v);
    }
};

template <>
struct _LIBCPP_TYPE_VIS hash<long double>
    : public __scalar_hash<long double>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(long double __v) const _NOEXCEPT
    {
        // -0.0 and 0.0 should return same hash
        if (__v == 0)
            return 0;
#if defined(__i386__)
        // Zero out padding bits
        union
        {
            long double __t;
            struct
            {
                size_t __a;
                size_t __b;
                size_t __c;
                size_t __d;
            };
        } __u;
        __u.__a = 0;
        __u.__b = 0;
        __u.__c = 0;
        __u.__d = 0;
        __u.__t = __v;
        return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d;
#elif defined(__x86_64__)
        // Zero out padding bits
        union
        {
            long double __t;
            struct
            {
                size_t __a;
                size_t __b;
            };
        } __u;
        __u.__a = 0;
        __u.__b = 0;
        __u.__t = __v;
        return __u.__a ^ __u.__b;
#else
        return __scalar_hash<long double>::operator()(__v);
#endif
    }
};

// struct hash<T*> in <memory>

_LIBCPP_END_NAMESPACE_STD

#endif  // _LIBCPP_FUNCTIONAL
@


1.5
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/249998
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@d1142 5
a1146 2
      function(_Fp,
               typename enable_if<__callable<_Fp>::value>::type* = 0);
d1168 2
a1169 1
        __callable<typename decay<_Fp>::type>::value,
d1273 5
a1277 1
                                     typename enable_if<__callable<_Fp>::value>::type*)
d1381 2
a1382 1
    function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value,
d1606 12
d1620 1
a1621 1
    typedef typename __invoke_of<_Ti&, _Uj...>::type type;
d1761 3
a1763 1
                                  is_constructible<_Fd, _Gp>::value
d1828 7
a1834 1
    template <class _Gp, class ..._BA>
@


1.4
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/246487
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@d477 1
a477 1
struct _LIBCPP_VISIBLE plus : binary_function<_Tp, _Tp, _Tp>
d484 1
a484 1
struct _LIBCPP_VISIBLE minus : binary_function<_Tp, _Tp, _Tp>
d491 1
a491 1
struct _LIBCPP_VISIBLE multiplies : binary_function<_Tp, _Tp, _Tp>
d498 1
a498 1
struct _LIBCPP_VISIBLE divides : binary_function<_Tp, _Tp, _Tp>
d505 1
a505 1
struct _LIBCPP_VISIBLE modulus : binary_function<_Tp, _Tp, _Tp>
d512 1
a512 1
struct _LIBCPP_VISIBLE negate : unary_function<_Tp, _Tp>
d519 1
a519 1
struct _LIBCPP_VISIBLE equal_to : binary_function<_Tp, _Tp, bool>
d526 1
a526 1
struct _LIBCPP_VISIBLE not_equal_to : binary_function<_Tp, _Tp, bool>
d533 1
a533 1
struct _LIBCPP_VISIBLE greater : binary_function<_Tp, _Tp, bool>
d542 1
a542 1
struct _LIBCPP_VISIBLE greater_equal : binary_function<_Tp, _Tp, bool>
d549 1
a549 1
struct _LIBCPP_VISIBLE less_equal : binary_function<_Tp, _Tp, bool>
d556 1
a556 1
struct _LIBCPP_VISIBLE logical_and : binary_function<_Tp, _Tp, bool>
d563 1
a563 1
struct _LIBCPP_VISIBLE logical_or : binary_function<_Tp, _Tp, bool>
d570 1
a570 1
struct _LIBCPP_VISIBLE logical_not : unary_function<_Tp, bool>
d577 1
a577 1
struct _LIBCPP_VISIBLE bit_and : binary_function<_Tp, _Tp, _Tp>
d584 1
a584 1
struct _LIBCPP_VISIBLE bit_or : binary_function<_Tp, _Tp, _Tp>
d591 1
a591 1
struct _LIBCPP_VISIBLE bit_xor : binary_function<_Tp, _Tp, _Tp>
d598 1
a598 1
class _LIBCPP_VISIBLE unary_negate
d615 1
a615 1
class _LIBCPP_VISIBLE binary_negate
d635 1
a635 1
class _LIBCPP_VISIBLE binder1st
d661 1
a661 1
class _LIBCPP_VISIBLE binder2nd
d687 1
a687 1
class _LIBCPP_VISIBLE pointer_to_unary_function
d705 1
a705 1
class _LIBCPP_VISIBLE pointer_to_binary_function
d723 1
a723 1
class _LIBCPP_VISIBLE mem_fun_t : public unary_function<_Tp*, _Sp>
d734 1
a734 1
class _LIBCPP_VISIBLE mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
d757 1
a757 1
class _LIBCPP_VISIBLE mem_fun_ref_t : public unary_function<_Tp, _Sp>
d768 1
a768 1
class _LIBCPP_VISIBLE mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
d791 1
a791 1
class _LIBCPP_VISIBLE const_mem_fun_t : public unary_function<const _Tp*, _Sp>
d802 1
a802 1
class _LIBCPP_VISIBLE const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
d825 1
a825 1
class _LIBCPP_VISIBLE const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
d836 1
a836 1
class _LIBCPP_VISIBLE const_mem_fun1_ref_t
d935 1
a935 1
template<class _Fp> class _LIBCPP_VISIBLE function; // undefined
d1086 1
a1086 1
class _LIBCPP_VISIBLE function<_Rp(_ArgTypes...)>
d1499 1
a1499 1
template<class _Tp> struct _LIBCPP_VISIBLE is_bind_expression
d1503 1
a1503 1
template<class _Tp> struct _LIBCPP_VISIBLE is_placeholder
d1627 2
a1628 1
                           0 < is_placeholder<_Ti>::value,
d1634 21
d1658 1
a1658 1
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
d1672 1
a1672 1
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
d1698 1
d1701 1
d1758 1
a1758 1
        typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
d1774 2
d1813 6
a1818 1
        result_type
d1826 6
a1831 1
        result_type
d1862 1
a1862 1
struct _LIBCPP_VISIBLE hash<bool>
d1870 1
a1870 1
struct _LIBCPP_VISIBLE hash<char>
d1878 1
a1878 1
struct _LIBCPP_VISIBLE hash<signed char>
d1886 1
a1886 1
struct _LIBCPP_VISIBLE hash<unsigned char>
d1896 1
a1896 1
struct _LIBCPP_VISIBLE hash<char16_t>
d1904 1
a1904 1
struct _LIBCPP_VISIBLE hash<char32_t>
d1914 1
a1914 1
struct _LIBCPP_VISIBLE hash<wchar_t>
d1922 1
a1922 1
struct _LIBCPP_VISIBLE hash<short>
d1930 1
a1930 1
struct _LIBCPP_VISIBLE hash<unsigned short>
d1938 1
a1938 1
struct _LIBCPP_VISIBLE hash<int>
d1946 1
a1946 1
struct _LIBCPP_VISIBLE hash<unsigned int>
d1954 1
a1954 1
struct _LIBCPP_VISIBLE hash<long>
d1962 1
a1962 1
struct _LIBCPP_VISIBLE hash<unsigned long>
d1970 1
a1970 1
struct _LIBCPP_VISIBLE hash<long long>
d1976 1
a1976 1
struct _LIBCPP_VISIBLE hash<unsigned long long>
d1982 1
a1982 1
struct _LIBCPP_VISIBLE hash<float>
d1996 1
a1996 1
struct _LIBCPP_VISIBLE hash<double>
d2010 1
a2010 1
struct _LIBCPP_VISIBLE hash<long double>
@


1.3
log
@SVN rev 241903 on 2012-10-22 18:25:04Z by dim

Import libc++ trunk r165949.  Among other improvements and bug fixes,
this has many visibility problems fixed, which should help with
compiling certain ports that exercise C++11 mode (i.e. Firefox).

Also, belatedly add the LICENSE.TXT and accompanying CREDITS.TXT files,
which are referred to in all the source files.

MFC after:	1 month
@
text
@d1091 1
a1091 1
    aligned_storage<3*sizeof(void*)>::type __buf_;
@


1.2
log
@SVN rev 232950 on 2012-03-14 00:09:36Z by theraven

Import new versions of libcxxrt and libc++.
Please tests any C++ code you care about with -stdlib=libc++!

Approved by:	dim (mentor)
@
text
@d1116 2
a1117 1
    template <class _Fp, bool = __invokable<_Fp&, _ArgTypes...>::value>
d1354 1
d1366 1
d1713 5
a1717 1
    template <class _Gp, class ..._BA>
@


1.2.2.1
log
@file functional was added on branch RELENG_9 on 2012-05-22 18:32:26 +0000
@
text
@d1 2020
@


1.2.2.2
log
@SVN rev 235798 on 2012-05-22 18:30:14Z by theraven

Merged libcxxrt and libc++.  Now available for testing on 9-stable with
-stdlib=libc++.  Changes to libstdc++ not yet merged, so it is not yet possible
to mix libstdc++ and libc++ in the same program.

Merged revisions: 226702,226785,227006,227755,227983,227987,228531,228630,228761,229067,230127,232950,233098,234715-234716,234772
@
text
@a0 2020
// -*- C++ -*-
//===------------------------ functional ----------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_FUNCTIONAL
#define _LIBCPP_FUNCTIONAL

/*
    functional synopsis

namespace std
{

template <class Arg, class Result>
struct unary_function
{
    typedef Arg    argument_type;
    typedef Result result_type;
};

template <class Arg1, class Arg2, class Result>
struct binary_function
{
    typedef Arg1   first_argument_type;
    typedef Arg2   second_argument_type;
    typedef Result result_type;
};

template <class T>
class reference_wrapper
    : public unary_function<T1, R> // if wrapping a unary functor
    : public binary_function<T1, T2, R> // if wraping a binary functor
{
public:
    // types
    typedef T type;
    typedef see below result_type; // Not always defined

    // construct/copy/destroy
    reference_wrapper(T&) noexcept;
    reference_wrapper(T&&) = delete; // do not bind to temps
    reference_wrapper(const reference_wrapper<T>& x) noexcept;

    // assignment
    reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;

    // access
    operator T& () const noexcept;
    T& get() const noexcept;

    // invoke
    template <class... ArgTypes>
      typename result_of<T(ArgTypes...)>::type
          operator() (ArgTypes&&...) const;
};

template <class T> reference_wrapper<T> ref(T& t) noexcept;
template <class T> void ref(const T&& t) = delete;
template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;

template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
template <class T> void cref(const T&& t) = delete;
template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;

template <class T>
struct plus : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct minus : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct multiplies : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct divides : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct modulus : binary_function<T, T, T>
{
    T operator()(const T& x, const T& y) const;
};

template <class T>
struct negate : unary_function<T, T>
{
    T operator()(const T& x) const;
};

template <class T>
struct equal_to : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct not_equal_to : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct greater : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct less : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct greater_equal : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct less_equal : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct logical_and : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct logical_or : binary_function<T, T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T>
struct logical_not : unary_function<T, bool>
{
    bool operator()(const T& x) const;
};

template <class Predicate>
class unary_negate
    : public unary_function<typename Predicate::argument_type, bool>
{
public:
    explicit unary_negate(const Predicate& pred);
    bool operator()(const typename Predicate::argument_type& x) const;
};

template <class Predicate> unary_negate<Predicate> not1(const Predicate& pred);

template <class Predicate>
class binary_negate
    : public binary_function<typename Predicate::first_argument_type,
                             typename Predicate::second_argument_type,
                             bool>
{
public:
    explicit binary_negate(const Predicate& pred);
    bool operator()(const typename Predicate::first_argument_type& x,
                    const typename Predicate::second_argument_type& y) const;
};

template <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);

template<class T> struct is_bind_expression;
template<class T> struct is_placeholder;

template<class Fn, class... BoundArgs>
  unspecified bind(Fn&&, BoundArgs&&...);
template<class R, class Fn, class... BoundArgs>
  unspecified bind(Fn&&, BoundArgs&&...);

namespace placeholders {
  // M is the implementation-defined number of placeholders
  extern unspecified _1;
  extern unspecified _2;
  .
  .
  .
  extern unspecified _Mp;
}

template <class Operation>
class binder1st
    : public unary_function<typename Operation::second_argument_type,
                            typename Operation::result_type>
{
protected:
    Operation                               op;
    typename Operation::first_argument_type value;
public:
    binder1st(const Operation& x, const typename Operation::first_argument_type y);
    typename Operation::result_type operator()(      typename Operation::second_argument_type& x) const;
    typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
};

template <class Operation, class T>
binder1st<Operation> bind1st(const Operation& op, const T& x);

template <class Operation>
class binder2nd
    : public unary_function<typename Operation::first_argument_type,
                            typename Operation::result_type>
{
protected:
    Operation                                op;
    typename Operation::second_argument_type value;
public:
    binder2nd(const Operation& x, const typename Operation::second_argument_type y);
    typename Operation::result_type operator()(      typename Operation::first_argument_type& x) const;
    typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
};

template <class Operation, class T>
binder2nd<Operation> bind2nd(const Operation& op, const T& x);

template <class Arg, class Result>
class pointer_to_unary_function : public unary_function<Arg, Result>
{
public:
    explicit pointer_to_unary_function(Result (*f)(Arg));
    Result operator()(Arg x) const;
};

template <class Arg, class Result>
pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));

template <class Arg1, class Arg2, class Result>
class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
{
public:
    explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
    Result operator()(Arg1 x, Arg2 y) const;
};

template <class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));

template<class S, class T>
class mem_fun_t : public unary_function<T*, S>
{
public:
    explicit mem_fun_t(S (T::*p)());
    S operator()(T* p) const;
};

template<class S, class T, class A>
class mem_fun1_t : public binary_function<T*, A, S>
{
public:
    explicit mem_fun1_t(S (T::*p)(A));
    S operator()(T* p, A x) const;
};

template<class S, class T>          mem_fun_t<S,T>    mem_fun(S (T::*f)());
template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));

template<class S, class T>
class mem_fun_ref_t : public unary_function<T, S>
{
public:
    explicit mem_fun_ref_t(S (T::*p)());
    S operator()(T& p) const;
};

template<class S, class T, class A>
class mem_fun1_ref_t : public binary_function<T, A, S>
{
public:
    explicit mem_fun1_ref_t(S (T::*p)(A));
    S operator()(T& p, A x) const;
};

template<class S, class T>          mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)());
template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));

template <class S, class T>
class const_mem_fun_t : public unary_function<const T*, S>
{
public:
    explicit const_mem_fun_t(S (T::*p)() const);
    S operator()(const T* p) const;
};

template <class S, class T, class A>
class const_mem_fun1_t : public binary_function<const T*, A, S>
{
public:
    explicit const_mem_fun1_t(S (T::*p)(A) const);
    S operator()(const T* p, A x) const;
};

template <class S, class T>          const_mem_fun_t<S,T>    mem_fun(S (T::*f)() const);
template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);

template <class S, class T>
class const_mem_fun_ref_t : public unary_function<T, S>
{
public:
    explicit const_mem_fun_ref_t(S (T::*p)() const);
    S operator()(const T& p) const;
};

template <class S, class T, class A>
class const_mem_fun1_ref_t : public binary_function<T, A, S>
{
public:
    explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
    S operator()(const T& p, A x) const;
};

template <class S, class T>          const_mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)() const);
template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);

template<class R, class T> unspecified mem_fn(R T::*);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...));
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &&);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &&);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &&);
template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &&);

class bad_function_call
    : public exception
{
};

template<class> class function; // undefined

template<class R, class... ArgTypes>
class function<R(ArgTypes...)>
  : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and
                                      // ArgTypes contains T1
  : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
                                      // ArgTypes contains T1 and T2
{
public:
    typedef R result_type;

    // construct/copy/destroy:
    function() noexcept;
    function(nullptr_t) noexcept;
    function(const function&);
    function(function&&) noexcept;
    template<class F>
      function(F);
    template<Allocator Alloc>
      function(allocator_arg_t, const Alloc&) noexcept;
    template<Allocator Alloc>
      function(allocator_arg_t, const Alloc&, nullptr_t) noexcept;
    template<Allocator Alloc>
      function(allocator_arg_t, const Alloc&, const function&);
    template<Allocator Alloc>
      function(allocator_arg_t, const Alloc&, function&&);
    template<class F, Allocator Alloc>
      function(allocator_arg_t, const Alloc&, F);

    function& operator=(const function&);
    function& operator=(function&&) noexcept;
    function& operator=(nullptr_t) noexcept;
    template<class F>
      function& operator=(F&&);
    template<class F>
      function& operator=(reference_wrapper<F>) noexcept;

    ~function();

    // function modifiers:
    void swap(function&) noexcept;
    template<class F, class Alloc>
      void assign(F&&, const Alloc&);

    // function capacity:
    explicit operator bool() const noexcept;

    // function invocation:
    R operator()(ArgTypes...) const;

    // function target access:
    const std::type_info& target_type() const noexcept;
    template <typename T>       T* target() noexcept;
    template <typename T> const T* target() const noexcept;
};

// Null pointer comparisons:
template <class R, class ... ArgTypes>
  bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;

template <class R, class ... ArgTypes>
  bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;

template <class R, class ... ArgTypes>
  bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;

template <class  R, class ... ArgTypes>
  bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;

// specialized algorithms:
template <class  R, class ... ArgTypes>
  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;

template <class T> struct hash;

template <> struct hash<bool>;
template <> struct hash<char>;
template <> struct hash<signed char>;
template <> struct hash<unsigned char>;
template <> struct hash<char16_t>;
template <> struct hash<char32_t>;
template <> struct hash<wchar_t>;
template <> struct hash<short>;
template <> struct hash<unsigned short>;
template <> struct hash<int>;
template <> struct hash<unsigned int>;
template <> struct hash<long>;
template <> struct hash<long long>;
template <> struct hash<unsigned long>;
template <> struct hash<unsigned long long>;

template <> struct hash<float>;
template <> struct hash<double>;
template <> struct hash<long double>;

template<class T> struct hash<T*>;

}  // std

POLICY:  For non-variadic implementations, the number of arguments is limited
         to 3.  It is hoped that the need for non-variadic implementations
         will be minimal.

*/

#include <__config>
#include <type_traits>
#include <typeinfo>
#include <exception>
#include <memory>
#include <tuple>

#include <__functional_base>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

template <class _Tp>
struct _LIBCPP_VISIBLE plus : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x + __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE minus : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x - __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE multiplies : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x * __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE divides : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x / __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE modulus : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x % __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE negate : unary_function<_Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const
        {return -__x;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE equal_to : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x == __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE not_equal_to : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x != __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE greater : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x > __y;}
};

// less in <__functional_base>

template <class _Tp>
struct _LIBCPP_VISIBLE greater_equal : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x >= __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE less_equal : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x <= __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE logical_and : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x && __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE logical_or : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x || __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE logical_not : unary_function<_Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const
        {return !__x;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE bit_and : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x & __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE bit_or : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x | __y;}
};

template <class _Tp>
struct _LIBCPP_VISIBLE bit_xor : binary_function<_Tp, _Tp, _Tp>
{
    _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const
        {return __x ^ __y;}
};

template <class _Predicate>
class _LIBCPP_VISIBLE unary_negate
    : public unary_function<typename _Predicate::argument_type, bool>
{
    _Predicate __pred_;
public:
    _LIBCPP_INLINE_VISIBILITY explicit unary_negate(const _Predicate& __pred)
        : __pred_(__pred) {}
    _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::argument_type& __x) const
        {return !__pred_(__x);}
};

template <class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
unary_negate<_Predicate>
not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}

template <class _Predicate>
class _LIBCPP_VISIBLE binary_negate
    : public binary_function<typename _Predicate::first_argument_type,
                             typename _Predicate::second_argument_type,
                             bool>
{
    _Predicate __pred_;
public:
    _LIBCPP_INLINE_VISIBILITY explicit binary_negate(const _Predicate& __pred)
        : __pred_(__pred) {}
    _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::first_argument_type& __x,
                    const typename _Predicate::second_argument_type& __y) const
        {return !__pred_(__x, __y);}
};

template <class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
binary_negate<_Predicate>
not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}

template <class __Operation>
class _LIBCPP_VISIBLE binder1st
    : public unary_function<typename __Operation::second_argument_type,
                            typename __Operation::result_type>
{
protected:
    __Operation                               op;
    typename __Operation::first_argument_type value;
public:
    _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
                               const typename __Operation::first_argument_type __y)
        : op(__x), value(__y) {}
    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
        (typename __Operation::second_argument_type& __x) const
            {return op(value, __x);}
    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
        (const typename __Operation::second_argument_type& __x) const
            {return op(value, __x);}
};

template <class __Operation, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
binder1st<__Operation>
bind1st(const __Operation& __op, const _Tp& __x)
    {return binder1st<__Operation>(__op, __x);}

template <class __Operation>
class _LIBCPP_VISIBLE binder2nd
    : public unary_function<typename __Operation::first_argument_type,
                            typename __Operation::result_type>
{
protected:
    __Operation                                op;
    typename __Operation::second_argument_type value;
public:
    _LIBCPP_INLINE_VISIBILITY
    binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
        : op(__x), value(__y) {}
    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
        (      typename __Operation::first_argument_type& __x) const
            {return op(__x, value);}
    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
        (const typename __Operation::first_argument_type& __x) const
            {return op(__x, value);}
};

template <class __Operation, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
binder2nd<__Operation>
bind2nd(const __Operation& __op, const _Tp& __x)
    {return binder2nd<__Operation>(__op, __x);}

template <class _Arg, class _Result>
class _LIBCPP_VISIBLE pointer_to_unary_function
    : public unary_function<_Arg, _Result>
{
    _Result (*__f_)(_Arg);
public:
    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
        : __f_(__f) {}
    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
        {return __f_(__x);}
};

template <class _Arg, class _Result>
inline _LIBCPP_INLINE_VISIBILITY
pointer_to_unary_function<_Arg,_Result>
ptr_fun(_Result (*__f)(_Arg))
    {return pointer_to_unary_function<_Arg,_Result>(__f);}

template <class _Arg1, class _Arg2, class _Result>
class _LIBCPP_VISIBLE pointer_to_binary_function
    : public binary_function<_Arg1, _Arg2, _Result>
{
    _Result (*__f_)(_Arg1, _Arg2);
public:
    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
        : __f_(__f) {}
    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
        {return __f_(__x, __y);}
};

template <class _Arg1, class _Arg2, class _Result>
inline _LIBCPP_INLINE_VISIBILITY
pointer_to_binary_function<_Arg1,_Arg2,_Result>
ptr_fun(_Result (*__f)(_Arg1,_Arg2))
    {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}

template<class _Sp, class _Tp>
class _LIBCPP_VISIBLE mem_fun_t : public unary_function<_Tp*, _Sp>
{
    _Sp (_Tp::*__p_)();
public:
    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
        {return (__p->*__p_)();}
};

template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_VISIBLE mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
{
    _Sp (_Tp::*__p_)(_Ap);
public:
    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
        {return (__p->*__p_)(__x);}
};

template<class _Sp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
mem_fun_t<_Sp,_Tp>
mem_fun(_Sp (_Tp::*__f)())
    {return mem_fun_t<_Sp,_Tp>(__f);}

template<class _Sp, class _Tp, class _Ap>
inline _LIBCPP_INLINE_VISIBILITY
mem_fun1_t<_Sp,_Tp,_Ap>
mem_fun(_Sp (_Tp::*__f)(_Ap))
    {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}

template<class _Sp, class _Tp>
class _LIBCPP_VISIBLE mem_fun_ref_t : public unary_function<_Tp, _Sp>
{
    _Sp (_Tp::*__p_)();
public:
    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
        {return (__p.*__p_)();}
};

template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_VISIBLE mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
{
    _Sp (_Tp::*__p_)(_Ap);
public:
    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
        {return (__p.*__p_)(__x);}
};

template<class _Sp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
mem_fun_ref_t<_Sp,_Tp>
mem_fun_ref(_Sp (_Tp::*__f)())
    {return mem_fun_ref_t<_Sp,_Tp>(__f);}

template<class _Sp, class _Tp, class _Ap>
inline _LIBCPP_INLINE_VISIBILITY
mem_fun1_ref_t<_Sp,_Tp,_Ap>
mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
    {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}

template <class _Sp, class _Tp>
class _LIBCPP_VISIBLE const_mem_fun_t : public unary_function<const _Tp*, _Sp>
{
    _Sp (_Tp::*__p_)() const;
public:
    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
        {return (__p->*__p_)();}
};

template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_VISIBLE const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
{
    _Sp (_Tp::*__p_)(_Ap) const;
public:
    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
        {return (__p->*__p_)(__x);}
};

template <class _Sp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
const_mem_fun_t<_Sp,_Tp>
mem_fun(_Sp (_Tp::*__f)() const)
    {return const_mem_fun_t<_Sp,_Tp>(__f);}

template <class _Sp, class _Tp, class _Ap>
inline _LIBCPP_INLINE_VISIBILITY
const_mem_fun1_t<_Sp,_Tp,_Ap>
mem_fun(_Sp (_Tp::*__f)(_Ap) const)
    {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}

template <class _Sp, class _Tp>
class _LIBCPP_VISIBLE const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
{
    _Sp (_Tp::*__p_)() const;
public:
    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
        {return (__p.*__p_)();}
};

template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_VISIBLE const_mem_fun1_ref_t
    : public binary_function<_Tp, _Ap, _Sp>
{
    _Sp (_Tp::*__p_)(_Ap) const;
public:
    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
        : __p_(__p) {}
    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
        {return (__p.*__p_)(__x);}
};

template <class _Sp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
const_mem_fun_ref_t<_Sp,_Tp>
mem_fun_ref(_Sp (_Tp::*__f)() const)
    {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}

template <class _Sp, class _Tp, class _Ap>
inline _LIBCPP_INLINE_VISIBILITY
const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
    {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}

#ifdef _LIBCPP_HAS_NO_VARIADICS

#include <__functional_03>

#else  // _LIBCPP_HAS_NO_VARIADICS

template <class _Tp>
class __mem_fn
    : public __weak_result_type<_Tp>
{
public:
    // types
    typedef _Tp type;
private:
    type __f_;

public:
    _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}

    // invoke
    template <class... _ArgTypes>
       _LIBCPP_INLINE_VISIBILITY
       typename __invoke_return<type, _ArgTypes...>::type
          operator() (_ArgTypes&&... __args)
          {
              return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
          }
};

template<class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp _Tp::*>
mem_fn(_Rp _Tp::* __pm)
{
    return __mem_fn<_Rp _Tp::*>(__pm);
}

template<class _Rp, class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_Args...)>
mem_fn(_Rp (_Tp::* __pm)(_Args...))
{
    return __mem_fn<_Rp (_Tp::*)(_Args...)>(__pm);
}

template<class _Rp, class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_Args...) const>
mem_fn(_Rp (_Tp::* __pm)(_Args...) const)
{
    return __mem_fn<_Rp (_Tp::*)(_Args...) const>(__pm);
}

template<class _Rp, class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_Args...) volatile>
mem_fn(_Rp (_Tp::* __pm)(_Args...) volatile)
{
    return __mem_fn<_Rp (_Tp::*)(_Args...) volatile>(__pm);
}

template<class _Rp, class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_Args...) const volatile>
mem_fn(_Rp (_Tp::* __pm)(_Args...) const volatile)
{
    return __mem_fn<_Rp (_Tp::*)(_Args...) const volatile>(__pm);
}

// bad_function_call

class _LIBCPP_EXCEPTION_ABI bad_function_call
    : public exception
{
};

template<class _Fp> class _LIBCPP_VISIBLE function; // undefined

namespace __function
{

template<class _Rp, class ..._ArgTypes>
struct __maybe_derive_from_unary_function
{
};

template<class _Rp, class _A1>
struct __maybe_derive_from_unary_function<_Rp(_A1)>
    : public unary_function<_A1, _Rp>
{
};

template<class _Rp, class ..._ArgTypes>
struct __maybe_derive_from_binary_function
{
};

template<class _Rp, class _A1, class _A2>
struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
    : public binary_function<_A1, _A2, _Rp>
{
};

template<class _Fp> class __base;

template<class _Rp, class ..._ArgTypes>
class __base<_Rp(_ArgTypes...)>
{
    __base(const __base&);
    __base& operator=(const __base&);
public:
    _LIBCPP_INLINE_VISIBILITY __base() {}
    _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
    virtual __base* __clone() const = 0;
    virtual void __clone(__base*) const = 0;
    virtual void destroy() _NOEXCEPT = 0;
    virtual void destroy_deallocate() _NOEXCEPT = 0;
    virtual _Rp operator()(_ArgTypes&& ...) = 0;
#ifndef _LIBCPP_NO_RTTI
    virtual const void* target(const type_info&) const _NOEXCEPT = 0;
    virtual const std::type_info& target_type() const _NOEXCEPT = 0;
#endif  // _LIBCPP_NO_RTTI
};

template<class _FD, class _Alloc, class _FB> class __func;

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
    : public  __base<_Rp(_ArgTypes...)>
{
    __compressed_pair<_Fp, _Alloc> __f_;
public:
    _LIBCPP_INLINE_VISIBILITY
    explicit __func(_Fp&& __f)
        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
                                    _VSTD::forward_as_tuple()) {}
    _LIBCPP_INLINE_VISIBILITY
    explicit __func(const _Fp& __f, const _Alloc& __a)
        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
                                    _VSTD::forward_as_tuple(__a)) {}

    _LIBCPP_INLINE_VISIBILITY
    explicit __func(const _Fp& __f, _Alloc&& __a)
        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}

    _LIBCPP_INLINE_VISIBILITY
    explicit __func(_Fp&& __f, _Alloc&& __a)
        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
    virtual __base<_Rp(_ArgTypes...)>* __clone() const;
    virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
    virtual void destroy() _NOEXCEPT;
    virtual void destroy_deallocate() _NOEXCEPT;
    virtual _Rp operator()(_ArgTypes&& ... __arg);
#ifndef _LIBCPP_NO_RTTI
    virtual const void* target(const type_info&) const _NOEXCEPT;
    virtual const std::type_info& target_type() const _NOEXCEPT;
#endif  // _LIBCPP_NO_RTTI
};

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
__base<_Rp(_ArgTypes...)>*
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
{
    typedef typename _Alloc::template rebind<__func>::other _Ap;
    _Ap __a(__f_.second());
    typedef __allocator_destructor<_Ap> _Dp;
    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
    return __hold.release();
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
{
    ::new (__p) __func(__f_.first(), __f_.second());
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
{
    __f_.~__compressed_pair<_Fp, _Alloc>();
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
{
    typedef typename _Alloc::template rebind<__func>::other _Ap;
    _Ap __a(__f_.second());
    __f_.~__compressed_pair<_Fp, _Alloc>();
    __a.deallocate(this, 1);
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
_Rp
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
{
    return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
}

#ifndef _LIBCPP_NO_RTTI

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
const void*
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
{
    if (__ti == typeid(_Fp))
        return &__f_.first();
    return (const void*)0;
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
const std::type_info&
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
{
    return typeid(_Fp);
}

#endif  // _LIBCPP_NO_RTTI

}  // __function

template<class _Rp, class ..._ArgTypes>
class _LIBCPP_VISIBLE function<_Rp(_ArgTypes...)>
    : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
      public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
{
    typedef __function::__base<_Rp(_ArgTypes...)> __base;
    aligned_storage<3*sizeof(void*)>::type __buf_;
    __base* __f_;

    template <class _Fp>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(const _Fp&) {return true;}
    template <class _R2, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;}
    template <class _R2, class _Cp, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;}
    template <class _R2, class _Cp, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;}
    template <class _R2, class _Cp, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;}
    template <class _R2, class _Cp, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;}
    template <class _R2, class ..._Ap>
        _LIBCPP_INLINE_VISIBILITY
        static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;}

    template <class _Fp, bool = __invokable<_Fp&, _ArgTypes...>::value>
        struct __callable;
    template <class _Fp>
        struct __callable<_Fp, true>
        {
            static const bool value =
                is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
                               _Rp>::value;
        };
    template <class _Fp>
        struct __callable<_Fp, false>
        {
            static const bool value = false;
        };
public:
    typedef _Rp result_type;

    // construct/copy/destroy:
    _LIBCPP_INLINE_VISIBILITY
    function() _NOEXCEPT : __f_(0) {}
    _LIBCPP_INLINE_VISIBILITY
    function(nullptr_t) _NOEXCEPT : __f_(0) {}
    function(const function&);
    function(function&&) _NOEXCEPT;
    template<class _Fp>
      function(_Fp,
               typename enable_if<__callable<_Fp>::value>::type* = 0);

    template<class _Alloc>
      _LIBCPP_INLINE_VISIBILITY
      function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
    template<class _Alloc>
      _LIBCPP_INLINE_VISIBILITY
      function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
    template<class _Alloc>
      function(allocator_arg_t, const _Alloc&, const function&);
    template<class _Alloc>
      function(allocator_arg_t, const _Alloc&, function&&);
    template<class _Fp, class _Alloc>
      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
               typename enable_if<__callable<_Fp>::value>::type* = 0);

    function& operator=(const function&);
    function& operator=(function&&) _NOEXCEPT;
    function& operator=(nullptr_t) _NOEXCEPT;
    template<class _Fp>
      typename enable_if
      <
        __callable<typename decay<_Fp>::type>::value,
        function&
      >::type
      operator=(_Fp&&);

    ~function();

    // function modifiers:
    void swap(function&) _NOEXCEPT;
    template<class _Fp, class _Alloc>
      _LIBCPP_INLINE_VISIBILITY
      void assign(_Fp&& __f, const _Alloc& __a)
        {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}

    // function capacity:
    _LIBCPP_INLINE_VISIBILITY
        _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}

    // deleted overloads close possible hole in the type system
    template<class _R2, class... _ArgTypes2>
      bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
    template<class _R2, class... _ArgTypes2>
      bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
public:
    // function invocation:
    _Rp operator()(_ArgTypes...) const;

#ifndef _LIBCPP_NO_RTTI
    // function target access:
    const std::type_info& target_type() const _NOEXCEPT;
    template <typename _Tp> _Tp* target() _NOEXCEPT;
    template <typename _Tp> const _Tp* target() const _NOEXCEPT;
#endif  // _LIBCPP_NO_RTTI
};

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>::function(const function& __f)
{
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (const __base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
        __f_ = __f.__f_->__clone();
}

template<class _Rp, class ..._ArgTypes>
template <class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
                                     const function& __f)
{
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (const __base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
        __f_ = __f.__f_->__clone();
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
{
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (__base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
    {
        __f_ = __f.__f_;
        __f.__f_ = 0;
    }
}

template<class _Rp, class ..._ArgTypes>
template <class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
                                     function&& __f)
{
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (__base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
    {
        __f_ = __f.__f_;
        __f.__f_ = 0;
    }
}

template<class _Rp, class ..._ArgTypes>
template <class _Fp>
function<_Rp(_ArgTypes...)>::function(_Fp __f,
                                     typename enable_if<__callable<_Fp>::value>::type*)
    : __f_(0)
{
    if (__not_null(__f))
    {
        typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
        if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
        {
            __f_ = (__base*)&__buf_;
            ::new (__f_) _FF(_VSTD::move(__f));
        }
        else
        {
            typedef allocator<_FF> _Ap;
            _Ap __a;
            typedef __allocator_destructor<_Ap> _Dp;
            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
            ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
            __f_ = __hold.release();
        }
    }
}

template<class _Rp, class ..._ArgTypes>
template <class _Fp, class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
                                     typename enable_if<__callable<_Fp>::value>::type*)
    : __f_(0)
{
    typedef allocator_traits<_Alloc> __alloc_traits;
    if (__not_null(__f))
    {
        typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
        if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
        {
            __f_ = (__base*)&__buf_;
            ::new (__f_) _FF(_VSTD::move(__f));
        }
        else
        {
            typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
                rebind_alloc<_FF>
#else
                rebind_alloc<_FF>::other
#endif
                                                         _Ap;
            _Ap __a(__a0);
            typedef __allocator_destructor<_Ap> _Dp;
            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
            ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
            __f_ = __hold.release();
        }
    }
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>&
function<_Rp(_ArgTypes...)>::operator=(const function& __f)
{
    function(__f).swap(*this);
    return *this;
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>&
function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
{
    if (__f_ == (__base*)&__buf_)
        __f_->destroy();
    else if (__f_)
        __f_->destroy_deallocate();
    __f_ = 0;
    if (__f.__f_ == 0)
        __f_ = 0;
    else if (__f.__f_ == (__base*)&__f.__buf_)
    {
        __f_ = (__base*)&__buf_;
        __f.__f_->__clone(__f_);
    }
    else
    {
        __f_ = __f.__f_;
        __f.__f_ = 0;
    }
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>&
function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
{
    if (__f_ == (__base*)&__buf_)
        __f_->destroy();
    else if (__f_)
        __f_->destroy_deallocate();
    __f_ = 0;
}

template<class _Rp, class ..._ArgTypes>
template <class _Fp>
typename enable_if
<
    function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value,
    function<_Rp(_ArgTypes...)>&
>::type
function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
{
    function(_VSTD::forward<_Fp>(__f)).swap(*this);
    return *this;
}

template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>::~function()
{
    if (__f_ == (__base*)&__buf_)
        __f_->destroy();
    else if (__f_)
        __f_->destroy_deallocate();
}

template<class _Rp, class ..._ArgTypes>
void
function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
{
    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
    {
        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
        __base* __t = (__base*)&__tempbuf;
        __f_->__clone(__t);
        __f_->destroy();
        __f_ = 0;
        __f.__f_->__clone((__base*)&__buf_);
        __f.__f_->destroy();
        __f.__f_ = 0;
        __f_ = (__base*)&__buf_;
        __t->__clone((__base*)&__f.__buf_);
        __t->destroy();
        __f.__f_ = (__base*)&__f.__buf_;
    }
    else if (__f_ == (__base*)&__buf_)
    {
        __f_->__clone((__base*)&__f.__buf_);
        __f_->destroy();
        __f_ = __f.__f_;
        __f.__f_ = (__base*)&__f.__buf_;
    }
    else if (__f.__f_ == (__base*)&__f.__buf_)
    {
        __f.__f_->__clone((__base*)&__buf_);
        __f.__f_->destroy();
        __f.__f_ = __f_;
        __f_ = (__base*)&__buf_;
    }
    else
        _VSTD::swap(__f_, __f.__f_);
}

template<class _Rp, class ..._ArgTypes>
_Rp
function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
{
#ifndef _LIBCPP_NO_EXCEPTIONS
    if (__f_ == 0)
        throw bad_function_call();
#endif  // _LIBCPP_NO_EXCEPTIONS
    return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
}

#ifndef _LIBCPP_NO_RTTI

template<class _Rp, class ..._ArgTypes>
const std::type_info&
function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
{
    if (__f_ == 0)
        return typeid(void);
    return __f_->target_type();
}

template<class _Rp, class ..._ArgTypes>
template <typename _Tp>
_Tp*
function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
{
    if (__f_ == 0)
        return (_Tp*)0;
    return (_Tp*)__f_->target(typeid(_Tp));
}

template<class _Rp, class ..._ArgTypes>
template <typename _Tp>
const _Tp*
function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
{
    if (__f_ == 0)
        return (const _Tp*)0;
    return (const _Tp*)__f_->target(typeid(_Tp));
}

#endif  // _LIBCPP_NO_RTTI

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
{return __x.swap(__y);}

template<class _Tp> struct __is_bind_expression : public false_type {};
template<class _Tp> struct _LIBCPP_VISIBLE is_bind_expression
    : public __is_bind_expression<typename remove_cv<_Tp>::type> {};

template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
template<class _Tp> struct _LIBCPP_VISIBLE is_placeholder
    : public __is_placeholder<typename remove_cv<_Tp>::type> {};

namespace placeholders
{

template <int _Np> struct __ph {};

extern __ph<1>   _1;
extern __ph<2>   _2;
extern __ph<3>   _3;
extern __ph<4>   _4;
extern __ph<5>   _5;
extern __ph<6>   _6;
extern __ph<7>   _7;
extern __ph<8>   _8;
extern __ph<9>   _9;
extern __ph<10> _10;

}  // placeholders

template<int _Np>
struct __is_placeholder<placeholders::__ph<_Np> >
    : public integral_constant<int, _Np> {};

template <class _Tp, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
_Tp&
__mu(reference_wrapper<_Tp> __t, _Uj&)
{
    return __t.get();
}

template <class _Ti, class ..._Uj, size_t ..._Indx>
inline _LIBCPP_INLINE_VISIBILITY
typename __invoke_of<_Ti&, _Uj...>::type
__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
{
    return __ti(_VSTD::forward<_Uj>(get<_Indx>(__uj))...);
}

template <class _Ti, class ..._Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
    is_bind_expression<_Ti>::value,
    typename __invoke_of<_Ti&, _Uj...>::type
>::type
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
{
    typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
    return  __mu_expand(__ti, __uj, __indices());
}

template <bool IsPh, class _Ti, class _Uj>
struct __mu_return2 {};

template <class _Ti, class _Uj>
struct __mu_return2<true, _Ti, _Uj>
{
    typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
};

template <class _Ti, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
    0 < is_placeholder<_Ti>::value,
    typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
>::type
__mu(_Ti&, _Uj& __uj)
{
    const size_t _Indx = is_placeholder<_Ti>::value - 1;
    return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj));
}

template <class _Ti, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
    !is_bind_expression<_Ti>::value &&
    is_placeholder<_Ti>::value == 0 &&
    !__is_reference_wrapper<_Ti>::value,
    _Ti&
>::type
__mu(_Ti& __ti, _Uj&)
{
    return __ti;
}

template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
          class _TupleUj>
struct ____mu_return;

template <class _Ti, class ..._Uj>
struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
{
    typedef typename __invoke_of<_Ti&, _Uj...>::type type;
};

template <class _Ti, class _TupleUj>
struct ____mu_return<_Ti, false, false, true, _TupleUj>
{
    typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
                                   _TupleUj>::type&& type;
};

template <class _Ti, class _TupleUj>
struct ____mu_return<_Ti, true, false, false, _TupleUj>
{
    typedef typename _Ti::type& type;
};

template <class _Ti, class _TupleUj>
struct ____mu_return<_Ti, false, false, false, _TupleUj>
{
    typedef _Ti& type;
};

template <class _Ti, class _TupleUj>
struct __mu_return
    : public ____mu_return<_Ti,
                           __is_reference_wrapper<_Ti>::value,
                           is_bind_expression<_Ti>::value,
                           0 < is_placeholder<_Ti>::value,
                           _TupleUj>
{
};

template <class _Fp, class _BoundArgs, class _TupleUj>
struct __bind_return;

template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
{
    typedef typename __invoke_of
    <
        _Fp&,
        typename __mu_return
        <
            _BoundArgs,
            _TupleUj
        >::type...
    >::type type;
};

template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
{
    typedef typename __invoke_of
    <
        _Fp&,
        typename __mu_return
        <
            const _BoundArgs,
            _TupleUj
        >::type...
    >::type type;
};

template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
inline _LIBCPP_INLINE_VISIBILITY
typename __bind_return<_Fp, _BoundArgs, _Args>::type
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
                _Args&& __args)
{
    return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...);
}

template<class _Fp, class ..._BoundArgs>
class __bind
    : public __weak_result_type<typename decay<_Fp>::type>
{
    typedef typename decay<_Fp>::type _Fd;
    typedef tuple<typename decay<_BoundArgs>::type...> _Td;
    _Fd __f_;
    _Td __bound_args_;

    typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
public:
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

    _LIBCPP_INLINE_VISIBILITY
    __bind(const __bind& __b)
        : __f_(__b.__f_),
          __bound_args_(__b.__bound_args_) {}

    _LIBCPP_INLINE_VISIBILITY
    __bind& operator=(const __bind& __b)
    {
        __f_ = __b.__f_;
        __bound_args_ = __b.__bound_args_;
        return *this;
    }

    _LIBCPP_INLINE_VISIBILITY
    __bind(__bind&& __b)
        : __f_(_VSTD::move(__b.__f_)),
          __bound_args_(_VSTD::move(__b.__bound_args_)) {}

    _LIBCPP_INLINE_VISIBILITY
    __bind& operator=(__bind&& __b)
    {
        __f_ = _VSTD::move(__b.__f_);
        __bound_args_ = _VSTD::move(__b.__bound_args_);
        return *this;
    }

#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

    template <class _Gp, class ..._BA>
      _LIBCPP_INLINE_VISIBILITY
      explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
        : __f_(_VSTD::forward<_Gp>(__f)),
          __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}

    template <class ..._Args>
        _LIBCPP_INLINE_VISIBILITY
        typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
        operator()(_Args&& ...__args)
        {
            return __apply_functor(__f_, __bound_args_, __indices(),
                                  tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
        }

    template <class ..._Args>
        _LIBCPP_INLINE_VISIBILITY
        typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
        operator()(_Args&& ...__args) const
        {
            return __apply_functor(__f_, __bound_args_, __indices(),
                                   tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
        }
};

template<class _Fp, class ..._BoundArgs>
struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};

template<class _Rp, class _Fp, class ..._BoundArgs>
class __bind_r
    : public __bind<_Fp, _BoundArgs...>
{
    typedef __bind<_Fp, _BoundArgs...> base;
public:
    typedef _Rp result_type;

#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

    _LIBCPP_INLINE_VISIBILITY
    __bind_r(const __bind_r& __b)
        : base(_VSTD::forward<const base&>(__b)) {}

    _LIBCPP_INLINE_VISIBILITY
    __bind_r& operator=(const __bind_r& __b)
    {
        base::operator=(_VSTD::forward<const base&>(__b));
        return *this;
    }

    _LIBCPP_INLINE_VISIBILITY
    __bind_r(__bind_r&& __b)
        : base(_VSTD::forward<base>(__b)) {}

    _LIBCPP_INLINE_VISIBILITY
    __bind_r& operator=(__bind_r&& __b)
    {
        base::operator=(_VSTD::forward<base>(__b));
        return *this;
    }

#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

    template <class _Gp, class ..._BA>
      _LIBCPP_INLINE_VISIBILITY
      explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
        : base(_VSTD::forward<_Gp>(__f),
               _VSTD::forward<_BA>(__bound_args)...) {}

    template <class ..._Args>
        _LIBCPP_INLINE_VISIBILITY
        result_type
        operator()(_Args&& ...__args)
        {
            return base::operator()(_VSTD::forward<_Args>(__args)...);
        }

    template <class ..._Args>
        _LIBCPP_INLINE_VISIBILITY
        result_type
        operator()(_Args&& ...__args) const
        {
            return base::operator()(_VSTD::forward<_Args>(__args)...);
        }
};

template<class _Rp, class _Fp, class ..._BoundArgs>
struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};

template<class _Fp, class ..._BoundArgs>
inline _LIBCPP_INLINE_VISIBILITY
__bind<_Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
    typedef __bind<_Fp, _BoundArgs...> type;
    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
}

template<class _Rp, class _Fp, class ..._BoundArgs>
inline _LIBCPP_INLINE_VISIBILITY
__bind_r<_Rp, _Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
    typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
}

#endif  // _LIBCPP_HAS_NO_VARIADICS

template <>
struct _LIBCPP_VISIBLE hash<bool>
    : public unary_function<bool, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<char>
    : public unary_function<char, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<signed char>
    : public unary_function<signed char, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<unsigned char>
    : public unary_function<unsigned char, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS

template <>
struct _LIBCPP_VISIBLE hash<char16_t>
    : public unary_function<char16_t, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<char32_t>
    : public unary_function<char32_t, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS

template <>
struct _LIBCPP_VISIBLE hash<wchar_t>
    : public unary_function<wchar_t, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<short>
    : public unary_function<short, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<unsigned short>
    : public unary_function<unsigned short, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<int>
    : public unary_function<int, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<unsigned int>
    : public unary_function<unsigned int, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<long>
    : public unary_function<long, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<unsigned long>
    : public unary_function<unsigned long, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};

template <>
struct _LIBCPP_VISIBLE hash<long long>
    : public __scalar_hash<long long>
{
};

template <>
struct _LIBCPP_VISIBLE hash<unsigned long long>
    : public __scalar_hash<unsigned long long>
{
};

template <>
struct _LIBCPP_VISIBLE hash<float>
    : public __scalar_hash<float>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(float __v) const _NOEXCEPT
    {
        // -0.0 and 0.0 should return same hash
       if (__v == 0)
           return 0;
        return __scalar_hash<float>::operator()(__v);
    }
};

template <>
struct _LIBCPP_VISIBLE hash<double>
    : public __scalar_hash<double>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(double __v) const _NOEXCEPT
    {
        // -0.0 and 0.0 should return same hash
       if (__v == 0)
           return 0;
        return __scalar_hash<double>::operator()(__v);
    }
};

template <>
struct _LIBCPP_VISIBLE hash<long double>
    : public __scalar_hash<long double>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(long double __v) const _NOEXCEPT
    {
        // -0.0 and 0.0 should return same hash
        if (__v == 0)
            return 0;
#if defined(__i386__)
        // Zero out padding bits
        union
        {
            long double __t;
            struct
            {
                size_t __a;
                size_t __b;
                size_t __c;
                size_t __d;
            };
        } __u;
        __u.__a = 0;
        __u.__b = 0;
        __u.__c = 0;
        __u.__d = 0;
        __u.__t = __v;
        return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d;
#elif defined(__x86_64__)
        // Zero out padding bits
        union
        {
            long double __t;
            struct
            {
                size_t __a;
                size_t __b;
            };
        } __u;
        __u.__a = 0;
        __u.__b = 0;
        __u.__t = __v;
        return __u.__a ^ __u.__b;
#else
        return __scalar_hash<long double>::operator()(__v);
#endif
    }
};

// struct hash<T*> in <memory>

_LIBCPP_END_NAMESPACE_STD

#endif  // _LIBCPP_FUNCTIONAL
@


1.2.2.3
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 243376
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r243376 | dim | 2012-11-21 18:38:56 +0000 (Wed, 21 Nov 2012) | 14 lines
## SVN ##
## SVN ## MFC r241903:
## SVN ##
## SVN ##   Import libc++ trunk r165949.  Among other improvements and bug fixes,
## SVN ##   this has many visibility problems fixed, which should help with
## SVN ##   compiling certain ports that exercise C++11 mode (i.e. Firefox).
## SVN ##
## SVN ##   Also, belatedly add the LICENSE.TXT and accompanying CREDITS.TXT files,
## SVN ##   which are referred to in all the source files.
## SVN ##
## SVN ## MFC r241907:
## SVN ##
## SVN ##   Fix two -Wsystem-header warnings in libc++ that were exposed by the new
## SVN ##   ATF import.  These have also been sent upstream.
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d1116 1
a1116 2
    template <class _Fp, bool = !is_same<_Fp, function>::value &&
                                __invokable<_Fp&, _ArgTypes...>::value>
a1352 1
    return *this;
a1363 1
    return *this;
d1710 1
a1710 5
    template <class _Gp, class ..._BA,
              class = typename enable_if
                               <
                                  is_constructible<_Fd, _Gp>::value
                               >::type>
@


1.2.2.4
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/250514
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@d477 1
a477 1
struct _LIBCPP_TYPE_VIS plus : binary_function<_Tp, _Tp, _Tp>
d484 1
a484 1
struct _LIBCPP_TYPE_VIS minus : binary_function<_Tp, _Tp, _Tp>
d491 1
a491 1
struct _LIBCPP_TYPE_VIS multiplies : binary_function<_Tp, _Tp, _Tp>
d498 1
a498 1
struct _LIBCPP_TYPE_VIS divides : binary_function<_Tp, _Tp, _Tp>
d505 1
a505 1
struct _LIBCPP_TYPE_VIS modulus : binary_function<_Tp, _Tp, _Tp>
d512 1
a512 1
struct _LIBCPP_TYPE_VIS negate : unary_function<_Tp, _Tp>
d519 1
a519 1
struct _LIBCPP_TYPE_VIS equal_to : binary_function<_Tp, _Tp, bool>
d526 1
a526 1
struct _LIBCPP_TYPE_VIS not_equal_to : binary_function<_Tp, _Tp, bool>
d533 1
a533 1
struct _LIBCPP_TYPE_VIS greater : binary_function<_Tp, _Tp, bool>
d542 1
a542 1
struct _LIBCPP_TYPE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
d549 1
a549 1
struct _LIBCPP_TYPE_VIS less_equal : binary_function<_Tp, _Tp, bool>
d556 1
a556 1
struct _LIBCPP_TYPE_VIS logical_and : binary_function<_Tp, _Tp, bool>
d563 1
a563 1
struct _LIBCPP_TYPE_VIS logical_or : binary_function<_Tp, _Tp, bool>
d570 1
a570 1
struct _LIBCPP_TYPE_VIS logical_not : unary_function<_Tp, bool>
d577 1
a577 1
struct _LIBCPP_TYPE_VIS bit_and : binary_function<_Tp, _Tp, _Tp>
d584 1
a584 1
struct _LIBCPP_TYPE_VIS bit_or : binary_function<_Tp, _Tp, _Tp>
d591 1
a591 1
struct _LIBCPP_TYPE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp>
d598 1
a598 1
class _LIBCPP_TYPE_VIS unary_negate
d615 1
a615 1
class _LIBCPP_TYPE_VIS binary_negate
d635 1
a635 1
class _LIBCPP_TYPE_VIS binder1st
d661 1
a661 1
class _LIBCPP_TYPE_VIS binder2nd
d687 1
a687 1
class _LIBCPP_TYPE_VIS pointer_to_unary_function
d705 1
a705 1
class _LIBCPP_TYPE_VIS pointer_to_binary_function
d723 1
a723 1
class _LIBCPP_TYPE_VIS mem_fun_t : public unary_function<_Tp*, _Sp>
d734 1
a734 1
class _LIBCPP_TYPE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
d757 1
a757 1
class _LIBCPP_TYPE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp>
d768 1
a768 1
class _LIBCPP_TYPE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
d791 1
a791 1
class _LIBCPP_TYPE_VIS const_mem_fun_t : public unary_function<const _Tp*, _Sp>
d802 1
a802 1
class _LIBCPP_TYPE_VIS const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
d825 1
a825 1
class _LIBCPP_TYPE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
d836 1
a836 1
class _LIBCPP_TYPE_VIS const_mem_fun1_ref_t
d935 1
a935 1
template<class _Fp> class _LIBCPP_TYPE_VIS function; // undefined
d1086 1
a1086 1
class _LIBCPP_TYPE_VIS function<_Rp(_ArgTypes...)>
d1091 1
a1091 1
    typename aligned_storage<3*sizeof(void*)>::type __buf_;
d1499 1
a1499 1
template<class _Tp> struct _LIBCPP_TYPE_VIS is_bind_expression
d1503 1
a1503 1
template<class _Tp> struct _LIBCPP_TYPE_VIS is_placeholder
d1627 1
a1627 2
                           0 < is_placeholder<_Ti>::value &&
                           is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
a1632 21
struct _is_valid_bind_return
{
    static const bool value = false;
};

template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
{
    static const bool value = __invokable<_Fp,
                    typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
};

template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
{
    static const bool value = __invokable<_Fp,
                    typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
};

template <class _Fp, class _BoundArgs, class _TupleUj,
          bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
d1636 1
a1636 1
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
d1650 1
a1650 1
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
a1675 1
protected:
a1677 1
private:
d1734 1
a1734 1
        typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
a1749 2
    typedef typename base::_Fd _Fd;
    typedef typename base::_Td _Td;
d1787 1
a1787 6
        typename enable_if
        <
            is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
                           result_type>::value,
            result_type
        >::type
d1795 1
a1795 6
        typename enable_if
        <
            is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
                           result_type>::value,
            result_type
        >::type
d1826 1
a1826 1
struct _LIBCPP_TYPE_VIS hash<bool>
d1834 1
a1834 1
struct _LIBCPP_TYPE_VIS hash<char>
d1842 1
a1842 1
struct _LIBCPP_TYPE_VIS hash<signed char>
d1850 1
a1850 1
struct _LIBCPP_TYPE_VIS hash<unsigned char>
d1860 1
a1860 1
struct _LIBCPP_TYPE_VIS hash<char16_t>
d1868 1
a1868 1
struct _LIBCPP_TYPE_VIS hash<char32_t>
d1878 1
a1878 1
struct _LIBCPP_TYPE_VIS hash<wchar_t>
d1886 1
a1886 1
struct _LIBCPP_TYPE_VIS hash<short>
d1894 1
a1894 1
struct _LIBCPP_TYPE_VIS hash<unsigned short>
d1902 1
a1902 1
struct _LIBCPP_TYPE_VIS hash<int>
d1910 1
a1910 1
struct _LIBCPP_TYPE_VIS hash<unsigned int>
d1918 1
a1918 1
struct _LIBCPP_TYPE_VIS hash<long>
d1926 1
a1926 1
struct _LIBCPP_TYPE_VIS hash<unsigned long>
d1934 1
a1934 1
struct _LIBCPP_TYPE_VIS hash<long long>
d1940 1
a1940 1
struct _LIBCPP_TYPE_VIS hash<unsigned long long>
d1946 1
a1946 1
struct _LIBCPP_TYPE_VIS hash<float>
d1960 1
a1960 1
struct _LIBCPP_TYPE_VIS hash<double>
d1974 1
a1974 1
struct _LIBCPP_TYPE_VIS hash<long double>
@


1.2.2.5
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/253222
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@d1142 2
a1143 5
      function(_Fp, typename enable_if
                                     <
                                        __callable<_Fp>::value &&
                                        !is_same<_Fp, function>::value
                                      >::type* = 0);
d1165 1
a1165 2
        __callable<typename decay<_Fp>::type>::value &&
        !is_same<typename remove_reference<_Fp>::type, function>::value,
d1269 1
a1269 5
                                     typename enable_if
                                     <
                                        __callable<_Fp>::value &&
                                        !is_same<_Fp, function>::value
                                     >::type*)
d1373 1
a1373 2
    function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
    !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
a1596 6
template <bool _Invokable, class _Ti, class ..._Uj>
struct ____mu_return_invokable  // false
{
    typedef __nat type;
};

d1598 1
a1598 1
struct ____mu_return_invokable<true, _Ti, _Uj...>
a1602 6
template <class _Ti, class ..._Uj>
struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
    : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
{
};

d1740 1
a1740 3
                                  is_constructible<_Fd, _Gp>::value &&
                                  !is_same<typename remove_reference<_Gp>::type,
                                           __bind>::value
d1805 1
a1805 7
    template <class _Gp, class ..._BA,
              class = typename enable_if
                               <
                                  is_constructible<_Fd, _Gp>::value &&
                                  !is_same<typename remove_reference<_Gp>::type,
                                           __bind_r>::value
                               >::type>
@


1.2.2.6
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/262801
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@d59 1
a59 1
      typename result_of<T&(ArgTypes&&...)>::type
d71 1
a71 1
template <class T> // <class T=void> in C++14
d77 1
a77 1
template <class T> // <class T=void> in C++14
d83 1
a83 1
template <class T> // <class T=void> in C++14
d89 1
a89 1
template <class T> // <class T=void> in C++14
d95 1
a95 1
template <class T> // <class T=void> in C++14
d101 1
a101 1
template <class T> // <class T=void> in C++14
d107 1
a107 1
template <class T> // <class T=void> in C++14
d113 1
a113 1
template <class T> // <class T=void> in C++14
d119 1
a119 1
template <class T> // <class T=void> in C++14
d125 1
a125 1
template <class T> // <class T=void> in C++14
d131 1
a131 1
template <class T> // <class T=void> in C++14
d137 1
a137 1
template <class T> // <class T=void> in C++14
d143 1
a143 1
template <class T> // <class T=void> in C++14
d149 1
a149 1
template <class T> // <class T=void> in C++14
d155 1
a155 1
template <class T> // <class T=void> in C++14
a160 24
template <class T> // <class T=void> in C++14
struct bit_and : unary_function<T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T> // <class T=void> in C++14
struct bit_or : unary_function<T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T> // <class T=void> in C++14
struct bit_xor : unary_function<T, bool>
{
    bool operator()(const T& x, const T& y) const;
};

template <class T=void> // C++14
struct bit_xor : unary_function<T, bool>
{
    bool operator()(const T& x) const;
};

d337 12
a475 3
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d477 1
a477 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp>
d479 1
a479 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x, const _Tp& __y) const
a482 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY plus<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d484 1
a484 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp>
d486 1
a486 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x, const _Tp& __y) const
a489 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY minus<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d491 1
a491 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp>
d493 1
a493 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x, const _Tp& __y) const
a496 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d498 1
a498 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp>
d500 1
a500 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x, const _Tp& __y) const
a503 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY divides<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d505 1
a505 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp>
d507 1
a507 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x, const _Tp& __y) const
a510 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY modulus<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d512 1
a512 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp>
d514 1
a514 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x) const
a517 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY negate<void>
{
    template <class _Tp>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_Tp&& __x) const
        { return -_VSTD::forward<_Tp>(__x); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d519 1
a519 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool>
d521 1
a521 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const _Tp& __x, const _Tp& __y) const
a524 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d526 1
a526 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool>
d528 1
a528 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const _Tp& __x, const _Tp& __y) const
a531 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d533 1
a533 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool>
d535 1
a535 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const _Tp& __x, const _Tp& __y) const
a538 13
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY greater<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


a540 3
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d542 1
a542 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool>
d544 1
a544 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const _Tp& __x, const _Tp& __y) const
a547 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d549 1
a549 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool>
d551 1
a551 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const _Tp& __x, const _Tp& __y) const
a554 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d556 1
a556 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool>
d558 1
a558 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const _Tp& __x, const _Tp& __y) const
a561 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d563 1
a563 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool>
d565 1
a565 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const _Tp& __x, const _Tp& __y) const
a568 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d570 1
a570 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool>
d572 1
a572 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const _Tp& __x) const
a575 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
{
    template <class _Tp>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_Tp&& __x) const
        { return !_VSTD::forward<_Tp>(__x); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d577 1
a577 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp>
d579 1
a579 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x, const _Tp& __y) const
a582 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d584 1
a584 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp>
d586 1
a586 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x, const _Tp& __y) const
a589 16
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
d591 1
a591 2
#endif
struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp>
d593 1
a593 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x, const _Tp& __y) const
a596 33
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
{
    template <class _T1, class _T2>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_T1&& __t, _T2&& __u) const
        { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
    typedef void is_transparent;
};
#endif


#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp>
{
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    _Tp operator()(const _Tp& __x) const
        {return ~__x;}
};

template <>
struct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
{
    template <class _Tp>
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    auto operator()(_Tp&& __x) const
        { return ~_VSTD::forward<_Tp>(__x); }
    typedef void is_transparent;
};
#endif

d598 1
a598 1
class _LIBCPP_TYPE_VIS_ONLY unary_negate
d603 1
a603 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    explicit unary_negate(const _Predicate& __pred)
d605 1
a605 2
    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const typename _Predicate::argument_type& __x) const
d610 1
a610 1
inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
d615 1
a615 1
class _LIBCPP_TYPE_VIS_ONLY binary_negate
d622 3
a624 5
    _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 
    binary_negate(const _Predicate& __pred) : __pred_(__pred) {}

    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
    bool operator()(const typename _Predicate::first_argument_type& __x,
d630 1
a630 1
inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
d635 1
a635 1
class _LIBCPP_TYPE_VIS_ONLY binder1st
d661 1
a661 1
class _LIBCPP_TYPE_VIS_ONLY binder2nd
d687 1
a687 1
class _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function
d705 1
a705 1
class _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function
d723 1
a723 1
class _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp>
d734 1
a734 1
class _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
d757 1
a757 1
class _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp>
d768 1
a768 1
class _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
d791 1
a791 1
class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp>
d802 1
a802 1
class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
d825 1
a825 1
class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
d836 1
a836 1
class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t
d896 32
d935 1
a935 1
template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
d1086 1
a1086 1
class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
d1508 1
a1508 1
template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
d1512 1
a1512 1
template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
d1520 10
a1529 10
_LIBCPP_FUNC_VIS extern __ph<1>   _1;
_LIBCPP_FUNC_VIS extern __ph<2>   _2;
_LIBCPP_FUNC_VIS extern __ph<3>   _3;
_LIBCPP_FUNC_VIS extern __ph<4>   _4;
_LIBCPP_FUNC_VIS extern __ph<5>   _5;
_LIBCPP_FUNC_VIS extern __ph<6>   _6;
_LIBCPP_FUNC_VIS extern __ph<7>   _7;
_LIBCPP_FUNC_VIS extern __ph<8>   _8;
_LIBCPP_FUNC_VIS extern __ph<9>   _9;
_LIBCPP_FUNC_VIS extern __ph<10> _10;
d1891 1
a1891 1
struct _LIBCPP_TYPE_VIS_ONLY hash<bool>
d1899 1
a1899 1
struct _LIBCPP_TYPE_VIS_ONLY hash<char>
d1907 1
a1907 1
struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
d1915 1
a1915 1
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
d1925 1
a1925 1
struct _LIBCPP_TYPE_VIS_ONLY hash<char16_t>
d1933 1
a1933 1
struct _LIBCPP_TYPE_VIS_ONLY hash<char32_t>
d1943 1
a1943 1
struct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t>
d1951 1
a1951 1
struct _LIBCPP_TYPE_VIS_ONLY hash<short>
d1959 1
a1959 1
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
d1967 1
a1967 1
struct _LIBCPP_TYPE_VIS_ONLY hash<int>
d1975 1
a1975 1
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
d1983 1
a1983 1
struct _LIBCPP_TYPE_VIS_ONLY hash<long>
d1991 1
a1991 1
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
d1999 1
a1999 1
struct _LIBCPP_TYPE_VIS_ONLY hash<long long>
d2005 1
a2005 1
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
d2011 1
a2011 1
struct _LIBCPP_TYPE_VIS_ONLY hash<float>
d2025 1
a2025 1
struct _LIBCPP_TYPE_VIS_ONLY hash<double>
d2039 1
a2039 1
struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
a2087 16
#if _LIBCPP_STD_VER > 11
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY hash
    : public unary_function<_Tp, size_t>
{
    static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types");

    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(_Tp __v) const _NOEXCEPT
    {
        typedef typename underlying_type<_Tp>::type type;
        return hash<type>{}(static_cast<type>(__v));
    }
};
#endif

@


1.2.2.7
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/262956
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@d1224 1
a1224 1
          operator() (_ArgTypes&&... __args) const
@


1.1
log
@SVN rev 227983 on 2011-11-25 20:59:04Z by theraven

Import libc++ / libcxxrt into base.  Not build by default yet (use
MK_LIBCPLUSPLUS=yes to enable).  This is a work-in-progress.  It works for
me, but is not guaranteed to work for anyone else and may eat your dog.

To build C++ using libc++, add -stdlib=libc++ to your CXX and LD flags.

Bug reports welcome, bug fixes even more welcome...

Approved by:	dim (mentor)
@
text
@d201 1
a201 1
  extern unspecified _M;
d539 1
a539 6
template <class _Tp>
struct _LIBCPP_VISIBLE less : binary_function<_Tp, _Tp, bool>
{
    _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
        {return __x < __y;}
};
d888 1
a888 1
template<class _R, class _T>
d890 2
a891 2
__mem_fn<_R _T::*>
mem_fn(_R _T::* __pm)
d893 1
a893 1
    return __mem_fn<_R _T::*>(__pm);
d896 1
a896 1
template<class _R, class _T, class ..._Args>
d898 2
a899 2
__mem_fn<_R (_T::*)(_Args...)>
mem_fn(_R (_T::* __pm)(_Args...))
d901 1
a901 1
    return __mem_fn<_R (_T::*)(_Args...)>(__pm);
d904 1
a904 1
template<class _R, class _T, class ..._Args>
d906 2
a907 2
__mem_fn<_R (_T::*)(_Args...) const>
mem_fn(_R (_T::* __pm)(_Args...) const)
d909 1
a909 1
    return __mem_fn<_R (_T::*)(_Args...) const>(__pm);
d912 1
a912 1
template<class _R, class _T, class ..._Args>
d914 2
a915 2
__mem_fn<_R (_T::*)(_Args...) volatile>
mem_fn(_R (_T::* __pm)(_Args...) volatile)
d917 1
a917 1
    return __mem_fn<_R (_T::*)(_Args...) volatile>(__pm);
d920 1
a920 1
template<class _R, class _T, class ..._Args>
d922 2
a923 2
__mem_fn<_R (_T::*)(_Args...) const volatile>
mem_fn(_R (_T::* __pm)(_Args...) const volatile)
d925 1
a925 1
    return __mem_fn<_R (_T::*)(_Args...) const volatile>(__pm);
d940 1
a940 1
template<class _R, class ..._ArgTypes>
d945 3
a947 3
template<class _R, class _A1>
struct __maybe_derive_from_unary_function<_R(_A1)>
    : public unary_function<_A1, _R>
d951 1
a951 1
template<class _R, class ..._ArgTypes>
d956 3
a958 3
template<class _R, class _A1, class _A2>
struct __maybe_derive_from_binary_function<_R(_A1, _A2)>
    : public binary_function<_A1, _A2, _R>
d964 2
a965 2
template<class _R, class ..._ArgTypes>
class __base<_R(_ArgTypes...)>
d976 1
a976 1
    virtual _R operator()(_ArgTypes&& ...) = 0;
d985 3
a987 3
template<class _F, class _Alloc, class _R, class ..._ArgTypes>
class __func<_F, _Alloc, _R(_ArgTypes...)>
    : public  __base<_R(_ArgTypes...)>
d989 1
a989 1
    __compressed_pair<_F, _Alloc> __f_;
d992 8
a999 1
    explicit __func(_F __f) : __f_(_VSTD::move(__f)) {}
d1001 10
a1010 3
    explicit __func(_F __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
    virtual __base<_R(_ArgTypes...)>* __clone() const;
    virtual void __clone(__base<_R(_ArgTypes...)>*) const;
d1013 1
a1013 1
    virtual _R operator()(_ArgTypes&& ... __arg);
d1020 8
a1027 8
template<class _F, class _Alloc, class _R, class ..._ArgTypes>
__base<_R(_ArgTypes...)>*
__func<_F, _Alloc, _R(_ArgTypes...)>::__clone() const
{
    typedef typename _Alloc::template rebind<__func>::other _A;
    _A __a(__f_.second());
    typedef __allocator_destructor<_A> _D;
    unique_ptr<__func, _D> __hold(__a.allocate(1), _D(__a, 1));
d1032 1
a1032 1
template<class _F, class _Alloc, class _R, class ..._ArgTypes>
d1034 1
a1034 1
__func<_F, _Alloc, _R(_ArgTypes...)>::__clone(__base<_R(_ArgTypes...)>* __p) const
d1039 1
a1039 1
template<class _F, class _Alloc, class _R, class ..._ArgTypes>
d1041 1
a1041 1
__func<_F, _Alloc, _R(_ArgTypes...)>::destroy() _NOEXCEPT
d1043 1
a1043 1
    __f_.~__compressed_pair<_F, _Alloc>();
d1046 1
a1046 1
template<class _F, class _Alloc, class _R, class ..._ArgTypes>
d1048 1
a1048 1
__func<_F, _Alloc, _R(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
d1050 3
a1052 3
    typedef typename _Alloc::template rebind<__func>::other _A;
    _A __a(__f_.second());
    __f_.~__compressed_pair<_F, _Alloc>();
d1056 3
a1058 3
template<class _F, class _Alloc, class _R, class ..._ArgTypes>
_R
__func<_F, _Alloc, _R(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
d1065 1
a1065 1
template<class _F, class _Alloc, class _R, class ..._ArgTypes>
d1067 1
a1067 1
__func<_F, _Alloc, _R(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
d1069 1
a1069 1
    if (__ti == typeid(_F))
d1074 1
a1074 1
template<class _F, class _Alloc, class _R, class ..._ArgTypes>
d1076 1
a1076 1
__func<_F, _Alloc, _R(_ArgTypes...)>::target_type() const _NOEXCEPT
d1078 1
a1078 1
    return typeid(_F);
d1085 4
a1088 4
template<class _R, class ..._ArgTypes>
class _LIBCPP_VISIBLE function<_R(_ArgTypes...)>
    : public __function::__maybe_derive_from_unary_function<_R(_ArgTypes...)>,
      public __function::__maybe_derive_from_binary_function<_R(_ArgTypes...)>
d1090 1
a1090 1
    typedef __function::__base<_R(_ArgTypes...)> __base;
d1094 1
a1094 1
    template <class _F>
d1096 2
a1097 2
        static bool __not_null(const _F&) {return true;}
    template <class _R2, class ..._A>
d1099 2
a1100 2
        static bool __not_null(_R2 (*__p)(_A...)) {return __p;}
    template <class _R2, class _C, class ..._A>
d1102 2
a1103 2
        static bool __not_null(_R2 (_C::*__p)(_A...)) {return __p;}
    template <class _R2, class _C, class ..._A>
d1105 2
a1106 2
        static bool __not_null(_R2 (_C::*__p)(_A...) const) {return __p;}
    template <class _R2, class _C, class ..._A>
d1108 2
a1109 2
        static bool __not_null(_R2 (_C::*__p)(_A...) volatile) {return __p;}
    template <class _R2, class _C, class ..._A>
d1111 2
a1112 2
        static bool __not_null(_R2 (_C::*__p)(_A...) const volatile) {return __p;}
    template <class _R2, class ..._A>
d1114 1
a1114 1
        static bool __not_null(const function<_R(_A...)>& __p) {return __p;}
d1116 1
a1116 1
    template <class _F, bool = __invokable<_F&, _ArgTypes...>::value>
d1118 2
a1119 2
    template <class _F>
        struct __callable<_F, true>
d1122 2
a1123 2
                is_convertible<typename __invoke_of<_F&, _ArgTypes...>::type,
                               _R>::value;
d1125 2
a1126 2
    template <class _F>
        struct __callable<_F, false>
d1131 1
a1131 1
    typedef _R result_type;
d1140 3
a1142 3
    template<class _F>
      function(_F,
               typename enable_if<__callable<_F>::value>::type* = 0);
d1154 3
a1156 3
    template<class _F, class _Alloc>
      function(allocator_arg_t, const _Alloc& __a, _F __f,
               typename enable_if<__callable<_F>::value>::type* = 0);
d1161 1
a1161 1
    template<class _F>
d1164 1
a1164 1
        __callable<typename decay<_F>::type>::value,
d1167 1
a1167 1
      operator=(_F&&);
d1173 1
a1173 1
    template<class _F, class _Alloc>
d1175 2
a1176 2
      void assign(_F&& __f, const _Alloc& __a)
        {function(allocator_arg, __a, _VSTD::forward<_F>(__f)).swap(*this);}
d1180 1
a1180 1
    /*explicit*/ operator bool() const _NOEXCEPT {return __f_;}
d1189 1
a1189 1
    _R operator()(_ArgTypes...) const;
d1194 2
a1195 2
    template <typename _T> _T* target() _NOEXCEPT;
    template <typename _T> const _T* target() const _NOEXCEPT;
d1199 2
a1200 2
template<class _R, class ..._ArgTypes>
function<_R(_ArgTypes...)>::function(const function& __f)
d1213 1
a1213 1
template<class _R, class ..._ArgTypes>
d1215 1
a1215 1
function<_R(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
d1229 2
a1230 2
template<class _R, class ..._ArgTypes>
function<_R(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
d1246 1
a1246 1
template<class _R, class ..._ArgTypes>
d1248 1
a1248 1
function<_R(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
d1265 4
a1268 4
template<class _R, class ..._ArgTypes>
template <class _F>
function<_R(_ArgTypes...)>::function(_F __f,
                                     typename enable_if<__callable<_F>::value>::type*)
d1273 2
a1274 2
        typedef __function::__func<_F, allocator<_F>, _R(_ArgTypes...)> _FF;
        if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_F>::value)
d1281 5
a1285 5
            typedef allocator<_FF> _A;
            _A __a;
            typedef __allocator_destructor<_A> _D;
            unique_ptr<__base, _D> __hold(__a.allocate(1), _D(__a, 1));
            ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_F>(__a));
d1291 4
a1294 4
template<class _R, class ..._ArgTypes>
template <class _F, class _Alloc>
function<_R(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _F __f,
                                     typename enable_if<__callable<_F>::value>::type*)
d1300 2
a1301 2
        typedef __function::__func<_F, _Alloc, _R(_ArgTypes...)> _FF;
        if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_F>::value)
d1314 4
a1317 4
                                                         _A;
            _A __a(__a0);
            typedef __allocator_destructor<_A> _D;
            unique_ptr<__base, _D> __hold(__a.allocate(1), _D(__a, 1));
d1324 3
a1326 3
template<class _R, class ..._ArgTypes>
function<_R(_ArgTypes...)>&
function<_R(_ArgTypes...)>::operator=(const function& __f)
d1332 3
a1334 3
template<class _R, class ..._ArgTypes>
function<_R(_ArgTypes...)>&
function<_R(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
d1355 3
a1357 3
template<class _R, class ..._ArgTypes>
function<_R(_ArgTypes...)>&
function<_R(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
d1366 2
a1367 2
template<class _R, class ..._ArgTypes>
template <class _F>
d1370 2
a1371 2
    function<_R(_ArgTypes...)>::template __callable<typename decay<_F>::type>::value,
    function<_R(_ArgTypes...)>&
d1373 1
a1373 1
function<_R(_ArgTypes...)>::operator=(_F&& __f)
d1375 1
a1375 1
    function(_VSTD::forward<_F>(__f)).swap(*this);
d1379 2
a1380 2
template<class _R, class ..._ArgTypes>
function<_R(_ArgTypes...)>::~function()
d1388 1
a1388 1
template<class _R, class ..._ArgTypes>
d1390 1
a1390 1
function<_R(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
d1425 3
a1427 3
template<class _R, class ..._ArgTypes>
_R
function<_R(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
d1438 1
a1438 1
template<class _R, class ..._ArgTypes>
d1440 1
a1440 1
function<_R(_ArgTypes...)>::target_type() const _NOEXCEPT
d1447 4
a1450 4
template<class _R, class ..._ArgTypes>
template <typename _T>
_T*
function<_R(_ArgTypes...)>::target() _NOEXCEPT
d1453 2
a1454 2
        return (_T*)0;
    return (_T*)__f_->target(typeid(_T));
d1457 4
a1460 4
template<class _R, class ..._ArgTypes>
template <typename _T>
const _T*
function<_R(_ArgTypes...)>::target() const _NOEXCEPT
d1463 2
a1464 2
        return (const _T*)0;
    return (const _T*)__f_->target(typeid(_T));
d1469 1
a1469 1
template <class _R, class... _ArgTypes>
d1472 1
a1472 1
operator==(const function<_R(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
d1474 1
a1474 1
template <class _R, class... _ArgTypes>
d1477 1
a1477 1
operator==(nullptr_t, const function<_R(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
d1479 1
a1479 1
template <class _R, class... _ArgTypes>
d1482 1
a1482 1
operator!=(const function<_R(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
d1484 1
a1484 1
template <class _R, class... _ArgTypes>
d1487 1
a1487 1
operator!=(nullptr_t, const function<_R(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
d1489 1
a1489 1
template <class _R, class... _ArgTypes>
d1492 1
a1492 1
swap(function<_R(_ArgTypes...)>& __x, function<_R(_ArgTypes...)>& __y) _NOEXCEPT
d1506 1
a1506 1
template <int _N> struct __ph {};
d1521 3
a1523 3
template<int _N>
struct __is_placeholder<placeholders::__ph<_N> >
    : public integral_constant<int, _N> {};
d1585 1
a1585 1
__mu(_Ti& __ti, _Uj& __uj)
d1629 1
a1629 1
template <class _F, class _BoundArgs, class _TupleUj>
d1632 2
a1633 2
template <class _F, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_F, tuple<_BoundArgs...>, _TupleUj>
d1637 1
a1637 1
        _F&,
d1646 2
a1647 2
template <class _F, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_F, const tuple<_BoundArgs...>, _TupleUj>
d1651 1
a1651 1
        _F&,
d1660 1
a1660 1
template <class _F, class _BoundArgs, size_t ..._Indx, class _Args>
d1662 2
a1663 2
typename __bind_return<_F, _BoundArgs, _Args>::type
__apply_functor(_F& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
d1669 1
a1669 1
template<class _F, class ..._BoundArgs>
d1671 1
a1671 1
    : public __weak_result_type<typename decay<_F>::type>
d1673 1
a1673 1
    typedef typename decay<_F>::type _Fd;
d1710 1
a1710 1
    template <class _G, class ..._BA>
d1712 2
a1713 2
      explicit __bind(_G&& __f, _BA&& ...__bound_args)
        : __f_(_VSTD::forward<_G>(__f)),
d1735 2
a1736 2
template<class _F, class ..._BoundArgs>
struct __is_bind_expression<__bind<_F, _BoundArgs...> > : public true_type {};
d1738 1
a1738 1
template<class _R, class _F, class ..._BoundArgs>
d1740 1
a1740 1
    : public __bind<_F, _BoundArgs...>
d1742 1
a1742 1
    typedef __bind<_F, _BoundArgs...> base;
d1744 1
a1744 1
    typedef _R result_type;
d1772 1
a1772 1
    template <class _G, class ..._BA>
d1774 2
a1775 2
      explicit __bind_r(_G&& __f, _BA&& ...__bound_args)
        : base(_VSTD::forward<_G>(__f),
d1795 2
a1796 2
template<class _R, class _F, class ..._BoundArgs>
struct __is_bind_expression<__bind_r<_R, _F, _BoundArgs...> > : public true_type {};
d1798 1
a1798 1
template<class _F, class ..._BoundArgs>
d1800 2
a1801 2
__bind<_F, _BoundArgs...>
bind(_F&& __f, _BoundArgs&&... __bound_args)
d1803 2
a1804 2
    typedef __bind<_F, _BoundArgs...> type;
    return type(_VSTD::forward<_F>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
d1807 1
a1807 1
template<class _R, class _F, class ..._BoundArgs>
d1809 2
a1810 2
__bind_r<_R, _F, _BoundArgs...>
bind(_F&& __f, _BoundArgs&&... __bound_args)
d1812 2
a1813 2
    typedef __bind_r<_R, _F, _BoundArgs...> type;
    return type(_VSTD::forward<_F>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
d1928 1
a1928 1
    : public unary_function<long long, size_t>
a1929 9
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(long long __v) const _NOEXCEPT
    {
        size_t __r = 0;
        const size_t* const __p = reinterpret_cast<const size_t*>(&__v);
        for (unsigned __i = 0; __i < sizeof(argument_type)/sizeof(size_t); ++__i)
            __r ^= __p[__i];
        return __r;
    }
d1934 1
a1934 1
    : public unary_function<unsigned long long, size_t>
a1935 9
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(unsigned long long __v) const _NOEXCEPT
    {
        size_t __r = 0;
        const size_t* const __p = reinterpret_cast<const size_t*>(&__v);
        for (unsigned __i = 0; __i < sizeof(argument_type)/sizeof(size_t); ++__i)
            __r ^= __p[__i];
        return __r;
    }
d1940 1
a1940 1
    : public unary_function<float, size_t>
d1945 4
a1948 4
        if (__v == 0)
            return 0;
        const size_t* const __p = reinterpret_cast<const size_t*>(&__v);
        return *__p;
d1954 1
a1954 1
    : public unary_function<double, size_t>
d1959 4
a1962 7
        if (__v == 0)
            return 0;
        size_t __r = 0;
        const size_t* const __p = reinterpret_cast<const size_t*>(&__v);
        for (unsigned __i = 0; __i < sizeof(argument_type)/sizeof(size_t); ++__i)
            __r ^= __p[__i];
        return __r;
d1968 1
a1968 1
    : public unary_function<long double, size_t>
d1973 1
d1976 37
a2012 5
        size_t __r = 0;
        const size_t* const __p = reinterpret_cast<const size_t*>(&__v);
        for (unsigned __i = 0; __i < sizeof(argument_type)/sizeof(size_t); ++__i)
            __r ^= __p[__i];
        return __r;
@

