1227825Stheraven// -*- C++ -*-
2227825Stheraven//===------------------------ functional ----------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_FUNCTIONAL
12227825Stheraven#define _LIBCPP_FUNCTIONAL
13227825Stheraven
14227825Stheraven/*
15227825Stheraven    functional synopsis
16227825Stheraven
17227825Stheravennamespace std
18227825Stheraven{
19227825Stheraven
20227825Stheraventemplate <class Arg, class Result>
21227825Stheravenstruct unary_function
22227825Stheraven{
23227825Stheraven    typedef Arg    argument_type;
24227825Stheraven    typedef Result result_type;
25227825Stheraven};
26227825Stheraven
27227825Stheraventemplate <class Arg1, class Arg2, class Result>
28227825Stheravenstruct binary_function
29227825Stheraven{
30227825Stheraven    typedef Arg1   first_argument_type;
31227825Stheraven    typedef Arg2   second_argument_type;
32227825Stheraven    typedef Result result_type;
33227825Stheraven};
34227825Stheraven
35227825Stheraventemplate <class T>
36227825Stheravenclass reference_wrapper
37227825Stheraven    : public unary_function<T1, R> // if wrapping a unary functor
38227825Stheraven    : public binary_function<T1, T2, R> // if wraping a binary functor
39227825Stheraven{
40227825Stheravenpublic:
41227825Stheraven    // types
42227825Stheraven    typedef T type;
43227825Stheraven    typedef see below result_type; // Not always defined
44227825Stheraven
45227825Stheraven    // construct/copy/destroy
46227825Stheraven    reference_wrapper(T&) noexcept;
47227825Stheraven    reference_wrapper(T&&) = delete; // do not bind to temps
48227825Stheraven    reference_wrapper(const reference_wrapper<T>& x) noexcept;
49227825Stheraven
50227825Stheraven    // assignment
51227825Stheraven    reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;
52227825Stheraven
53227825Stheraven    // access
54227825Stheraven    operator T& () const noexcept;
55227825Stheraven    T& get() const noexcept;
56227825Stheraven
57227825Stheraven    // invoke
58227825Stheraven    template <class... ArgTypes>
59261272Sdim      typename result_of<T&(ArgTypes&&...)>::type
60227825Stheraven          operator() (ArgTypes&&...) const;
61227825Stheraven};
62227825Stheraven
63227825Stheraventemplate <class T> reference_wrapper<T> ref(T& t) noexcept;
64227825Stheraventemplate <class T> void ref(const T&& t) = delete;
65227825Stheraventemplate <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;
66227825Stheraven
67227825Stheraventemplate <class T> reference_wrapper<const T> cref(const T& t) noexcept;
68227825Stheraventemplate <class T> void cref(const T&& t) = delete;
69227825Stheraventemplate <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
70227825Stheraven
71261272Sdimtemplate <class T> // <class T=void> in C++14
72227825Stheravenstruct plus : binary_function<T, T, T>
73227825Stheraven{
74227825Stheraven    T operator()(const T& x, const T& y) const;
75227825Stheraven};
76227825Stheraven
77261272Sdimtemplate <class T> // <class T=void> in C++14
78227825Stheravenstruct minus : binary_function<T, T, T>
79227825Stheraven{
80227825Stheraven    T operator()(const T& x, const T& y) const;
81227825Stheraven};
82227825Stheraven
83261272Sdimtemplate <class T> // <class T=void> in C++14
84227825Stheravenstruct multiplies : binary_function<T, T, T>
85227825Stheraven{
86227825Stheraven    T operator()(const T& x, const T& y) const;
87227825Stheraven};
88227825Stheraven
89261272Sdimtemplate <class T> // <class T=void> in C++14
90227825Stheravenstruct divides : binary_function<T, T, T>
91227825Stheraven{
92227825Stheraven    T operator()(const T& x, const T& y) const;
93227825Stheraven};
94227825Stheraven
95261272Sdimtemplate <class T> // <class T=void> in C++14
96227825Stheravenstruct modulus : binary_function<T, T, T>
97227825Stheraven{
98227825Stheraven    T operator()(const T& x, const T& y) const;
99227825Stheraven};
100227825Stheraven
101261272Sdimtemplate <class T> // <class T=void> in C++14
102227825Stheravenstruct negate : unary_function<T, T>
103227825Stheraven{
104227825Stheraven    T operator()(const T& x) const;
105227825Stheraven};
106227825Stheraven
107261272Sdimtemplate <class T> // <class T=void> in C++14
108227825Stheravenstruct equal_to : binary_function<T, T, bool>
109227825Stheraven{
110227825Stheraven    bool operator()(const T& x, const T& y) const;
111227825Stheraven};
112227825Stheraven
113261272Sdimtemplate <class T> // <class T=void> in C++14
114227825Stheravenstruct not_equal_to : binary_function<T, T, bool>
115227825Stheraven{
116227825Stheraven    bool operator()(const T& x, const T& y) const;
117227825Stheraven};
118227825Stheraven
119261272Sdimtemplate <class T> // <class T=void> in C++14
120227825Stheravenstruct greater : binary_function<T, T, bool>
121227825Stheraven{
122227825Stheraven    bool operator()(const T& x, const T& y) const;
123227825Stheraven};
124227825Stheraven
125261272Sdimtemplate <class T> // <class T=void> in C++14
126227825Stheravenstruct less : binary_function<T, T, bool>
127227825Stheraven{
128227825Stheraven    bool operator()(const T& x, const T& y) const;
129227825Stheraven};
130227825Stheraven
131261272Sdimtemplate <class T> // <class T=void> in C++14
132227825Stheravenstruct greater_equal : binary_function<T, T, bool>
133227825Stheraven{
134227825Stheraven    bool operator()(const T& x, const T& y) const;
135227825Stheraven};
136227825Stheraven
137261272Sdimtemplate <class T> // <class T=void> in C++14
138227825Stheravenstruct less_equal : binary_function<T, T, bool>
139227825Stheraven{
140227825Stheraven    bool operator()(const T& x, const T& y) const;
141227825Stheraven};
142227825Stheraven
143261272Sdimtemplate <class T> // <class T=void> in C++14
144227825Stheravenstruct logical_and : binary_function<T, T, bool>
145227825Stheraven{
146227825Stheraven    bool operator()(const T& x, const T& y) const;
147227825Stheraven};
148227825Stheraven
149261272Sdimtemplate <class T> // <class T=void> in C++14
150227825Stheravenstruct logical_or : binary_function<T, T, bool>
151227825Stheraven{
152227825Stheraven    bool operator()(const T& x, const T& y) const;
153227825Stheraven};
154227825Stheraven
155261272Sdimtemplate <class T> // <class T=void> in C++14
156227825Stheravenstruct logical_not : unary_function<T, bool>
157227825Stheraven{
158227825Stheraven    bool operator()(const T& x) const;
159227825Stheraven};
160227825Stheraven
161261272Sdimtemplate <class T> // <class T=void> in C++14
162261272Sdimstruct bit_and : unary_function<T, bool>
163261272Sdim{
164261272Sdim    bool operator()(const T& x, const T& y) const;
165261272Sdim};
166261272Sdim
167261272Sdimtemplate <class T> // <class T=void> in C++14
168261272Sdimstruct bit_or : unary_function<T, bool>
169261272Sdim{
170261272Sdim    bool operator()(const T& x, const T& y) const;
171261272Sdim};
172261272Sdim
173261272Sdimtemplate <class T> // <class T=void> in C++14
174261272Sdimstruct bit_xor : unary_function<T, bool>
175261272Sdim{
176261272Sdim    bool operator()(const T& x, const T& y) const;
177261272Sdim};
178261272Sdim
179261272Sdimtemplate <class T=void> // C++14
180261272Sdimstruct bit_xor : unary_function<T, bool>
181261272Sdim{
182261272Sdim    bool operator()(const T& x) const;
183261272Sdim};
184261272Sdim
185227825Stheraventemplate <class Predicate>
186227825Stheravenclass unary_negate
187227825Stheraven    : public unary_function<typename Predicate::argument_type, bool>
188227825Stheraven{
189227825Stheravenpublic:
190227825Stheraven    explicit unary_negate(const Predicate& pred);
191227825Stheraven    bool operator()(const typename Predicate::argument_type& x) const;
192227825Stheraven};
193227825Stheraven
194227825Stheraventemplate <class Predicate> unary_negate<Predicate> not1(const Predicate& pred);
195227825Stheraven
196227825Stheraventemplate <class Predicate>
197227825Stheravenclass binary_negate
198227825Stheraven    : public binary_function<typename Predicate::first_argument_type,
199227825Stheraven                             typename Predicate::second_argument_type,
200227825Stheraven                             bool>
201227825Stheraven{
202227825Stheravenpublic:
203227825Stheraven    explicit binary_negate(const Predicate& pred);
204227825Stheraven    bool operator()(const typename Predicate::first_argument_type& x,
205227825Stheraven                    const typename Predicate::second_argument_type& y) const;
206227825Stheraven};
207227825Stheraven
208227825Stheraventemplate <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);
209227825Stheraven
210227825Stheraventemplate<class T> struct is_bind_expression;
211227825Stheraventemplate<class T> struct is_placeholder;
212227825Stheraven
213227825Stheraventemplate<class Fn, class... BoundArgs>
214227825Stheraven  unspecified bind(Fn&&, BoundArgs&&...);
215227825Stheraventemplate<class R, class Fn, class... BoundArgs>
216227825Stheraven  unspecified bind(Fn&&, BoundArgs&&...);
217227825Stheraven
218227825Stheravennamespace placeholders {
219227825Stheraven  // M is the implementation-defined number of placeholders
220227825Stheraven  extern unspecified _1;
221227825Stheraven  extern unspecified _2;
222227825Stheraven  .
223227825Stheraven  .
224227825Stheraven  .
225232924Stheraven  extern unspecified _Mp;
226227825Stheraven}
227227825Stheraven
228227825Stheraventemplate <class Operation>
229227825Stheravenclass binder1st
230227825Stheraven    : public unary_function<typename Operation::second_argument_type,
231227825Stheraven                            typename Operation::result_type>
232227825Stheraven{
233227825Stheravenprotected:
234227825Stheraven    Operation                               op;
235227825Stheraven    typename Operation::first_argument_type value;
236227825Stheravenpublic:
237227825Stheraven    binder1st(const Operation& x, const typename Operation::first_argument_type y);
238227825Stheraven    typename Operation::result_type operator()(      typename Operation::second_argument_type& x) const;
239227825Stheraven    typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
240227825Stheraven};
241227825Stheraven
242227825Stheraventemplate <class Operation, class T>
243227825Stheravenbinder1st<Operation> bind1st(const Operation& op, const T& x);
244227825Stheraven
245227825Stheraventemplate <class Operation>
246227825Stheravenclass binder2nd
247227825Stheraven    : public unary_function<typename Operation::first_argument_type,
248227825Stheraven                            typename Operation::result_type>
249227825Stheraven{
250227825Stheravenprotected:
251227825Stheraven    Operation                                op;
252227825Stheraven    typename Operation::second_argument_type value;
253227825Stheravenpublic:
254227825Stheraven    binder2nd(const Operation& x, const typename Operation::second_argument_type y);
255227825Stheraven    typename Operation::result_type operator()(      typename Operation::first_argument_type& x) const;
256227825Stheraven    typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
257227825Stheraven};
258227825Stheraven
259227825Stheraventemplate <class Operation, class T>
260227825Stheravenbinder2nd<Operation> bind2nd(const Operation& op, const T& x);
261227825Stheraven
262227825Stheraventemplate <class Arg, class Result>
263227825Stheravenclass pointer_to_unary_function : public unary_function<Arg, Result>
264227825Stheraven{
265227825Stheravenpublic:
266227825Stheraven    explicit pointer_to_unary_function(Result (*f)(Arg));
267227825Stheraven    Result operator()(Arg x) const;
268227825Stheraven};
269227825Stheraven
270227825Stheraventemplate <class Arg, class Result>
271227825Stheravenpointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));
272227825Stheraven
273227825Stheraventemplate <class Arg1, class Arg2, class Result>
274227825Stheravenclass pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
275227825Stheraven{
276227825Stheravenpublic:
277227825Stheraven    explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
278227825Stheraven    Result operator()(Arg1 x, Arg2 y) const;
279227825Stheraven};
280227825Stheraven
281227825Stheraventemplate <class Arg1, class Arg2, class Result>
282227825Stheravenpointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));
283227825Stheraven
284227825Stheraventemplate<class S, class T>
285227825Stheravenclass mem_fun_t : public unary_function<T*, S>
286227825Stheraven{
287227825Stheravenpublic:
288227825Stheraven    explicit mem_fun_t(S (T::*p)());
289227825Stheraven    S operator()(T* p) const;
290227825Stheraven};
291227825Stheraven
292227825Stheraventemplate<class S, class T, class A>
293227825Stheravenclass mem_fun1_t : public binary_function<T*, A, S>
294227825Stheraven{
295227825Stheravenpublic:
296227825Stheraven    explicit mem_fun1_t(S (T::*p)(A));
297227825Stheraven    S operator()(T* p, A x) const;
298227825Stheraven};
299227825Stheraven
300227825Stheraventemplate<class S, class T>          mem_fun_t<S,T>    mem_fun(S (T::*f)());
301227825Stheraventemplate<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
302227825Stheraven
303227825Stheraventemplate<class S, class T>
304227825Stheravenclass mem_fun_ref_t : public unary_function<T, S>
305227825Stheraven{
306227825Stheravenpublic:
307227825Stheraven    explicit mem_fun_ref_t(S (T::*p)());
308227825Stheraven    S operator()(T& p) const;
309227825Stheraven};
310227825Stheraven
311227825Stheraventemplate<class S, class T, class A>
312227825Stheravenclass mem_fun1_ref_t : public binary_function<T, A, S>
313227825Stheraven{
314227825Stheravenpublic:
315227825Stheraven    explicit mem_fun1_ref_t(S (T::*p)(A));
316227825Stheraven    S operator()(T& p, A x) const;
317227825Stheraven};
318227825Stheraven
319227825Stheraventemplate<class S, class T>          mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)());
320227825Stheraventemplate<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));
321227825Stheraven
322227825Stheraventemplate <class S, class T>
323227825Stheravenclass const_mem_fun_t : public unary_function<const T*, S>
324227825Stheraven{
325227825Stheravenpublic:
326227825Stheraven    explicit const_mem_fun_t(S (T::*p)() const);
327227825Stheraven    S operator()(const T* p) const;
328227825Stheraven};
329227825Stheraven
330227825Stheraventemplate <class S, class T, class A>
331227825Stheravenclass const_mem_fun1_t : public binary_function<const T*, A, S>
332227825Stheraven{
333227825Stheravenpublic:
334227825Stheraven    explicit const_mem_fun1_t(S (T::*p)(A) const);
335227825Stheraven    S operator()(const T* p, A x) const;
336227825Stheraven};
337227825Stheraven
338227825Stheraventemplate <class S, class T>          const_mem_fun_t<S,T>    mem_fun(S (T::*f)() const);
339227825Stheraventemplate <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);
340227825Stheraven
341227825Stheraventemplate <class S, class T>
342227825Stheravenclass const_mem_fun_ref_t : public unary_function<T, S>
343227825Stheraven{
344227825Stheravenpublic:
345227825Stheraven    explicit const_mem_fun_ref_t(S (T::*p)() const);
346227825Stheraven    S operator()(const T& p) const;
347227825Stheraven};
348227825Stheraven
349227825Stheraventemplate <class S, class T, class A>
350227825Stheravenclass const_mem_fun1_ref_t : public binary_function<T, A, S>
351227825Stheraven{
352227825Stheravenpublic:
353227825Stheraven    explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
354227825Stheraven    S operator()(const T& p, A x) const;
355227825Stheraven};
356227825Stheraven
357227825Stheraventemplate <class S, class T>          const_mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)() const);
358227825Stheraventemplate <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
359227825Stheraven
360227825Stheraventemplate<class R, class T> unspecified mem_fn(R T::*);
361227825Stheraven
362227825Stheravenclass bad_function_call
363227825Stheraven    : public exception
364227825Stheraven{
365227825Stheraven};
366227825Stheraven
367227825Stheraventemplate<class> class function; // undefined
368227825Stheraven
369227825Stheraventemplate<class R, class... ArgTypes>
370227825Stheravenclass function<R(ArgTypes...)>
371227825Stheraven  : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and
372227825Stheraven                                      // ArgTypes contains T1
373227825Stheraven  : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
374227825Stheraven                                      // ArgTypes contains T1 and T2
375227825Stheraven{
376227825Stheravenpublic:
377227825Stheraven    typedef R result_type;
378227825Stheraven
379227825Stheraven    // construct/copy/destroy:
380227825Stheraven    function() noexcept;
381227825Stheraven    function(nullptr_t) noexcept;
382227825Stheraven    function(const function&);
383227825Stheraven    function(function&&) noexcept;
384227825Stheraven    template<class F>
385227825Stheraven      function(F);
386227825Stheraven    template<Allocator Alloc>
387227825Stheraven      function(allocator_arg_t, const Alloc&) noexcept;
388227825Stheraven    template<Allocator Alloc>
389227825Stheraven      function(allocator_arg_t, const Alloc&, nullptr_t) noexcept;
390227825Stheraven    template<Allocator Alloc>
391227825Stheraven      function(allocator_arg_t, const Alloc&, const function&);
392227825Stheraven    template<Allocator Alloc>
393227825Stheraven      function(allocator_arg_t, const Alloc&, function&&);
394227825Stheraven    template<class F, Allocator Alloc>
395227825Stheraven      function(allocator_arg_t, const Alloc&, F);
396227825Stheraven
397227825Stheraven    function& operator=(const function&);
398227825Stheraven    function& operator=(function&&) noexcept;
399227825Stheraven    function& operator=(nullptr_t) noexcept;
400227825Stheraven    template<class F>
401227825Stheraven      function& operator=(F&&);
402227825Stheraven    template<class F>
403227825Stheraven      function& operator=(reference_wrapper<F>) noexcept;
404227825Stheraven
405227825Stheraven    ~function();
406227825Stheraven
407227825Stheraven    // function modifiers:
408227825Stheraven    void swap(function&) noexcept;
409227825Stheraven    template<class F, class Alloc>
410227825Stheraven      void assign(F&&, const Alloc&);
411227825Stheraven
412227825Stheraven    // function capacity:
413227825Stheraven    explicit operator bool() const noexcept;
414227825Stheraven
415227825Stheraven    // function invocation:
416227825Stheraven    R operator()(ArgTypes...) const;
417227825Stheraven
418227825Stheraven    // function target access:
419227825Stheraven    const std::type_info& target_type() const noexcept;
420227825Stheraven    template <typename T>       T* target() noexcept;
421227825Stheraven    template <typename T> const T* target() const noexcept;
422227825Stheraven};
423227825Stheraven
424227825Stheraven// Null pointer comparisons:
425227825Stheraventemplate <class R, class ... ArgTypes>
426227825Stheraven  bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
427227825Stheraven
428227825Stheraventemplate <class R, class ... ArgTypes>
429227825Stheraven  bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
430227825Stheraven
431227825Stheraventemplate <class R, class ... ArgTypes>
432227825Stheraven  bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
433227825Stheraven
434227825Stheraventemplate <class  R, class ... ArgTypes>
435227825Stheraven  bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
436227825Stheraven
437227825Stheraven// specialized algorithms:
438227825Stheraventemplate <class  R, class ... ArgTypes>
439227825Stheraven  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
440227825Stheraven
441227825Stheraventemplate <class T> struct hash;
442227825Stheraven
443227825Stheraventemplate <> struct hash<bool>;
444227825Stheraventemplate <> struct hash<char>;
445227825Stheraventemplate <> struct hash<signed char>;
446227825Stheraventemplate <> struct hash<unsigned char>;
447227825Stheraventemplate <> struct hash<char16_t>;
448227825Stheraventemplate <> struct hash<char32_t>;
449227825Stheraventemplate <> struct hash<wchar_t>;
450227825Stheraventemplate <> struct hash<short>;
451227825Stheraventemplate <> struct hash<unsigned short>;
452227825Stheraventemplate <> struct hash<int>;
453227825Stheraventemplate <> struct hash<unsigned int>;
454227825Stheraventemplate <> struct hash<long>;
455227825Stheraventemplate <> struct hash<long long>;
456227825Stheraventemplate <> struct hash<unsigned long>;
457227825Stheraventemplate <> struct hash<unsigned long long>;
458227825Stheraven
459227825Stheraventemplate <> struct hash<float>;
460227825Stheraventemplate <> struct hash<double>;
461227825Stheraventemplate <> struct hash<long double>;
462227825Stheraven
463227825Stheraventemplate<class T> struct hash<T*>;
464227825Stheraven
465227825Stheraven}  // std
466227825Stheraven
467227825StheravenPOLICY:  For non-variadic implementations, the number of arguments is limited
468227825Stheraven         to 3.  It is hoped that the need for non-variadic implementations
469227825Stheraven         will be minimal.
470227825Stheraven
471227825Stheraven*/
472227825Stheraven
473227825Stheraven#include <__config>
474227825Stheraven#include <type_traits>
475227825Stheraven#include <typeinfo>
476227825Stheraven#include <exception>
477227825Stheraven#include <memory>
478227825Stheraven#include <tuple>
479227825Stheraven
480227825Stheraven#include <__functional_base>
481227825Stheraven
482227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
483227825Stheraven#pragma GCC system_header
484227825Stheraven#endif
485227825Stheraven
486227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
487227825Stheraven
488261272Sdim#if _LIBCPP_STD_VER > 11
489261272Sdimtemplate <class _Tp = void>
490261272Sdim#else
491227825Stheraventemplate <class _Tp>
492261272Sdim#endif
493261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp>
494227825Stheraven{
495261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
496261272Sdim    _Tp operator()(const _Tp& __x, const _Tp& __y) const
497227825Stheraven        {return __x + __y;}
498227825Stheraven};
499227825Stheraven
500261272Sdim#if _LIBCPP_STD_VER > 11
501261272Sdimtemplate <>
502261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY plus<void>
503261272Sdim{
504261272Sdim    template <class _T1, class _T2>
505261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
506261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
507288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
508288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
509288943Sdim        { return        _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
510261272Sdim    typedef void is_transparent;
511261272Sdim};
512261272Sdim#endif
513261272Sdim
514261272Sdim
515261272Sdim#if _LIBCPP_STD_VER > 11
516261272Sdimtemplate <class _Tp = void>
517261272Sdim#else
518227825Stheraventemplate <class _Tp>
519261272Sdim#endif
520261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp>
521227825Stheraven{
522261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
523261272Sdim    _Tp operator()(const _Tp& __x, const _Tp& __y) const
524227825Stheraven        {return __x - __y;}
525227825Stheraven};
526227825Stheraven
527261272Sdim#if _LIBCPP_STD_VER > 11
528261272Sdimtemplate <>
529261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY minus<void>
530261272Sdim{
531261272Sdim    template <class _T1, class _T2>
532261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
533261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
534288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
535288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
536288943Sdim        { return        _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
537261272Sdim    typedef void is_transparent;
538261272Sdim};
539261272Sdim#endif
540261272Sdim
541261272Sdim
542261272Sdim#if _LIBCPP_STD_VER > 11
543261272Sdimtemplate <class _Tp = void>
544261272Sdim#else
545227825Stheraventemplate <class _Tp>
546261272Sdim#endif
547261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp>
548227825Stheraven{
549261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
550261272Sdim    _Tp operator()(const _Tp& __x, const _Tp& __y) const
551227825Stheraven        {return __x * __y;}
552227825Stheraven};
553227825Stheraven
554261272Sdim#if _LIBCPP_STD_VER > 11
555261272Sdimtemplate <>
556261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
557261272Sdim{
558261272Sdim    template <class _T1, class _T2>
559261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
560261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
561288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
562288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
563288943Sdim        { return        _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
564261272Sdim    typedef void is_transparent;
565261272Sdim};
566261272Sdim#endif
567261272Sdim
568261272Sdim
569261272Sdim#if _LIBCPP_STD_VER > 11
570261272Sdimtemplate <class _Tp = void>
571261272Sdim#else
572227825Stheraventemplate <class _Tp>
573261272Sdim#endif
574261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp>
575227825Stheraven{
576261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
577261272Sdim    _Tp operator()(const _Tp& __x, const _Tp& __y) const
578227825Stheraven        {return __x / __y;}
579227825Stheraven};
580227825Stheraven
581261272Sdim#if _LIBCPP_STD_VER > 11
582261272Sdimtemplate <>
583261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY divides<void>
584261272Sdim{
585261272Sdim    template <class _T1, class _T2>
586261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
587261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
588288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
589288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
590288943Sdim        { return        _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
591261272Sdim    typedef void is_transparent;
592261272Sdim};
593261272Sdim#endif
594261272Sdim
595261272Sdim
596261272Sdim#if _LIBCPP_STD_VER > 11
597261272Sdimtemplate <class _Tp = void>
598261272Sdim#else
599227825Stheraventemplate <class _Tp>
600261272Sdim#endif
601261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp>
602227825Stheraven{
603261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
604261272Sdim    _Tp operator()(const _Tp& __x, const _Tp& __y) const
605227825Stheraven        {return __x % __y;}
606227825Stheraven};
607227825Stheraven
608261272Sdim#if _LIBCPP_STD_VER > 11
609261272Sdimtemplate <>
610261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY modulus<void>
611261272Sdim{
612261272Sdim    template <class _T1, class _T2>
613261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
614261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
615288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
616288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
617288943Sdim        { return        _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
618261272Sdim    typedef void is_transparent;
619261272Sdim};
620261272Sdim#endif
621261272Sdim
622261272Sdim
623261272Sdim#if _LIBCPP_STD_VER > 11
624261272Sdimtemplate <class _Tp = void>
625261272Sdim#else
626227825Stheraventemplate <class _Tp>
627261272Sdim#endif
628261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp>
629227825Stheraven{
630261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
631261272Sdim    _Tp operator()(const _Tp& __x) const
632227825Stheraven        {return -__x;}
633227825Stheraven};
634227825Stheraven
635261272Sdim#if _LIBCPP_STD_VER > 11
636261272Sdimtemplate <>
637261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY negate<void>
638261272Sdim{
639261272Sdim    template <class _Tp>
640261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
641261272Sdim    auto operator()(_Tp&& __x) const
642288943Sdim    _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
643288943Sdim    -> decltype        (- _VSTD::forward<_Tp>(__x))
644288943Sdim        { return        - _VSTD::forward<_Tp>(__x); }
645261272Sdim    typedef void is_transparent;
646261272Sdim};
647261272Sdim#endif
648261272Sdim
649261272Sdim
650261272Sdim#if _LIBCPP_STD_VER > 11
651261272Sdimtemplate <class _Tp = void>
652261272Sdim#else
653227825Stheraventemplate <class _Tp>
654261272Sdim#endif
655261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool>
656227825Stheraven{
657261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
658261272Sdim    bool operator()(const _Tp& __x, const _Tp& __y) const
659227825Stheraven        {return __x == __y;}
660227825Stheraven};
661227825Stheraven
662261272Sdim#if _LIBCPP_STD_VER > 11
663261272Sdimtemplate <>
664261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
665261272Sdim{
666261272Sdim    template <class _T1, class _T2>
667261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
668261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
669288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
670288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
671288943Sdim        { return        _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
672261272Sdim    typedef void is_transparent;
673261272Sdim};
674261272Sdim#endif
675261272Sdim
676261272Sdim
677261272Sdim#if _LIBCPP_STD_VER > 11
678261272Sdimtemplate <class _Tp = void>
679261272Sdim#else
680227825Stheraventemplate <class _Tp>
681261272Sdim#endif
682261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool>
683227825Stheraven{
684261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
685261272Sdim    bool operator()(const _Tp& __x, const _Tp& __y) const
686227825Stheraven        {return __x != __y;}
687227825Stheraven};
688227825Stheraven
689261272Sdim#if _LIBCPP_STD_VER > 11
690261272Sdimtemplate <>
691261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
692261272Sdim{
693261272Sdim    template <class _T1, class _T2>
694261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
695261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
696288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
697288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
698288943Sdim        { return        _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
699261272Sdim    typedef void is_transparent;
700261272Sdim};
701261272Sdim#endif
702261272Sdim
703261272Sdim
704261272Sdim#if _LIBCPP_STD_VER > 11
705261272Sdimtemplate <class _Tp = void>
706261272Sdim#else
707227825Stheraventemplate <class _Tp>
708261272Sdim#endif
709261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool>
710227825Stheraven{
711261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
712261272Sdim    bool operator()(const _Tp& __x, const _Tp& __y) const
713227825Stheraven        {return __x > __y;}
714227825Stheraven};
715227825Stheraven
716261272Sdim#if _LIBCPP_STD_VER > 11
717261272Sdimtemplate <>
718261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater<void>
719261272Sdim{
720261272Sdim    template <class _T1, class _T2>
721261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
722261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
723288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
724288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
725288943Sdim        { return        _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
726261272Sdim    typedef void is_transparent;
727261272Sdim};
728261272Sdim#endif
729261272Sdim
730261272Sdim
731232924Stheraven// less in <__functional_base>
732227825Stheraven
733261272Sdim#if _LIBCPP_STD_VER > 11
734261272Sdimtemplate <class _Tp = void>
735261272Sdim#else
736227825Stheraventemplate <class _Tp>
737261272Sdim#endif
738261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool>
739227825Stheraven{
740261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
741261272Sdim    bool operator()(const _Tp& __x, const _Tp& __y) const
742227825Stheraven        {return __x >= __y;}
743227825Stheraven};
744227825Stheraven
745261272Sdim#if _LIBCPP_STD_VER > 11
746261272Sdimtemplate <>
747261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
748261272Sdim{
749261272Sdim    template <class _T1, class _T2>
750261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
751261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
752288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
753288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
754288943Sdim        { return        _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
755261272Sdim    typedef void is_transparent;
756261272Sdim};
757261272Sdim#endif
758261272Sdim
759261272Sdim
760261272Sdim#if _LIBCPP_STD_VER > 11
761261272Sdimtemplate <class _Tp = void>
762261272Sdim#else
763227825Stheraventemplate <class _Tp>
764261272Sdim#endif
765261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool>
766227825Stheraven{
767261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
768261272Sdim    bool operator()(const _Tp& __x, const _Tp& __y) const
769227825Stheraven        {return __x <= __y;}
770227825Stheraven};
771227825Stheraven
772261272Sdim#if _LIBCPP_STD_VER > 11
773261272Sdimtemplate <>
774261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
775261272Sdim{
776261272Sdim    template <class _T1, class _T2>
777261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
778261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
779288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
780288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
781288943Sdim        { return        _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
782261272Sdim    typedef void is_transparent;
783261272Sdim};
784261272Sdim#endif
785261272Sdim
786261272Sdim
787261272Sdim#if _LIBCPP_STD_VER > 11
788261272Sdimtemplate <class _Tp = void>
789261272Sdim#else
790227825Stheraventemplate <class _Tp>
791261272Sdim#endif
792261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool>
793227825Stheraven{
794261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
795261272Sdim    bool operator()(const _Tp& __x, const _Tp& __y) const
796227825Stheraven        {return __x && __y;}
797227825Stheraven};
798227825Stheraven
799261272Sdim#if _LIBCPP_STD_VER > 11
800261272Sdimtemplate <>
801261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
802261272Sdim{
803261272Sdim    template <class _T1, class _T2>
804261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
805261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
806288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
807288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
808288943Sdim        { return        _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
809261272Sdim    typedef void is_transparent;
810261272Sdim};
811261272Sdim#endif
812261272Sdim
813261272Sdim
814261272Sdim#if _LIBCPP_STD_VER > 11
815261272Sdimtemplate <class _Tp = void>
816261272Sdim#else
817227825Stheraventemplate <class _Tp>
818261272Sdim#endif
819261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool>
820227825Stheraven{
821261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
822261272Sdim    bool operator()(const _Tp& __x, const _Tp& __y) const
823227825Stheraven        {return __x || __y;}
824227825Stheraven};
825227825Stheraven
826261272Sdim#if _LIBCPP_STD_VER > 11
827261272Sdimtemplate <>
828261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
829261272Sdim{
830261272Sdim    template <class _T1, class _T2>
831261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
832261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
833288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
834288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
835288943Sdim        { return        _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
836261272Sdim    typedef void is_transparent;
837261272Sdim};
838261272Sdim#endif
839261272Sdim
840261272Sdim
841261272Sdim#if _LIBCPP_STD_VER > 11
842261272Sdimtemplate <class _Tp = void>
843261272Sdim#else
844227825Stheraventemplate <class _Tp>
845261272Sdim#endif
846261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool>
847227825Stheraven{
848261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
849261272Sdim    bool operator()(const _Tp& __x) const
850227825Stheraven        {return !__x;}
851227825Stheraven};
852227825Stheraven
853261272Sdim#if _LIBCPP_STD_VER > 11
854261272Sdimtemplate <>
855261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
856261272Sdim{
857261272Sdim    template <class _Tp>
858261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
859261272Sdim    auto operator()(_Tp&& __x) const
860288943Sdim    _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
861288943Sdim    -> decltype        (!_VSTD::forward<_Tp>(__x))
862288943Sdim        { return        !_VSTD::forward<_Tp>(__x); }
863261272Sdim    typedef void is_transparent;
864261272Sdim};
865261272Sdim#endif
866261272Sdim
867261272Sdim
868261272Sdim#if _LIBCPP_STD_VER > 11
869261272Sdimtemplate <class _Tp = void>
870261272Sdim#else
871227825Stheraventemplate <class _Tp>
872261272Sdim#endif
873261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp>
874227825Stheraven{
875261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
876261272Sdim    _Tp operator()(const _Tp& __x, const _Tp& __y) const
877227825Stheraven        {return __x & __y;}
878227825Stheraven};
879227825Stheraven
880261272Sdim#if _LIBCPP_STD_VER > 11
881261272Sdimtemplate <>
882261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
883261272Sdim{
884261272Sdim    template <class _T1, class _T2>
885261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
886261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
887288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
888288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
889288943Sdim        { return        _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
890261272Sdim    typedef void is_transparent;
891261272Sdim};
892261272Sdim#endif
893261272Sdim
894261272Sdim
895261272Sdim#if _LIBCPP_STD_VER > 11
896261272Sdimtemplate <class _Tp = void>
897261272Sdim#else
898227825Stheraventemplate <class _Tp>
899261272Sdim#endif
900261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp>
901227825Stheraven{
902261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
903261272Sdim    _Tp operator()(const _Tp& __x, const _Tp& __y) const
904227825Stheraven        {return __x | __y;}
905227825Stheraven};
906227825Stheraven
907261272Sdim#if _LIBCPP_STD_VER > 11
908261272Sdimtemplate <>
909261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
910261272Sdim{
911261272Sdim    template <class _T1, class _T2>
912261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
913261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
914288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
915288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
916288943Sdim        { return        _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
917261272Sdim    typedef void is_transparent;
918261272Sdim};
919261272Sdim#endif
920261272Sdim
921261272Sdim
922261272Sdim#if _LIBCPP_STD_VER > 11
923261272Sdimtemplate <class _Tp = void>
924261272Sdim#else
925227825Stheraventemplate <class _Tp>
926261272Sdim#endif
927261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp>
928227825Stheraven{
929261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
930261272Sdim    _Tp operator()(const _Tp& __x, const _Tp& __y) const
931227825Stheraven        {return __x ^ __y;}
932227825Stheraven};
933227825Stheraven
934261272Sdim#if _LIBCPP_STD_VER > 11
935261272Sdimtemplate <>
936261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
937261272Sdim{
938261272Sdim    template <class _T1, class _T2>
939261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
940261272Sdim    auto operator()(_T1&& __t, _T2&& __u) const
941288943Sdim    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
942288943Sdim    -> decltype        (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
943288943Sdim        { return        _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
944261272Sdim    typedef void is_transparent;
945261272Sdim};
946261272Sdim#endif
947261272Sdim
948261272Sdim
949261272Sdim#if _LIBCPP_STD_VER > 11
950261272Sdimtemplate <class _Tp = void>
951261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp>
952261272Sdim{
953261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
954261272Sdim    _Tp operator()(const _Tp& __x) const
955261272Sdim        {return ~__x;}
956261272Sdim};
957261272Sdim
958261272Sdimtemplate <>
959261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
960261272Sdim{
961261272Sdim    template <class _Tp>
962261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
963261272Sdim    auto operator()(_Tp&& __x) const
964288943Sdim    _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
965288943Sdim    -> decltype        (~_VSTD::forward<_Tp>(__x))
966288943Sdim        { return        ~_VSTD::forward<_Tp>(__x); }
967261272Sdim    typedef void is_transparent;
968261272Sdim};
969261272Sdim#endif
970261272Sdim
971227825Stheraventemplate <class _Predicate>
972261272Sdimclass _LIBCPP_TYPE_VIS_ONLY unary_negate
973227825Stheraven    : public unary_function<typename _Predicate::argument_type, bool>
974227825Stheraven{
975227825Stheraven    _Predicate __pred_;
976227825Stheravenpublic:
977261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
978261272Sdim    explicit unary_negate(const _Predicate& __pred)
979227825Stheraven        : __pred_(__pred) {}
980261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
981261272Sdim    bool operator()(const typename _Predicate::argument_type& __x) const
982227825Stheraven        {return !__pred_(__x);}
983227825Stheraven};
984227825Stheraven
985227825Stheraventemplate <class _Predicate>
986261272Sdiminline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
987227825Stheravenunary_negate<_Predicate>
988227825Stheravennot1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
989227825Stheraven
990227825Stheraventemplate <class _Predicate>
991261272Sdimclass _LIBCPP_TYPE_VIS_ONLY binary_negate
992227825Stheraven    : public binary_function<typename _Predicate::first_argument_type,
993227825Stheraven                             typename _Predicate::second_argument_type,
994227825Stheraven                             bool>
995227825Stheraven{
996227825Stheraven    _Predicate __pred_;
997227825Stheravenpublic:
998261272Sdim    _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 
999261272Sdim    binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
1000261272Sdim
1001261272Sdim    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1002261272Sdim    bool operator()(const typename _Predicate::first_argument_type& __x,
1003227825Stheraven                    const typename _Predicate::second_argument_type& __y) const
1004227825Stheraven        {return !__pred_(__x, __y);}
1005227825Stheraven};
1006227825Stheraven
1007227825Stheraventemplate <class _Predicate>
1008261272Sdiminline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1009227825Stheravenbinary_negate<_Predicate>
1010227825Stheravennot2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
1011227825Stheraven
1012227825Stheraventemplate <class __Operation>
1013261272Sdimclass _LIBCPP_TYPE_VIS_ONLY binder1st
1014227825Stheraven    : public unary_function<typename __Operation::second_argument_type,
1015227825Stheraven                            typename __Operation::result_type>
1016227825Stheraven{
1017227825Stheravenprotected:
1018227825Stheraven    __Operation                               op;
1019227825Stheraven    typename __Operation::first_argument_type value;
1020227825Stheravenpublic:
1021227825Stheraven    _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
1022227825Stheraven                               const typename __Operation::first_argument_type __y)
1023227825Stheraven        : op(__x), value(__y) {}
1024227825Stheraven    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1025227825Stheraven        (typename __Operation::second_argument_type& __x) const
1026227825Stheraven            {return op(value, __x);}
1027227825Stheraven    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1028227825Stheraven        (const typename __Operation::second_argument_type& __x) const
1029227825Stheraven            {return op(value, __x);}
1030227825Stheraven};
1031227825Stheraven
1032227825Stheraventemplate <class __Operation, class _Tp>
1033227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1034227825Stheravenbinder1st<__Operation>
1035227825Stheravenbind1st(const __Operation& __op, const _Tp& __x)
1036227825Stheraven    {return binder1st<__Operation>(__op, __x);}
1037227825Stheraven
1038227825Stheraventemplate <class __Operation>
1039261272Sdimclass _LIBCPP_TYPE_VIS_ONLY binder2nd
1040227825Stheraven    : public unary_function<typename __Operation::first_argument_type,
1041227825Stheraven                            typename __Operation::result_type>
1042227825Stheraven{
1043227825Stheravenprotected:
1044227825Stheraven    __Operation                                op;
1045227825Stheraven    typename __Operation::second_argument_type value;
1046227825Stheravenpublic:
1047227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1048227825Stheraven    binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
1049227825Stheraven        : op(__x), value(__y) {}
1050227825Stheraven    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1051227825Stheraven        (      typename __Operation::first_argument_type& __x) const
1052227825Stheraven            {return op(__x, value);}
1053227825Stheraven    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1054227825Stheraven        (const typename __Operation::first_argument_type& __x) const
1055227825Stheraven            {return op(__x, value);}
1056227825Stheraven};
1057227825Stheraven
1058227825Stheraventemplate <class __Operation, class _Tp>
1059227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1060227825Stheravenbinder2nd<__Operation>
1061227825Stheravenbind2nd(const __Operation& __op, const _Tp& __x)
1062227825Stheraven    {return binder2nd<__Operation>(__op, __x);}
1063227825Stheraven
1064227825Stheraventemplate <class _Arg, class _Result>
1065261272Sdimclass _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function
1066227825Stheraven    : public unary_function<_Arg, _Result>
1067227825Stheraven{
1068227825Stheraven    _Result (*__f_)(_Arg);
1069227825Stheravenpublic:
1070227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
1071227825Stheraven        : __f_(__f) {}
1072227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
1073227825Stheraven        {return __f_(__x);}
1074227825Stheraven};
1075227825Stheraven
1076227825Stheraventemplate <class _Arg, class _Result>
1077227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1078227825Stheravenpointer_to_unary_function<_Arg,_Result>
1079227825Stheravenptr_fun(_Result (*__f)(_Arg))
1080227825Stheraven    {return pointer_to_unary_function<_Arg,_Result>(__f);}
1081227825Stheraven
1082227825Stheraventemplate <class _Arg1, class _Arg2, class _Result>
1083261272Sdimclass _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function
1084227825Stheraven    : public binary_function<_Arg1, _Arg2, _Result>
1085227825Stheraven{
1086227825Stheraven    _Result (*__f_)(_Arg1, _Arg2);
1087227825Stheravenpublic:
1088227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
1089227825Stheraven        : __f_(__f) {}
1090227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
1091227825Stheraven        {return __f_(__x, __y);}
1092227825Stheraven};
1093227825Stheraven
1094227825Stheraventemplate <class _Arg1, class _Arg2, class _Result>
1095227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1096227825Stheravenpointer_to_binary_function<_Arg1,_Arg2,_Result>
1097227825Stheravenptr_fun(_Result (*__f)(_Arg1,_Arg2))
1098227825Stheraven    {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
1099227825Stheraven
1100227825Stheraventemplate<class _Sp, class _Tp>
1101261272Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp>
1102227825Stheraven{
1103227825Stheraven    _Sp (_Tp::*__p_)();
1104227825Stheravenpublic:
1105227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
1106227825Stheraven        : __p_(__p) {}
1107227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
1108227825Stheraven        {return (__p->*__p_)();}
1109227825Stheraven};
1110227825Stheraven
1111227825Stheraventemplate<class _Sp, class _Tp, class _Ap>
1112261272Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
1113227825Stheraven{
1114227825Stheraven    _Sp (_Tp::*__p_)(_Ap);
1115227825Stheravenpublic:
1116227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
1117227825Stheraven        : __p_(__p) {}
1118227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
1119227825Stheraven        {return (__p->*__p_)(__x);}
1120227825Stheraven};
1121227825Stheraven
1122227825Stheraventemplate<class _Sp, class _Tp>
1123227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1124227825Stheravenmem_fun_t<_Sp,_Tp>
1125227825Stheravenmem_fun(_Sp (_Tp::*__f)())
1126227825Stheraven    {return mem_fun_t<_Sp,_Tp>(__f);}
1127227825Stheraven
1128227825Stheraventemplate<class _Sp, class _Tp, class _Ap>
1129227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1130227825Stheravenmem_fun1_t<_Sp,_Tp,_Ap>
1131227825Stheravenmem_fun(_Sp (_Tp::*__f)(_Ap))
1132227825Stheraven    {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1133227825Stheraven
1134227825Stheraventemplate<class _Sp, class _Tp>
1135261272Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp>
1136227825Stheraven{
1137227825Stheraven    _Sp (_Tp::*__p_)();
1138227825Stheravenpublic:
1139227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
1140227825Stheraven        : __p_(__p) {}
1141227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
1142227825Stheraven        {return (__p.*__p_)();}
1143227825Stheraven};
1144227825Stheraven
1145227825Stheraventemplate<class _Sp, class _Tp, class _Ap>
1146261272Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
1147227825Stheraven{
1148227825Stheraven    _Sp (_Tp::*__p_)(_Ap);
1149227825Stheravenpublic:
1150227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
1151227825Stheraven        : __p_(__p) {}
1152227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
1153227825Stheraven        {return (__p.*__p_)(__x);}
1154227825Stheraven};
1155227825Stheraven
1156227825Stheraventemplate<class _Sp, class _Tp>
1157227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1158227825Stheravenmem_fun_ref_t<_Sp,_Tp>
1159227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)())
1160227825Stheraven    {return mem_fun_ref_t<_Sp,_Tp>(__f);}
1161227825Stheraven
1162227825Stheraventemplate<class _Sp, class _Tp, class _Ap>
1163227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1164227825Stheravenmem_fun1_ref_t<_Sp,_Tp,_Ap>
1165227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)(_Ap))
1166227825Stheraven    {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1167227825Stheraven
1168227825Stheraventemplate <class _Sp, class _Tp>
1169261272Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp>
1170227825Stheraven{
1171227825Stheraven    _Sp (_Tp::*__p_)() const;
1172227825Stheravenpublic:
1173227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
1174227825Stheraven        : __p_(__p) {}
1175227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
1176227825Stheraven        {return (__p->*__p_)();}
1177227825Stheraven};
1178227825Stheraven
1179227825Stheraventemplate <class _Sp, class _Tp, class _Ap>
1180261272Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
1181227825Stheraven{
1182227825Stheraven    _Sp (_Tp::*__p_)(_Ap) const;
1183227825Stheravenpublic:
1184227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
1185227825Stheraven        : __p_(__p) {}
1186227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
1187227825Stheraven        {return (__p->*__p_)(__x);}
1188227825Stheraven};
1189227825Stheraven
1190227825Stheraventemplate <class _Sp, class _Tp>
1191227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1192227825Stheravenconst_mem_fun_t<_Sp,_Tp>
1193227825Stheravenmem_fun(_Sp (_Tp::*__f)() const)
1194227825Stheraven    {return const_mem_fun_t<_Sp,_Tp>(__f);}
1195227825Stheraven
1196227825Stheraventemplate <class _Sp, class _Tp, class _Ap>
1197227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1198227825Stheravenconst_mem_fun1_t<_Sp,_Tp,_Ap>
1199227825Stheravenmem_fun(_Sp (_Tp::*__f)(_Ap) const)
1200227825Stheraven    {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1201227825Stheraven
1202227825Stheraventemplate <class _Sp, class _Tp>
1203261272Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
1204227825Stheraven{
1205227825Stheraven    _Sp (_Tp::*__p_)() const;
1206227825Stheravenpublic:
1207227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
1208227825Stheraven        : __p_(__p) {}
1209227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
1210227825Stheraven        {return (__p.*__p_)();}
1211227825Stheraven};
1212227825Stheraven
1213227825Stheraventemplate <class _Sp, class _Tp, class _Ap>
1214261272Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t
1215227825Stheraven    : public binary_function<_Tp, _Ap, _Sp>
1216227825Stheraven{
1217227825Stheraven    _Sp (_Tp::*__p_)(_Ap) const;
1218227825Stheravenpublic:
1219227825Stheraven    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
1220227825Stheraven        : __p_(__p) {}
1221227825Stheraven    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
1222227825Stheraven        {return (__p.*__p_)(__x);}
1223227825Stheraven};
1224227825Stheraven
1225227825Stheraventemplate <class _Sp, class _Tp>
1226227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1227227825Stheravenconst_mem_fun_ref_t<_Sp,_Tp>
1228227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)() const)
1229227825Stheraven    {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
1230227825Stheraven
1231227825Stheraventemplate <class _Sp, class _Tp, class _Ap>
1232227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1233227825Stheravenconst_mem_fun1_ref_t<_Sp,_Tp,_Ap>
1234227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
1235227825Stheraven    {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1236227825Stheraven
1237300770Sdim////////////////////////////////////////////////////////////////////////////////
1238300770Sdim//                                MEMFUN
1239300770Sdim//==============================================================================
1240227825Stheraven
1241227825Stheraventemplate <class _Tp>
1242227825Stheravenclass __mem_fn
1243227825Stheraven    : public __weak_result_type<_Tp>
1244227825Stheraven{
1245227825Stheravenpublic:
1246227825Stheraven    // types
1247227825Stheraven    typedef _Tp type;
1248227825Stheravenprivate:
1249227825Stheraven    type __f_;
1250227825Stheraven
1251227825Stheravenpublic:
1252300770Sdim    _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
1253227825Stheraven
1254300770Sdim#ifndef _LIBCPP_HAS_NO_VARIADICS
1255227825Stheraven    // invoke
1256227825Stheraven    template <class... _ArgTypes>
1257300770Sdim    _LIBCPP_INLINE_VISIBILITY
1258300770Sdim    typename __invoke_return<type, _ArgTypes...>::type
1259300770Sdim    operator() (_ArgTypes&&... __args) const {
1260300770Sdim        return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
1261300770Sdim    }
1262300770Sdim#else
1263300770Sdim
1264300770Sdim    template <class _A0>
1265300770Sdim    _LIBCPP_INLINE_VISIBILITY
1266300770Sdim    typename __invoke_return0<type, _A0>::type
1267300770Sdim    operator() (_A0& __a0) const {
1268300770Sdim        return __invoke(__f_, __a0);
1269300770Sdim    }
1270300770Sdim
1271300770Sdim    template <class _A0>
1272300770Sdim    _LIBCPP_INLINE_VISIBILITY
1273300770Sdim    typename __invoke_return0<type, _A0 const>::type
1274300770Sdim    operator() (_A0 const& __a0) const {
1275300770Sdim        return __invoke(__f_, __a0);
1276300770Sdim    }
1277300770Sdim
1278300770Sdim    template <class _A0, class _A1>
1279300770Sdim    _LIBCPP_INLINE_VISIBILITY
1280300770Sdim    typename __invoke_return1<type, _A0, _A1>::type
1281300770Sdim    operator() (_A0& __a0, _A1& __a1) const {
1282300770Sdim        return __invoke(__f_, __a0, __a1);
1283300770Sdim    }
1284300770Sdim
1285300770Sdim    template <class _A0, class _A1>
1286300770Sdim    _LIBCPP_INLINE_VISIBILITY
1287300770Sdim    typename __invoke_return1<type, _A0 const, _A1>::type
1288300770Sdim    operator() (_A0 const& __a0, _A1& __a1) const {
1289300770Sdim        return __invoke(__f_, __a0, __a1);
1290300770Sdim    }
1291300770Sdim
1292300770Sdim    template <class _A0, class _A1>
1293300770Sdim    _LIBCPP_INLINE_VISIBILITY
1294300770Sdim    typename __invoke_return1<type, _A0, _A1 const>::type
1295300770Sdim    operator() (_A0& __a0, _A1 const& __a1) const {
1296300770Sdim        return __invoke(__f_, __a0, __a1);
1297300770Sdim    }
1298300770Sdim
1299300770Sdim    template <class _A0, class _A1>
1300300770Sdim    _LIBCPP_INLINE_VISIBILITY
1301300770Sdim    typename __invoke_return1<type, _A0 const, _A1 const>::type
1302300770Sdim    operator() (_A0 const& __a0, _A1 const& __a1) const {
1303300770Sdim        return __invoke(__f_, __a0, __a1);
1304300770Sdim    }
1305300770Sdim
1306300770Sdim    template <class _A0, class _A1, class _A2>
1307300770Sdim    _LIBCPP_INLINE_VISIBILITY
1308300770Sdim    typename __invoke_return2<type, _A0, _A1, _A2>::type
1309300770Sdim    operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
1310300770Sdim        return __invoke(__f_, __a0, __a1, __a2);
1311300770Sdim    }
1312300770Sdim
1313300770Sdim    template <class _A0, class _A1, class _A2>
1314300770Sdim    _LIBCPP_INLINE_VISIBILITY
1315300770Sdim    typename __invoke_return2<type, _A0 const, _A1, _A2>::type
1316300770Sdim    operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
1317300770Sdim        return __invoke(__f_, __a0, __a1, __a2);
1318300770Sdim    }
1319300770Sdim
1320300770Sdim    template <class _A0, class _A1, class _A2>
1321300770Sdim    _LIBCPP_INLINE_VISIBILITY
1322300770Sdim    typename __invoke_return2<type, _A0, _A1 const, _A2>::type
1323300770Sdim    operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
1324300770Sdim        return __invoke(__f_, __a0, __a1, __a2);
1325300770Sdim    }
1326300770Sdim
1327300770Sdim    template <class _A0, class _A1, class _A2>
1328300770Sdim    _LIBCPP_INLINE_VISIBILITY
1329300770Sdim    typename __invoke_return2<type, _A0, _A1, _A2 const>::type
1330300770Sdim    operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
1331300770Sdim        return __invoke(__f_, __a0, __a1, __a2);
1332300770Sdim    }
1333300770Sdim
1334300770Sdim    template <class _A0, class _A1, class _A2>
1335300770Sdim    _LIBCPP_INLINE_VISIBILITY
1336300770Sdim    typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
1337300770Sdim    operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
1338300770Sdim        return __invoke(__f_, __a0, __a1, __a2);
1339300770Sdim    }
1340300770Sdim
1341300770Sdim    template <class _A0, class _A1, class _A2>
1342300770Sdim    _LIBCPP_INLINE_VISIBILITY
1343300770Sdim    typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
1344300770Sdim    operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
1345300770Sdim        return __invoke(__f_, __a0, __a1, __a2);
1346300770Sdim    }
1347300770Sdim
1348300770Sdim    template <class _A0, class _A1, class _A2>
1349300770Sdim    _LIBCPP_INLINE_VISIBILITY
1350300770Sdim    typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
1351300770Sdim    operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
1352300770Sdim        return __invoke(__f_, __a0, __a1, __a2);
1353300770Sdim    }
1354300770Sdim
1355300770Sdim    template <class _A0, class _A1, class _A2>
1356300770Sdim    _LIBCPP_INLINE_VISIBILITY
1357300770Sdim    typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
1358300770Sdim    operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
1359300770Sdim        return __invoke(__f_, __a0, __a1, __a2);
1360300770Sdim    }
1361300770Sdim#endif
1362227825Stheraven};
1363227825Stheraven
1364232924Stheraventemplate<class _Rp, class _Tp>
1365227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1366232924Stheraven__mem_fn<_Rp _Tp::*>
1367300770Sdimmem_fn(_Rp _Tp::* __pm) _NOEXCEPT
1368227825Stheraven{
1369232924Stheraven    return __mem_fn<_Rp _Tp::*>(__pm);
1370227825Stheraven}
1371227825Stheraven
1372300770Sdim////////////////////////////////////////////////////////////////////////////////
1373300770Sdim//                                FUNCTION
1374300770Sdim//==============================================================================
1375300770Sdim
1376227825Stheraven// bad_function_call
1377227825Stheraven
1378227825Stheravenclass _LIBCPP_EXCEPTION_ABI bad_function_call
1379227825Stheraven    : public exception
1380227825Stheraven{
1381227825Stheraven};
1382227825Stheraven
1383261272Sdimtemplate<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
1384227825Stheraven
1385227825Stheravennamespace __function
1386227825Stheraven{
1387227825Stheraven
1388300770Sdimtemplate<class _Rp>
1389227825Stheravenstruct __maybe_derive_from_unary_function
1390227825Stheraven{
1391227825Stheraven};
1392227825Stheraven
1393232924Stheraventemplate<class _Rp, class _A1>
1394232924Stheravenstruct __maybe_derive_from_unary_function<_Rp(_A1)>
1395232924Stheraven    : public unary_function<_A1, _Rp>
1396227825Stheraven{
1397227825Stheraven};
1398227825Stheraven
1399300770Sdimtemplate<class _Rp>
1400227825Stheravenstruct __maybe_derive_from_binary_function
1401227825Stheraven{
1402227825Stheraven};
1403227825Stheraven
1404232924Stheraventemplate<class _Rp, class _A1, class _A2>
1405232924Stheravenstruct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
1406232924Stheraven    : public binary_function<_A1, _A2, _Rp>
1407227825Stheraven{
1408227825Stheraven};
1409227825Stheraven
1410300770Sdimtemplate <class _Fp>
1411300770Sdim_LIBCPP_INLINE_VISIBILITY
1412300770Sdimbool __not_null(_Fp const&) { return true; }
1413300770Sdim
1414300770Sdimtemplate <class _Fp>
1415300770Sdim_LIBCPP_INLINE_VISIBILITY
1416300770Sdimbool __not_null(_Fp* __ptr) { return __ptr; }
1417300770Sdim
1418300770Sdimtemplate <class _Ret, class _Class>
1419300770Sdim_LIBCPP_INLINE_VISIBILITY
1420300770Sdimbool __not_null(_Ret _Class::*__ptr) { return __ptr; }
1421300770Sdim
1422300770Sdimtemplate <class _Fp>
1423300770Sdim_LIBCPP_INLINE_VISIBILITY
1424300770Sdimbool __not_null(function<_Fp> const& __f) { return !!__f; }
1425300770Sdim
1426300770Sdim} // namespace __function
1427300770Sdim
1428300770Sdim#ifndef _LIBCPP_HAS_NO_VARIADICS
1429300770Sdim
1430300770Sdimnamespace __function {
1431300770Sdim
1432227825Stheraventemplate<class _Fp> class __base;
1433227825Stheraven
1434232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1435232924Stheravenclass __base<_Rp(_ArgTypes...)>
1436227825Stheraven{
1437227825Stheraven    __base(const __base&);
1438227825Stheraven    __base& operator=(const __base&);
1439227825Stheravenpublic:
1440227825Stheraven    _LIBCPP_INLINE_VISIBILITY __base() {}
1441227825Stheraven    _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
1442227825Stheraven    virtual __base* __clone() const = 0;
1443227825Stheraven    virtual void __clone(__base*) const = 0;
1444227825Stheraven    virtual void destroy() _NOEXCEPT = 0;
1445227825Stheraven    virtual void destroy_deallocate() _NOEXCEPT = 0;
1446232924Stheraven    virtual _Rp operator()(_ArgTypes&& ...) = 0;
1447227825Stheraven#ifndef _LIBCPP_NO_RTTI
1448227825Stheraven    virtual const void* target(const type_info&) const _NOEXCEPT = 0;
1449227825Stheraven    virtual const std::type_info& target_type() const _NOEXCEPT = 0;
1450227825Stheraven#endif  // _LIBCPP_NO_RTTI
1451227825Stheraven};
1452227825Stheraven
1453227825Stheraventemplate<class _FD, class _Alloc, class _FB> class __func;
1454227825Stheraven
1455232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1456232924Stheravenclass __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
1457232924Stheraven    : public  __base<_Rp(_ArgTypes...)>
1458227825Stheraven{
1459232924Stheraven    __compressed_pair<_Fp, _Alloc> __f_;
1460227825Stheravenpublic:
1461227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1462232924Stheraven    explicit __func(_Fp&& __f)
1463232924Stheraven        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1464232924Stheraven                                    _VSTD::forward_as_tuple()) {}
1465227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1466232924Stheraven    explicit __func(const _Fp& __f, const _Alloc& __a)
1467232924Stheraven        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1468232924Stheraven                                    _VSTD::forward_as_tuple(__a)) {}
1469232924Stheraven
1470232924Stheraven    _LIBCPP_INLINE_VISIBILITY
1471232924Stheraven    explicit __func(const _Fp& __f, _Alloc&& __a)
1472232924Stheraven        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1473232924Stheraven                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1474232924Stheraven
1475232924Stheraven    _LIBCPP_INLINE_VISIBILITY
1476232924Stheraven    explicit __func(_Fp&& __f, _Alloc&& __a)
1477232924Stheraven        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1478232924Stheraven                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1479232924Stheraven    virtual __base<_Rp(_ArgTypes...)>* __clone() const;
1480232924Stheraven    virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
1481227825Stheraven    virtual void destroy() _NOEXCEPT;
1482227825Stheraven    virtual void destroy_deallocate() _NOEXCEPT;
1483232924Stheraven    virtual _Rp operator()(_ArgTypes&& ... __arg);
1484227825Stheraven#ifndef _LIBCPP_NO_RTTI
1485227825Stheraven    virtual const void* target(const type_info&) const _NOEXCEPT;
1486227825Stheraven    virtual const std::type_info& target_type() const _NOEXCEPT;
1487227825Stheraven#endif  // _LIBCPP_NO_RTTI
1488227825Stheraven};
1489227825Stheraven
1490232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1491232924Stheraven__base<_Rp(_ArgTypes...)>*
1492232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
1493227825Stheraven{
1494288943Sdim    typedef allocator_traits<_Alloc> __alloc_traits;
1495288943Sdim    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1496232924Stheraven    _Ap __a(__f_.second());
1497232924Stheraven    typedef __allocator_destructor<_Ap> _Dp;
1498232924Stheraven    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1499227825Stheraven    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
1500227825Stheraven    return __hold.release();
1501227825Stheraven}
1502227825Stheraven
1503232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1504227825Stheravenvoid
1505232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
1506227825Stheraven{
1507227825Stheraven    ::new (__p) __func(__f_.first(), __f_.second());
1508227825Stheraven}
1509227825Stheraven
1510232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1511227825Stheravenvoid
1512232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
1513227825Stheraven{
1514232924Stheraven    __f_.~__compressed_pair<_Fp, _Alloc>();
1515227825Stheraven}
1516227825Stheraven
1517232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1518227825Stheravenvoid
1519232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
1520227825Stheraven{
1521288943Sdim    typedef allocator_traits<_Alloc> __alloc_traits;
1522288943Sdim    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1523232924Stheraven    _Ap __a(__f_.second());
1524232924Stheraven    __f_.~__compressed_pair<_Fp, _Alloc>();
1525227825Stheraven    __a.deallocate(this, 1);
1526227825Stheraven}
1527227825Stheraven
1528232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1529232924Stheraven_Rp
1530232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
1531227825Stheraven{
1532288943Sdim    typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1533288943Sdim    return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
1534227825Stheraven}
1535227825Stheraven
1536227825Stheraven#ifndef _LIBCPP_NO_RTTI
1537227825Stheraven
1538232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1539227825Stheravenconst void*
1540232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
1541227825Stheraven{
1542232924Stheraven    if (__ti == typeid(_Fp))
1543227825Stheraven        return &__f_.first();
1544227825Stheraven    return (const void*)0;
1545227825Stheraven}
1546227825Stheraven
1547232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1548227825Stheravenconst std::type_info&
1549232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1550227825Stheraven{
1551232924Stheraven    return typeid(_Fp);
1552227825Stheraven}
1553227825Stheraven
1554227825Stheraven#endif  // _LIBCPP_NO_RTTI
1555227825Stheraven
1556227825Stheraven}  // __function
1557227825Stheraven
1558232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1559261272Sdimclass _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
1560232924Stheraven    : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
1561232924Stheraven      public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
1562227825Stheraven{
1563232924Stheraven    typedef __function::__base<_Rp(_ArgTypes...)> __base;
1564246468Stheraven    typename aligned_storage<3*sizeof(void*)>::type __buf_;
1565227825Stheraven    __base* __f_;
1566227825Stheraven
1567241900Sdim    template <class _Fp, bool = !is_same<_Fp, function>::value &&
1568241900Sdim                                __invokable<_Fp&, _ArgTypes...>::value>
1569227825Stheraven        struct __callable;
1570232924Stheraven    template <class _Fp>
1571232924Stheraven        struct __callable<_Fp, true>
1572227825Stheraven        {
1573288943Sdim            static const bool value = is_same<void, _Rp>::value ||
1574232924Stheraven                is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
1575232924Stheraven                               _Rp>::value;
1576227825Stheraven        };
1577232924Stheraven    template <class _Fp>
1578232924Stheraven        struct __callable<_Fp, false>
1579227825Stheraven        {
1580227825Stheraven            static const bool value = false;
1581227825Stheraven        };
1582227825Stheravenpublic:
1583232924Stheraven    typedef _Rp result_type;
1584227825Stheraven
1585227825Stheraven    // construct/copy/destroy:
1586227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1587227825Stheraven    function() _NOEXCEPT : __f_(0) {}
1588227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1589227825Stheraven    function(nullptr_t) _NOEXCEPT : __f_(0) {}
1590227825Stheraven    function(const function&);
1591227825Stheraven    function(function&&) _NOEXCEPT;
1592232924Stheraven    template<class _Fp>
1593253146Stheraven      function(_Fp, typename enable_if
1594253146Stheraven                                     <
1595253146Stheraven                                        __callable<_Fp>::value &&
1596253146Stheraven                                        !is_same<_Fp, function>::value
1597253146Stheraven                                      >::type* = 0);
1598227825Stheraven
1599227825Stheraven    template<class _Alloc>
1600227825Stheraven      _LIBCPP_INLINE_VISIBILITY
1601227825Stheraven      function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
1602227825Stheraven    template<class _Alloc>
1603227825Stheraven      _LIBCPP_INLINE_VISIBILITY
1604227825Stheraven      function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
1605227825Stheraven    template<class _Alloc>
1606227825Stheraven      function(allocator_arg_t, const _Alloc&, const function&);
1607227825Stheraven    template<class _Alloc>
1608227825Stheraven      function(allocator_arg_t, const _Alloc&, function&&);
1609232924Stheraven    template<class _Fp, class _Alloc>
1610232924Stheraven      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1611232924Stheraven               typename enable_if<__callable<_Fp>::value>::type* = 0);
1612227825Stheraven
1613227825Stheraven    function& operator=(const function&);
1614227825Stheraven    function& operator=(function&&) _NOEXCEPT;
1615227825Stheraven    function& operator=(nullptr_t) _NOEXCEPT;
1616232924Stheraven    template<class _Fp>
1617227825Stheraven      typename enable_if
1618227825Stheraven      <
1619253146Stheraven        __callable<typename decay<_Fp>::type>::value &&
1620253146Stheraven        !is_same<typename remove_reference<_Fp>::type, function>::value,
1621227825Stheraven        function&
1622227825Stheraven      >::type
1623232924Stheraven      operator=(_Fp&&);
1624227825Stheraven
1625227825Stheraven    ~function();
1626227825Stheraven
1627227825Stheraven    // function modifiers:
1628227825Stheraven    void swap(function&) _NOEXCEPT;
1629232924Stheraven    template<class _Fp, class _Alloc>
1630227825Stheraven      _LIBCPP_INLINE_VISIBILITY
1631232924Stheraven      void assign(_Fp&& __f, const _Alloc& __a)
1632232924Stheraven        {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
1633227825Stheraven
1634227825Stheraven    // function capacity:
1635227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1636232924Stheraven        _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
1637227825Stheraven
1638227825Stheraven    // deleted overloads close possible hole in the type system
1639227825Stheraven    template<class _R2, class... _ArgTypes2>
1640227825Stheraven      bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
1641227825Stheraven    template<class _R2, class... _ArgTypes2>
1642227825Stheraven      bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
1643227825Stheravenpublic:
1644227825Stheraven    // function invocation:
1645232924Stheraven    _Rp operator()(_ArgTypes...) const;
1646227825Stheraven
1647227825Stheraven#ifndef _LIBCPP_NO_RTTI
1648227825Stheraven    // function target access:
1649227825Stheraven    const std::type_info& target_type() const _NOEXCEPT;
1650232924Stheraven    template <typename _Tp> _Tp* target() _NOEXCEPT;
1651232924Stheraven    template <typename _Tp> const _Tp* target() const _NOEXCEPT;
1652227825Stheraven#endif  // _LIBCPP_NO_RTTI
1653227825Stheraven};
1654227825Stheraven
1655232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1656232924Stheravenfunction<_Rp(_ArgTypes...)>::function(const function& __f)
1657227825Stheraven{
1658227825Stheraven    if (__f.__f_ == 0)
1659227825Stheraven        __f_ = 0;
1660227825Stheraven    else if (__f.__f_ == (const __base*)&__f.__buf_)
1661227825Stheraven    {
1662227825Stheraven        __f_ = (__base*)&__buf_;
1663227825Stheraven        __f.__f_->__clone(__f_);
1664227825Stheraven    }
1665227825Stheraven    else
1666227825Stheraven        __f_ = __f.__f_->__clone();
1667227825Stheraven}
1668227825Stheraven
1669232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1670227825Stheraventemplate <class _Alloc>
1671232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1672227825Stheraven                                     const function& __f)
1673227825Stheraven{
1674227825Stheraven    if (__f.__f_ == 0)
1675227825Stheraven        __f_ = 0;
1676227825Stheraven    else if (__f.__f_ == (const __base*)&__f.__buf_)
1677227825Stheraven    {
1678227825Stheraven        __f_ = (__base*)&__buf_;
1679227825Stheraven        __f.__f_->__clone(__f_);
1680227825Stheraven    }
1681227825Stheraven    else
1682227825Stheraven        __f_ = __f.__f_->__clone();
1683227825Stheraven}
1684227825Stheraven
1685232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1686232924Stheravenfunction<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
1687227825Stheraven{
1688227825Stheraven    if (__f.__f_ == 0)
1689227825Stheraven        __f_ = 0;
1690227825Stheraven    else if (__f.__f_ == (__base*)&__f.__buf_)
1691227825Stheraven    {
1692227825Stheraven        __f_ = (__base*)&__buf_;
1693227825Stheraven        __f.__f_->__clone(__f_);
1694227825Stheraven    }
1695227825Stheraven    else
1696227825Stheraven    {
1697227825Stheraven        __f_ = __f.__f_;
1698227825Stheraven        __f.__f_ = 0;
1699227825Stheraven    }
1700227825Stheraven}
1701227825Stheraven
1702232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1703227825Stheraventemplate <class _Alloc>
1704232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1705227825Stheraven                                     function&& __f)
1706227825Stheraven{
1707227825Stheraven    if (__f.__f_ == 0)
1708227825Stheraven        __f_ = 0;
1709227825Stheraven    else if (__f.__f_ == (__base*)&__f.__buf_)
1710227825Stheraven    {
1711227825Stheraven        __f_ = (__base*)&__buf_;
1712227825Stheraven        __f.__f_->__clone(__f_);
1713227825Stheraven    }
1714227825Stheraven    else
1715227825Stheraven    {
1716227825Stheraven        __f_ = __f.__f_;
1717227825Stheraven        __f.__f_ = 0;
1718227825Stheraven    }
1719227825Stheraven}
1720227825Stheraven
1721232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1722232924Stheraventemplate <class _Fp>
1723232924Stheravenfunction<_Rp(_ArgTypes...)>::function(_Fp __f,
1724253146Stheraven                                     typename enable_if
1725253146Stheraven                                     <
1726253146Stheraven                                        __callable<_Fp>::value &&
1727253146Stheraven                                        !is_same<_Fp, function>::value
1728253146Stheraven                                     >::type*)
1729227825Stheraven    : __f_(0)
1730227825Stheraven{
1731300770Sdim    if (__function::__not_null(__f))
1732227825Stheraven    {
1733232924Stheraven        typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
1734232924Stheraven        if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
1735227825Stheraven        {
1736227825Stheraven            __f_ = (__base*)&__buf_;
1737227825Stheraven            ::new (__f_) _FF(_VSTD::move(__f));
1738227825Stheraven        }
1739227825Stheraven        else
1740227825Stheraven        {
1741232924Stheraven            typedef allocator<_FF> _Ap;
1742232924Stheraven            _Ap __a;
1743232924Stheraven            typedef __allocator_destructor<_Ap> _Dp;
1744232924Stheraven            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1745232924Stheraven            ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
1746227825Stheraven            __f_ = __hold.release();
1747227825Stheraven        }
1748227825Stheraven    }
1749227825Stheraven}
1750227825Stheraven
1751232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1752232924Stheraventemplate <class _Fp, class _Alloc>
1753232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1754232924Stheraven                                     typename enable_if<__callable<_Fp>::value>::type*)
1755227825Stheraven    : __f_(0)
1756227825Stheraven{
1757227825Stheraven    typedef allocator_traits<_Alloc> __alloc_traits;
1758300770Sdim    if (__function::__not_null(__f))
1759227825Stheraven    {
1760232924Stheraven        typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
1761288943Sdim        typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1762276792Sdim        _Ap __a(__a0);
1763276792Sdim        if (sizeof(_FF) <= sizeof(__buf_) && 
1764276792Sdim            is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
1765227825Stheraven        {
1766227825Stheraven            __f_ = (__base*)&__buf_;
1767276792Sdim            ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));
1768227825Stheraven        }
1769227825Stheraven        else
1770227825Stheraven        {
1771232924Stheraven            typedef __allocator_destructor<_Ap> _Dp;
1772232924Stheraven            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1773227825Stheraven            ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
1774227825Stheraven            __f_ = __hold.release();
1775227825Stheraven        }
1776227825Stheraven    }
1777227825Stheraven}
1778227825Stheraven
1779232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1780232924Stheravenfunction<_Rp(_ArgTypes...)>&
1781232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(const function& __f)
1782227825Stheraven{
1783227825Stheraven    function(__f).swap(*this);
1784227825Stheraven    return *this;
1785227825Stheraven}
1786227825Stheraven
1787232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1788232924Stheravenfunction<_Rp(_ArgTypes...)>&
1789232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
1790227825Stheraven{
1791227825Stheraven    if (__f_ == (__base*)&__buf_)
1792227825Stheraven        __f_->destroy();
1793227825Stheraven    else if (__f_)
1794227825Stheraven        __f_->destroy_deallocate();
1795227825Stheraven    __f_ = 0;
1796227825Stheraven    if (__f.__f_ == 0)
1797227825Stheraven        __f_ = 0;
1798227825Stheraven    else if (__f.__f_ == (__base*)&__f.__buf_)
1799227825Stheraven    {
1800227825Stheraven        __f_ = (__base*)&__buf_;
1801227825Stheraven        __f.__f_->__clone(__f_);
1802227825Stheraven    }
1803227825Stheraven    else
1804227825Stheraven    {
1805227825Stheraven        __f_ = __f.__f_;
1806227825Stheraven        __f.__f_ = 0;
1807227825Stheraven    }
1808241900Sdim    return *this;
1809227825Stheraven}
1810227825Stheraven
1811232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1812232924Stheravenfunction<_Rp(_ArgTypes...)>&
1813232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
1814227825Stheraven{
1815227825Stheraven    if (__f_ == (__base*)&__buf_)
1816227825Stheraven        __f_->destroy();
1817227825Stheraven    else if (__f_)
1818227825Stheraven        __f_->destroy_deallocate();
1819227825Stheraven    __f_ = 0;
1820241900Sdim    return *this;
1821227825Stheraven}
1822227825Stheraven
1823232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1824232924Stheraventemplate <class _Fp>
1825227825Stheraventypename enable_if
1826227825Stheraven<
1827253146Stheraven    function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
1828253146Stheraven    !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
1829232924Stheraven    function<_Rp(_ArgTypes...)>&
1830227825Stheraven>::type
1831232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
1832227825Stheraven{
1833232924Stheraven    function(_VSTD::forward<_Fp>(__f)).swap(*this);
1834227825Stheraven    return *this;
1835227825Stheraven}
1836227825Stheraven
1837232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1838232924Stheravenfunction<_Rp(_ArgTypes...)>::~function()
1839227825Stheraven{
1840227825Stheraven    if (__f_ == (__base*)&__buf_)
1841227825Stheraven        __f_->destroy();
1842227825Stheraven    else if (__f_)
1843227825Stheraven        __f_->destroy_deallocate();
1844227825Stheraven}
1845227825Stheraven
1846232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1847227825Stheravenvoid
1848232924Stheravenfunction<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
1849227825Stheraven{
1850227825Stheraven    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1851227825Stheraven    {
1852227825Stheraven        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1853227825Stheraven        __base* __t = (__base*)&__tempbuf;
1854227825Stheraven        __f_->__clone(__t);
1855227825Stheraven        __f_->destroy();
1856227825Stheraven        __f_ = 0;
1857227825Stheraven        __f.__f_->__clone((__base*)&__buf_);
1858227825Stheraven        __f.__f_->destroy();
1859227825Stheraven        __f.__f_ = 0;
1860227825Stheraven        __f_ = (__base*)&__buf_;
1861227825Stheraven        __t->__clone((__base*)&__f.__buf_);
1862227825Stheraven        __t->destroy();
1863227825Stheraven        __f.__f_ = (__base*)&__f.__buf_;
1864227825Stheraven    }
1865227825Stheraven    else if (__f_ == (__base*)&__buf_)
1866227825Stheraven    {
1867227825Stheraven        __f_->__clone((__base*)&__f.__buf_);
1868227825Stheraven        __f_->destroy();
1869227825Stheraven        __f_ = __f.__f_;
1870227825Stheraven        __f.__f_ = (__base*)&__f.__buf_;
1871227825Stheraven    }
1872227825Stheraven    else if (__f.__f_ == (__base*)&__f.__buf_)
1873227825Stheraven    {
1874227825Stheraven        __f.__f_->__clone((__base*)&__buf_);
1875227825Stheraven        __f.__f_->destroy();
1876227825Stheraven        __f.__f_ = __f_;
1877227825Stheraven        __f_ = (__base*)&__buf_;
1878227825Stheraven    }
1879227825Stheraven    else
1880227825Stheraven        _VSTD::swap(__f_, __f.__f_);
1881227825Stheraven}
1882227825Stheraven
1883232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1884232924Stheraven_Rp
1885232924Stheravenfunction<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
1886227825Stheraven{
1887227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS
1888227825Stheraven    if (__f_ == 0)
1889227825Stheraven        throw bad_function_call();
1890227825Stheraven#endif  // _LIBCPP_NO_EXCEPTIONS
1891227825Stheraven    return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
1892227825Stheraven}
1893227825Stheraven
1894227825Stheraven#ifndef _LIBCPP_NO_RTTI
1895227825Stheraven
1896232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1897227825Stheravenconst std::type_info&
1898232924Stheravenfunction<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1899227825Stheraven{
1900227825Stheraven    if (__f_ == 0)
1901227825Stheraven        return typeid(void);
1902227825Stheraven    return __f_->target_type();
1903227825Stheraven}
1904227825Stheraven
1905232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1906232924Stheraventemplate <typename _Tp>
1907232924Stheraven_Tp*
1908232924Stheravenfunction<_Rp(_ArgTypes...)>::target() _NOEXCEPT
1909227825Stheraven{
1910227825Stheraven    if (__f_ == 0)
1911232924Stheraven        return (_Tp*)0;
1912232924Stheraven    return (_Tp*)__f_->target(typeid(_Tp));
1913227825Stheraven}
1914227825Stheraven
1915232924Stheraventemplate<class _Rp, class ..._ArgTypes>
1916232924Stheraventemplate <typename _Tp>
1917232924Stheravenconst _Tp*
1918232924Stheravenfunction<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
1919227825Stheraven{
1920227825Stheraven    if (__f_ == 0)
1921232924Stheraven        return (const _Tp*)0;
1922232924Stheraven    return (const _Tp*)__f_->target(typeid(_Tp));
1923227825Stheraven}
1924227825Stheraven
1925227825Stheraven#endif  // _LIBCPP_NO_RTTI
1926227825Stheraven
1927232924Stheraventemplate <class _Rp, class... _ArgTypes>
1928227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1929227825Stheravenbool
1930232924Stheravenoperator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
1931227825Stheraven
1932232924Stheraventemplate <class _Rp, class... _ArgTypes>
1933227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1934227825Stheravenbool
1935232924Stheravenoperator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
1936227825Stheraven
1937232924Stheraventemplate <class _Rp, class... _ArgTypes>
1938227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1939227825Stheravenbool
1940232924Stheravenoperator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
1941227825Stheraven
1942232924Stheraventemplate <class _Rp, class... _ArgTypes>
1943227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1944227825Stheravenbool
1945232924Stheravenoperator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
1946227825Stheraven
1947232924Stheraventemplate <class _Rp, class... _ArgTypes>
1948227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1949227825Stheravenvoid
1950232924Stheravenswap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
1951227825Stheraven{return __x.swap(__y);}
1952227825Stheraven
1953300770Sdim#else // _LIBCPP_HAS_NO_VARIADICS
1954300770Sdim
1955300770Sdim#include <__functional_03>
1956300770Sdim
1957300770Sdim#endif
1958300770Sdim
1959300770Sdim////////////////////////////////////////////////////////////////////////////////
1960300770Sdim//                                  BIND
1961300770Sdim//==============================================================================
1962300770Sdim
1963227825Stheraventemplate<class _Tp> struct __is_bind_expression : public false_type {};
1964261272Sdimtemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
1965227825Stheraven    : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
1966227825Stheraven
1967227825Stheraventemplate<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
1968261272Sdimtemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
1969227825Stheraven    : public __is_placeholder<typename remove_cv<_Tp>::type> {};
1970227825Stheraven
1971227825Stheravennamespace placeholders
1972227825Stheraven{
1973227825Stheraven
1974232924Stheraventemplate <int _Np> struct __ph {};
1975227825Stheraven
1976261272Sdim_LIBCPP_FUNC_VIS extern __ph<1>   _1;
1977261272Sdim_LIBCPP_FUNC_VIS extern __ph<2>   _2;
1978261272Sdim_LIBCPP_FUNC_VIS extern __ph<3>   _3;
1979261272Sdim_LIBCPP_FUNC_VIS extern __ph<4>   _4;
1980261272Sdim_LIBCPP_FUNC_VIS extern __ph<5>   _5;
1981261272Sdim_LIBCPP_FUNC_VIS extern __ph<6>   _6;
1982261272Sdim_LIBCPP_FUNC_VIS extern __ph<7>   _7;
1983261272Sdim_LIBCPP_FUNC_VIS extern __ph<8>   _8;
1984261272Sdim_LIBCPP_FUNC_VIS extern __ph<9>   _9;
1985261272Sdim_LIBCPP_FUNC_VIS extern __ph<10> _10;
1986227825Stheraven
1987227825Stheraven}  // placeholders
1988227825Stheraven
1989232924Stheraventemplate<int _Np>
1990232924Stheravenstruct __is_placeholder<placeholders::__ph<_Np> >
1991232924Stheraven    : public integral_constant<int, _Np> {};
1992227825Stheraven
1993300770Sdim
1994300770Sdim#ifndef _LIBCPP_HAS_NO_VARIADICS
1995300770Sdim
1996227825Stheraventemplate <class _Tp, class _Uj>
1997227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1998227825Stheraven_Tp&
1999227825Stheraven__mu(reference_wrapper<_Tp> __t, _Uj&)
2000227825Stheraven{
2001227825Stheraven    return __t.get();
2002227825Stheraven}
2003227825Stheraven
2004227825Stheraventemplate <class _Ti, class ..._Uj, size_t ..._Indx>
2005227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2006227825Stheraventypename __invoke_of<_Ti&, _Uj...>::type
2007227825Stheraven__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
2008227825Stheraven{
2009276792Sdim    return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
2010227825Stheraven}
2011227825Stheraven
2012227825Stheraventemplate <class _Ti, class ..._Uj>
2013227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2014276792Sdimtypename __lazy_enable_if
2015227825Stheraven<
2016227825Stheraven    is_bind_expression<_Ti>::value,
2017276792Sdim    __invoke_of<_Ti&, _Uj...>
2018227825Stheraven>::type
2019227825Stheraven__mu(_Ti& __ti, tuple<_Uj...>& __uj)
2020227825Stheraven{
2021227825Stheraven    typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
2022227825Stheraven    return  __mu_expand(__ti, __uj, __indices());
2023227825Stheraven}
2024227825Stheraven
2025227825Stheraventemplate <bool IsPh, class _Ti, class _Uj>
2026227825Stheravenstruct __mu_return2 {};
2027227825Stheraven
2028227825Stheraventemplate <class _Ti, class _Uj>
2029227825Stheravenstruct __mu_return2<true, _Ti, _Uj>
2030227825Stheraven{
2031227825Stheraven    typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
2032227825Stheraven};
2033227825Stheraven
2034227825Stheraventemplate <class _Ti, class _Uj>
2035227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2036227825Stheraventypename enable_if
2037227825Stheraven<
2038227825Stheraven    0 < is_placeholder<_Ti>::value,
2039227825Stheraven    typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
2040227825Stheraven>::type
2041227825Stheraven__mu(_Ti&, _Uj& __uj)
2042227825Stheraven{
2043227825Stheraven    const size_t _Indx = is_placeholder<_Ti>::value - 1;
2044276792Sdim    return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
2045227825Stheraven}
2046227825Stheraven
2047227825Stheraventemplate <class _Ti, class _Uj>
2048227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2049227825Stheraventypename enable_if
2050227825Stheraven<
2051227825Stheraven    !is_bind_expression<_Ti>::value &&
2052227825Stheraven    is_placeholder<_Ti>::value == 0 &&
2053227825Stheraven    !__is_reference_wrapper<_Ti>::value,
2054227825Stheraven    _Ti&
2055227825Stheraven>::type
2056232924Stheraven__mu(_Ti& __ti, _Uj&)
2057227825Stheraven{
2058227825Stheraven    return __ti;
2059227825Stheraven}
2060227825Stheraven
2061227825Stheraventemplate <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
2062227825Stheraven          class _TupleUj>
2063227825Stheravenstruct ____mu_return;
2064227825Stheraven
2065253146Stheraventemplate <bool _Invokable, class _Ti, class ..._Uj>
2066253146Stheravenstruct ____mu_return_invokable  // false
2067253146Stheraven{
2068253146Stheraven    typedef __nat type;
2069253146Stheraven};
2070253146Stheraven
2071227825Stheraventemplate <class _Ti, class ..._Uj>
2072253146Stheravenstruct ____mu_return_invokable<true, _Ti, _Uj...>
2073227825Stheraven{
2074227825Stheraven    typedef typename __invoke_of<_Ti&, _Uj...>::type type;
2075227825Stheraven};
2076227825Stheraven
2077253146Stheraventemplate <class _Ti, class ..._Uj>
2078253146Stheravenstruct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
2079253146Stheraven    : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
2080253146Stheraven{
2081253146Stheraven};
2082253146Stheraven
2083227825Stheraventemplate <class _Ti, class _TupleUj>
2084227825Stheravenstruct ____mu_return<_Ti, false, false, true, _TupleUj>
2085227825Stheraven{
2086227825Stheraven    typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
2087227825Stheraven                                   _TupleUj>::type&& type;
2088227825Stheraven};
2089227825Stheraven
2090227825Stheraventemplate <class _Ti, class _TupleUj>
2091227825Stheravenstruct ____mu_return<_Ti, true, false, false, _TupleUj>
2092227825Stheraven{
2093227825Stheraven    typedef typename _Ti::type& type;
2094227825Stheraven};
2095227825Stheraven
2096227825Stheraventemplate <class _Ti, class _TupleUj>
2097227825Stheravenstruct ____mu_return<_Ti, false, false, false, _TupleUj>
2098227825Stheraven{
2099227825Stheraven    typedef _Ti& type;
2100227825Stheraven};
2101227825Stheraven
2102227825Stheraventemplate <class _Ti, class _TupleUj>
2103227825Stheravenstruct __mu_return
2104227825Stheraven    : public ____mu_return<_Ti,
2105227825Stheraven                           __is_reference_wrapper<_Ti>::value,
2106227825Stheraven                           is_bind_expression<_Ti>::value,
2107249989Sdim                           0 < is_placeholder<_Ti>::value &&
2108249989Sdim                           is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
2109227825Stheraven                           _TupleUj>
2110227825Stheraven{
2111227825Stheraven};
2112227825Stheraven
2113232924Stheraventemplate <class _Fp, class _BoundArgs, class _TupleUj>
2114288943Sdimstruct __is_valid_bind_return
2115249989Sdim{
2116249989Sdim    static const bool value = false;
2117249989Sdim};
2118249989Sdim
2119249989Sdimtemplate <class _Fp, class ..._BoundArgs, class _TupleUj>
2120288943Sdimstruct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
2121249989Sdim{
2122249989Sdim    static const bool value = __invokable<_Fp,
2123249989Sdim                    typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
2124249989Sdim};
2125249989Sdim
2126249989Sdimtemplate <class _Fp, class ..._BoundArgs, class _TupleUj>
2127288943Sdimstruct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
2128249989Sdim{
2129249989Sdim    static const bool value = __invokable<_Fp,
2130249989Sdim                    typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
2131249989Sdim};
2132249989Sdim
2133249989Sdimtemplate <class _Fp, class _BoundArgs, class _TupleUj,
2134288943Sdim          bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
2135227825Stheravenstruct __bind_return;
2136227825Stheraven
2137232924Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj>
2138249989Sdimstruct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
2139227825Stheraven{
2140227825Stheraven    typedef typename __invoke_of
2141227825Stheraven    <
2142232924Stheraven        _Fp&,
2143227825Stheraven        typename __mu_return
2144227825Stheraven        <
2145227825Stheraven            _BoundArgs,
2146227825Stheraven            _TupleUj
2147227825Stheraven        >::type...
2148227825Stheraven    >::type type;
2149227825Stheraven};
2150227825Stheraven
2151232924Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj>
2152249989Sdimstruct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
2153227825Stheraven{
2154227825Stheraven    typedef typename __invoke_of
2155227825Stheraven    <
2156232924Stheraven        _Fp&,
2157227825Stheraven        typename __mu_return
2158227825Stheraven        <
2159227825Stheraven            const _BoundArgs,
2160227825Stheraven            _TupleUj
2161227825Stheraven        >::type...
2162227825Stheraven    >::type type;
2163227825Stheraven};
2164227825Stheraven
2165232924Stheraventemplate <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
2166227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2167232924Stheraventypename __bind_return<_Fp, _BoundArgs, _Args>::type
2168232924Stheraven__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
2169227825Stheraven                _Args&& __args)
2170227825Stheraven{
2171276792Sdim    return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
2172227825Stheraven}
2173227825Stheraven
2174232924Stheraventemplate<class _Fp, class ..._BoundArgs>
2175227825Stheravenclass __bind
2176232924Stheraven    : public __weak_result_type<typename decay<_Fp>::type>
2177227825Stheraven{
2178249989Sdimprotected:
2179232924Stheraven    typedef typename decay<_Fp>::type _Fd;
2180227825Stheraven    typedef tuple<typename decay<_BoundArgs>::type...> _Td;
2181249989Sdimprivate:
2182227825Stheraven    _Fd __f_;
2183227825Stheraven    _Td __bound_args_;
2184227825Stheraven
2185227825Stheraven    typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
2186227825Stheravenpublic:
2187227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2188227825Stheraven
2189227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2190227825Stheraven    __bind(const __bind& __b)
2191227825Stheraven        : __f_(__b.__f_),
2192227825Stheraven          __bound_args_(__b.__bound_args_) {}
2193227825Stheraven
2194227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2195227825Stheraven    __bind& operator=(const __bind& __b)
2196227825Stheraven    {
2197227825Stheraven        __f_ = __b.__f_;
2198227825Stheraven        __bound_args_ = __b.__bound_args_;
2199227825Stheraven        return *this;
2200227825Stheraven    }
2201227825Stheraven
2202227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2203227825Stheraven    __bind(__bind&& __b)
2204227825Stheraven        : __f_(_VSTD::move(__b.__f_)),
2205227825Stheraven          __bound_args_(_VSTD::move(__b.__bound_args_)) {}
2206227825Stheraven
2207227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2208227825Stheraven    __bind& operator=(__bind&& __b)
2209227825Stheraven    {
2210227825Stheraven        __f_ = _VSTD::move(__b.__f_);
2211227825Stheraven        __bound_args_ = _VSTD::move(__b.__bound_args_);
2212227825Stheraven        return *this;
2213227825Stheraven    }
2214227825Stheraven
2215227825Stheraven#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2216227825Stheraven
2217241900Sdim    template <class _Gp, class ..._BA,
2218241900Sdim              class = typename enable_if
2219241900Sdim                               <
2220253146Stheraven                                  is_constructible<_Fd, _Gp>::value &&
2221253146Stheraven                                  !is_same<typename remove_reference<_Gp>::type,
2222253146Stheraven                                           __bind>::value
2223241900Sdim                               >::type>
2224227825Stheraven      _LIBCPP_INLINE_VISIBILITY
2225232924Stheraven      explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
2226232924Stheraven        : __f_(_VSTD::forward<_Gp>(__f)),
2227227825Stheraven          __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
2228227825Stheraven
2229227825Stheraven    template <class ..._Args>
2230227825Stheraven        _LIBCPP_INLINE_VISIBILITY
2231227825Stheraven        typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
2232227825Stheraven        operator()(_Args&& ...__args)
2233227825Stheraven        {
2234227825Stheraven            return __apply_functor(__f_, __bound_args_, __indices(),
2235227825Stheraven                                  tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2236227825Stheraven        }
2237227825Stheraven
2238227825Stheraven    template <class ..._Args>
2239227825Stheraven        _LIBCPP_INLINE_VISIBILITY
2240249989Sdim        typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
2241227825Stheraven        operator()(_Args&& ...__args) const
2242227825Stheraven        {
2243227825Stheraven            return __apply_functor(__f_, __bound_args_, __indices(),
2244227825Stheraven                                   tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2245227825Stheraven        }
2246227825Stheraven};
2247227825Stheraven
2248232924Stheraventemplate<class _Fp, class ..._BoundArgs>
2249232924Stheravenstruct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
2250227825Stheraven
2251232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs>
2252227825Stheravenclass __bind_r
2253232924Stheraven    : public __bind<_Fp, _BoundArgs...>
2254227825Stheraven{
2255232924Stheraven    typedef __bind<_Fp, _BoundArgs...> base;
2256249989Sdim    typedef typename base::_Fd _Fd;
2257249989Sdim    typedef typename base::_Td _Td;
2258227825Stheravenpublic:
2259232924Stheraven    typedef _Rp result_type;
2260227825Stheraven
2261227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2262227825Stheraven
2263227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2264227825Stheraven    __bind_r(const __bind_r& __b)
2265227825Stheraven        : base(_VSTD::forward<const base&>(__b)) {}
2266227825Stheraven
2267227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2268227825Stheraven    __bind_r& operator=(const __bind_r& __b)
2269227825Stheraven    {
2270227825Stheraven        base::operator=(_VSTD::forward<const base&>(__b));
2271227825Stheraven        return *this;
2272227825Stheraven    }
2273227825Stheraven
2274227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2275227825Stheraven    __bind_r(__bind_r&& __b)
2276227825Stheraven        : base(_VSTD::forward<base>(__b)) {}
2277227825Stheraven
2278227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2279227825Stheraven    __bind_r& operator=(__bind_r&& __b)
2280227825Stheraven    {
2281227825Stheraven        base::operator=(_VSTD::forward<base>(__b));
2282227825Stheraven        return *this;
2283227825Stheraven    }
2284227825Stheraven
2285227825Stheraven#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2286227825Stheraven
2287253146Stheraven    template <class _Gp, class ..._BA,
2288253146Stheraven              class = typename enable_if
2289253146Stheraven                               <
2290253146Stheraven                                  is_constructible<_Fd, _Gp>::value &&
2291253146Stheraven                                  !is_same<typename remove_reference<_Gp>::type,
2292253146Stheraven                                           __bind_r>::value
2293253146Stheraven                               >::type>
2294227825Stheraven      _LIBCPP_INLINE_VISIBILITY
2295232924Stheraven      explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
2296232924Stheraven        : base(_VSTD::forward<_Gp>(__f),
2297227825Stheraven               _VSTD::forward<_BA>(__bound_args)...) {}
2298227825Stheraven
2299227825Stheraven    template <class ..._Args>
2300227825Stheraven        _LIBCPP_INLINE_VISIBILITY
2301249989Sdim        typename enable_if
2302249989Sdim        <
2303249989Sdim            is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
2304288943Sdim                           result_type>::value || is_void<_Rp>::value,
2305249989Sdim            result_type
2306249989Sdim        >::type
2307227825Stheraven        operator()(_Args&& ...__args)
2308227825Stheraven        {
2309288943Sdim            typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2310288943Sdim            return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
2311227825Stheraven        }
2312227825Stheraven
2313227825Stheraven    template <class ..._Args>
2314227825Stheraven        _LIBCPP_INLINE_VISIBILITY
2315249989Sdim        typename enable_if
2316249989Sdim        <
2317249989Sdim            is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
2318288943Sdim                           result_type>::value || is_void<_Rp>::value,
2319249989Sdim            result_type
2320249989Sdim        >::type
2321227825Stheraven        operator()(_Args&& ...__args) const
2322227825Stheraven        {
2323288943Sdim            typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2324288943Sdim            return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
2325227825Stheraven        }
2326227825Stheraven};
2327227825Stheraven
2328232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs>
2329232924Stheravenstruct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
2330227825Stheraven
2331232924Stheraventemplate<class _Fp, class ..._BoundArgs>
2332227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2333232924Stheraven__bind<_Fp, _BoundArgs...>
2334232924Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args)
2335227825Stheraven{
2336232924Stheraven    typedef __bind<_Fp, _BoundArgs...> type;
2337232924Stheraven    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2338227825Stheraven}
2339227825Stheraven
2340232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs>
2341227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2342232924Stheraven__bind_r<_Rp, _Fp, _BoundArgs...>
2343232924Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args)
2344227825Stheraven{
2345232924Stheraven    typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
2346232924Stheraven    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2347227825Stheraven}
2348227825Stheraven
2349227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2350227825Stheraven
2351227825Stheraventemplate <>
2352261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<bool>
2353227825Stheraven    : public unary_function<bool, size_t>
2354227825Stheraven{
2355227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2356227825Stheraven    size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2357227825Stheraven};
2358227825Stheraven
2359227825Stheraventemplate <>
2360261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char>
2361227825Stheraven    : public unary_function<char, size_t>
2362227825Stheraven{
2363227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2364227825Stheraven    size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2365227825Stheraven};
2366227825Stheraven
2367227825Stheraventemplate <>
2368261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
2369227825Stheraven    : public unary_function<signed char, size_t>
2370227825Stheraven{
2371227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2372227825Stheraven    size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2373227825Stheraven};
2374227825Stheraven
2375227825Stheraventemplate <>
2376261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
2377227825Stheraven    : public unary_function<unsigned char, size_t>
2378227825Stheraven{
2379227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2380227825Stheraven    size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2381227825Stheraven};
2382227825Stheraven
2383227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
2384227825Stheraven
2385227825Stheraventemplate <>
2386261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char16_t>
2387227825Stheraven    : public unary_function<char16_t, size_t>
2388227825Stheraven{
2389227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2390227825Stheraven    size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2391227825Stheraven};
2392227825Stheraven
2393227825Stheraventemplate <>
2394261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char32_t>
2395227825Stheraven    : public unary_function<char32_t, size_t>
2396227825Stheraven{
2397227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2398227825Stheraven    size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2399227825Stheraven};
2400227825Stheraven
2401227825Stheraven#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
2402227825Stheraven
2403227825Stheraventemplate <>
2404261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t>
2405227825Stheraven    : public unary_function<wchar_t, size_t>
2406227825Stheraven{
2407227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2408227825Stheraven    size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2409227825Stheraven};
2410227825Stheraven
2411227825Stheraventemplate <>
2412261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<short>
2413227825Stheraven    : public unary_function<short, size_t>
2414227825Stheraven{
2415227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2416227825Stheraven    size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2417227825Stheraven};
2418227825Stheraven
2419227825Stheraventemplate <>
2420261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
2421227825Stheraven    : public unary_function<unsigned short, size_t>
2422227825Stheraven{
2423227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2424227825Stheraven    size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2425227825Stheraven};
2426227825Stheraven
2427227825Stheraventemplate <>
2428261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<int>
2429227825Stheraven    : public unary_function<int, size_t>
2430227825Stheraven{
2431227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2432227825Stheraven    size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2433227825Stheraven};
2434227825Stheraven
2435227825Stheraventemplate <>
2436261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
2437227825Stheraven    : public unary_function<unsigned int, size_t>
2438227825Stheraven{
2439227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2440227825Stheraven    size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2441227825Stheraven};
2442227825Stheraven
2443227825Stheraventemplate <>
2444261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long>
2445227825Stheraven    : public unary_function<long, size_t>
2446227825Stheraven{
2447227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2448227825Stheraven    size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2449227825Stheraven};
2450227825Stheraven
2451227825Stheraventemplate <>
2452261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
2453227825Stheraven    : public unary_function<unsigned long, size_t>
2454227825Stheraven{
2455227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2456227825Stheraven    size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2457227825Stheraven};
2458227825Stheraven
2459227825Stheraventemplate <>
2460261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long long>
2461232924Stheraven    : public __scalar_hash<long long>
2462227825Stheraven{
2463227825Stheraven};
2464227825Stheraven
2465227825Stheraventemplate <>
2466261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
2467232924Stheraven    : public __scalar_hash<unsigned long long>
2468227825Stheraven{
2469227825Stheraven};
2470227825Stheraven
2471227825Stheraventemplate <>
2472261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<float>
2473232924Stheraven    : public __scalar_hash<float>
2474227825Stheraven{
2475227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2476227825Stheraven    size_t operator()(float __v) const _NOEXCEPT
2477227825Stheraven    {
2478232924Stheraven        // -0.0 and 0.0 should return same hash
2479232924Stheraven       if (__v == 0)
2480232924Stheraven           return 0;
2481232924Stheraven        return __scalar_hash<float>::operator()(__v);
2482227825Stheraven    }
2483227825Stheraven};
2484227825Stheraven
2485227825Stheraventemplate <>
2486261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<double>
2487232924Stheraven    : public __scalar_hash<double>
2488227825Stheraven{
2489227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2490227825Stheraven    size_t operator()(double __v) const _NOEXCEPT
2491227825Stheraven    {
2492232924Stheraven        // -0.0 and 0.0 should return same hash
2493232924Stheraven       if (__v == 0)
2494232924Stheraven           return 0;
2495232924Stheraven        return __scalar_hash<double>::operator()(__v);
2496227825Stheraven    }
2497227825Stheraven};
2498227825Stheraven
2499227825Stheraventemplate <>
2500261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long double>
2501232924Stheraven    : public __scalar_hash<long double>
2502227825Stheraven{
2503227825Stheraven    _LIBCPP_INLINE_VISIBILITY
2504227825Stheraven    size_t operator()(long double __v) const _NOEXCEPT
2505227825Stheraven    {
2506232924Stheraven        // -0.0 and 0.0 should return same hash
2507227825Stheraven        if (__v == 0)
2508227825Stheraven            return 0;
2509232924Stheraven#if defined(__i386__)
2510232924Stheraven        // Zero out padding bits
2511232924Stheraven        union
2512232924Stheraven        {
2513232924Stheraven            long double __t;
2514232924Stheraven            struct
2515232924Stheraven            {
2516232924Stheraven                size_t __a;
2517232924Stheraven                size_t __b;
2518232924Stheraven                size_t __c;
2519232924Stheraven                size_t __d;
2520289082Sdim            } __s;
2521232924Stheraven        } __u;
2522289082Sdim        __u.__s.__a = 0;
2523289082Sdim        __u.__s.__b = 0;
2524289082Sdim        __u.__s.__c = 0;
2525289082Sdim        __u.__s.__d = 0;
2526232924Stheraven        __u.__t = __v;
2527289082Sdim        return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
2528232924Stheraven#elif defined(__x86_64__)
2529232924Stheraven        // Zero out padding bits
2530232924Stheraven        union
2531232924Stheraven        {
2532232924Stheraven            long double __t;
2533232924Stheraven            struct
2534232924Stheraven            {
2535232924Stheraven                size_t __a;
2536232924Stheraven                size_t __b;
2537289082Sdim            } __s;
2538232924Stheraven        } __u;
2539289082Sdim        __u.__s.__a = 0;
2540289082Sdim        __u.__s.__b = 0;
2541232924Stheraven        __u.__t = __v;
2542289082Sdim        return __u.__s.__a ^ __u.__s.__b;
2543232924Stheraven#else
2544232924Stheraven        return __scalar_hash<long double>::operator()(__v);
2545232924Stheraven#endif
2546227825Stheraven    }
2547227825Stheraven};
2548227825Stheraven
2549261272Sdim#if _LIBCPP_STD_VER > 11
2550261272Sdimtemplate <class _Tp>
2551261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash
2552261272Sdim    : public unary_function<_Tp, size_t>
2553261272Sdim{
2554261272Sdim    static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types");
2555261272Sdim
2556261272Sdim    _LIBCPP_INLINE_VISIBILITY
2557261272Sdim    size_t operator()(_Tp __v) const _NOEXCEPT
2558261272Sdim    {
2559261272Sdim        typedef typename underlying_type<_Tp>::type type;
2560261272Sdim        return hash<type>{}(static_cast<type>(__v));
2561261272Sdim    }
2562261272Sdim};
2563261272Sdim#endif
2564261272Sdim
2565288943Sdim
2566288943Sdim#if _LIBCPP_STD_VER > 14
2567288943Sdimtemplate <class _Fn, class ..._Args>
2568288943Sdimresult_of_t<_Fn&&(_Args&&...)>
2569288943Sdiminvoke(_Fn&& __f, _Args&&... __args) {
2570288943Sdim    return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
2571288943Sdim}
2572288943Sdim#endif
2573288943Sdim
2574227825Stheraven// struct hash<T*> in <memory>
2575227825Stheraven
2576227825Stheraven_LIBCPP_END_NAMESPACE_STD
2577227825Stheraven
2578227825Stheraven#endif  // _LIBCPP_FUNCTIONAL
2579