2 //===------------------------ functional ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_FUNCTIONAL
12 #define _LIBCPP_FUNCTIONAL
20 template <class Arg, class Result>
23 typedef Arg argument_type;
24 typedef Result result_type;
27 template <class Arg1, class Arg2, class Result>
28 struct binary_function
30 typedef Arg1 first_argument_type;
31 typedef Arg2 second_argument_type;
32 typedef Result result_type;
36 class reference_wrapper
37 : public unary_function<T1, R> // if wrapping a unary functor
38 : public binary_function<T1, T2, R> // if wraping a binary functor
43 typedef see below result_type; // Not always defined
45 // construct/copy/destroy
46 reference_wrapper(T&) noexcept;
47 reference_wrapper(T&&) = delete; // do not bind to temps
48 reference_wrapper(const reference_wrapper<T>& x) noexcept;
51 reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;
54 operator T& () const noexcept;
55 T& get() const noexcept;
58 template <class... ArgTypes>
59 typename result_of<T&(ArgTypes&&...)>::type
60 operator() (ArgTypes&&...) const;
63 template <class T> reference_wrapper<T> ref(T& t) noexcept;
64 template <class T> void ref(const T&& t) = delete;
65 template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;
67 template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
68 template <class T> void cref(const T&& t) = delete;
69 template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
71 template <class T> // <class T=void> in C++14
72 struct plus : binary_function<T, T, T>
74 T operator()(const T& x, const T& y) const;
77 template <class T> // <class T=void> in C++14
78 struct minus : binary_function<T, T, T>
80 T operator()(const T& x, const T& y) const;
83 template <class T> // <class T=void> in C++14
84 struct multiplies : binary_function<T, T, T>
86 T operator()(const T& x, const T& y) const;
89 template <class T> // <class T=void> in C++14
90 struct divides : binary_function<T, T, T>
92 T operator()(const T& x, const T& y) const;
95 template <class T> // <class T=void> in C++14
96 struct modulus : binary_function<T, T, T>
98 T operator()(const T& x, const T& y) const;
101 template <class T> // <class T=void> in C++14
102 struct negate : unary_function<T, T>
104 T operator()(const T& x) const;
107 template <class T> // <class T=void> in C++14
108 struct equal_to : binary_function<T, T, bool>
110 bool operator()(const T& x, const T& y) const;
113 template <class T> // <class T=void> in C++14
114 struct not_equal_to : binary_function<T, T, bool>
116 bool operator()(const T& x, const T& y) const;
119 template <class T> // <class T=void> in C++14
120 struct greater : binary_function<T, T, bool>
122 bool operator()(const T& x, const T& y) const;
125 template <class T> // <class T=void> in C++14
126 struct less : binary_function<T, T, bool>
128 bool operator()(const T& x, const T& y) const;
131 template <class T> // <class T=void> in C++14
132 struct greater_equal : binary_function<T, T, bool>
134 bool operator()(const T& x, const T& y) const;
137 template <class T> // <class T=void> in C++14
138 struct less_equal : binary_function<T, T, bool>
140 bool operator()(const T& x, const T& y) const;
143 template <class T> // <class T=void> in C++14
144 struct logical_and : binary_function<T, T, bool>
146 bool operator()(const T& x, const T& y) const;
149 template <class T> // <class T=void> in C++14
150 struct logical_or : binary_function<T, T, bool>
152 bool operator()(const T& x, const T& y) const;
155 template <class T> // <class T=void> in C++14
156 struct logical_not : unary_function<T, bool>
158 bool operator()(const T& x) const;
161 template <class T> // <class T=void> in C++14
162 struct bit_and : unary_function<T, bool>
164 bool operator()(const T& x, const T& y) const;
167 template <class T> // <class T=void> in C++14
168 struct bit_or : unary_function<T, bool>
170 bool operator()(const T& x, const T& y) const;
173 template <class T> // <class T=void> in C++14
174 struct bit_xor : unary_function<T, bool>
176 bool operator()(const T& x, const T& y) const;
179 template <class T=void> // C++14
180 struct bit_xor : unary_function<T, bool>
182 bool operator()(const T& x) const;
185 template <class Predicate>
187 : public unary_function<typename Predicate::argument_type, bool>
190 explicit unary_negate(const Predicate& pred);
191 bool operator()(const typename Predicate::argument_type& x) const;
194 template <class Predicate> unary_negate<Predicate> not1(const Predicate& pred);
196 template <class Predicate>
198 : public binary_function<typename Predicate::first_argument_type,
199 typename Predicate::second_argument_type,
203 explicit binary_negate(const Predicate& pred);
204 bool operator()(const typename Predicate::first_argument_type& x,
205 const typename Predicate::second_argument_type& y) const;
208 template <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);
210 template<class T> struct is_bind_expression;
211 template<class T> struct is_placeholder;
213 template<class Fn, class... BoundArgs>
214 unspecified bind(Fn&&, BoundArgs&&...);
215 template<class R, class Fn, class... BoundArgs>
216 unspecified bind(Fn&&, BoundArgs&&...);
218 namespace placeholders {
219 // M is the implementation-defined number of placeholders
220 extern unspecified _1;
221 extern unspecified _2;
225 extern unspecified _Mp;
228 template <class Operation>
230 : public unary_function<typename Operation::second_argument_type,
231 typename Operation::result_type>
235 typename Operation::first_argument_type value;
237 binder1st(const Operation& x, const typename Operation::first_argument_type y);
238 typename Operation::result_type operator()( typename Operation::second_argument_type& x) const;
239 typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
242 template <class Operation, class T>
243 binder1st<Operation> bind1st(const Operation& op, const T& x);
245 template <class Operation>
247 : public unary_function<typename Operation::first_argument_type,
248 typename Operation::result_type>
252 typename Operation::second_argument_type value;
254 binder2nd(const Operation& x, const typename Operation::second_argument_type y);
255 typename Operation::result_type operator()( typename Operation::first_argument_type& x) const;
256 typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
259 template <class Operation, class T>
260 binder2nd<Operation> bind2nd(const Operation& op, const T& x);
262 template <class Arg, class Result>
263 class pointer_to_unary_function : public unary_function<Arg, Result>
266 explicit pointer_to_unary_function(Result (*f)(Arg));
267 Result operator()(Arg x) const;
270 template <class Arg, class Result>
271 pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));
273 template <class Arg1, class Arg2, class Result>
274 class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
277 explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
278 Result operator()(Arg1 x, Arg2 y) const;
281 template <class Arg1, class Arg2, class Result>
282 pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));
284 template<class S, class T>
285 class mem_fun_t : public unary_function<T*, S>
288 explicit mem_fun_t(S (T::*p)());
289 S operator()(T* p) const;
292 template<class S, class T, class A>
293 class mem_fun1_t : public binary_function<T*, A, S>
296 explicit mem_fun1_t(S (T::*p)(A));
297 S operator()(T* p, A x) const;
300 template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)());
301 template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
303 template<class S, class T>
304 class mem_fun_ref_t : public unary_function<T, S>
307 explicit mem_fun_ref_t(S (T::*p)());
308 S operator()(T& p) const;
311 template<class S, class T, class A>
312 class mem_fun1_ref_t : public binary_function<T, A, S>
315 explicit mem_fun1_ref_t(S (T::*p)(A));
316 S operator()(T& p, A x) const;
319 template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)());
320 template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));
322 template <class S, class T>
323 class const_mem_fun_t : public unary_function<const T*, S>
326 explicit const_mem_fun_t(S (T::*p)() const);
327 S operator()(const T* p) const;
330 template <class S, class T, class A>
331 class const_mem_fun1_t : public binary_function<const T*, A, S>
334 explicit const_mem_fun1_t(S (T::*p)(A) const);
335 S operator()(const T* p, A x) const;
338 template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const);
339 template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);
341 template <class S, class T>
342 class const_mem_fun_ref_t : public unary_function<T, S>
345 explicit const_mem_fun_ref_t(S (T::*p)() const);
346 S operator()(const T& p) const;
349 template <class S, class T, class A>
350 class const_mem_fun1_ref_t : public binary_function<T, A, S>
353 explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
354 S operator()(const T& p, A x) const;
357 template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const);
358 template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
360 template<class R, class T> unspecified mem_fn(R T::*);
362 class bad_function_call
367 template<class> class function; // undefined
369 template<class R, class... ArgTypes>
370 class function<R(ArgTypes...)>
371 : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
372 // ArgTypes contains T1
373 : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
374 // ArgTypes contains T1 and T2
377 typedef R result_type;
379 // construct/copy/destroy:
381 function(nullptr_t) noexcept;
382 function(const function&);
383 function(function&&) noexcept;
386 template<Allocator Alloc>
387 function(allocator_arg_t, const Alloc&) noexcept;
388 template<Allocator Alloc>
389 function(allocator_arg_t, const Alloc&, nullptr_t) noexcept;
390 template<Allocator Alloc>
391 function(allocator_arg_t, const Alloc&, const function&);
392 template<Allocator Alloc>
393 function(allocator_arg_t, const Alloc&, function&&);
394 template<class F, Allocator Alloc>
395 function(allocator_arg_t, const Alloc&, F);
397 function& operator=(const function&);
398 function& operator=(function&&) noexcept;
399 function& operator=(nullptr_t) noexcept;
401 function& operator=(F&&);
403 function& operator=(reference_wrapper<F>) noexcept;
407 // function modifiers:
408 void swap(function&) noexcept;
409 template<class F, class Alloc>
410 void assign(F&&, const Alloc&);
412 // function capacity:
413 explicit operator bool() const noexcept;
415 // function invocation:
416 R operator()(ArgTypes...) const;
418 // function target access:
419 const std::type_info& target_type() const noexcept;
420 template <typename T> T* target() noexcept;
421 template <typename T> const T* target() const noexcept;
424 // Null pointer comparisons:
425 template <class R, class ... ArgTypes>
426 bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
428 template <class R, class ... ArgTypes>
429 bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
431 template <class R, class ... ArgTypes>
432 bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
434 template <class R, class ... ArgTypes>
435 bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
437 // specialized algorithms:
438 template <class R, class ... ArgTypes>
439 void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
441 template <class T> struct hash;
443 template <> struct hash<bool>;
444 template <> struct hash<char>;
445 template <> struct hash<signed char>;
446 template <> struct hash<unsigned char>;
447 template <> struct hash<char16_t>;
448 template <> struct hash<char32_t>;
449 template <> struct hash<wchar_t>;
450 template <> struct hash<short>;
451 template <> struct hash<unsigned short>;
452 template <> struct hash<int>;
453 template <> struct hash<unsigned int>;
454 template <> struct hash<long>;
455 template <> struct hash<long long>;
456 template <> struct hash<unsigned long>;
457 template <> struct hash<unsigned long long>;
459 template <> struct hash<float>;
460 template <> struct hash<double>;
461 template <> struct hash<long double>;
463 template<class T> struct hash<T*>;
467 POLICY: For non-variadic implementations, the number of arguments is limited
468 to 3. It is hoped that the need for non-variadic implementations
474 #include <type_traits>
480 #include <__functional_base>
482 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
483 #pragma GCC system_header
486 _LIBCPP_BEGIN_NAMESPACE_STD
488 #if _LIBCPP_STD_VER > 11
489 template <class _Tp = void>
493 struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp>
495 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
496 _Tp operator()(const _Tp& __x, const _Tp& __y) const
500 #if _LIBCPP_STD_VER > 11
502 struct _LIBCPP_TYPE_VIS_ONLY plus<void>
504 template <class _T1, class _T2>
505 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
506 auto operator()(_T1&& __t, _T2&& __u) const
507 { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
508 typedef void is_transparent;
513 #if _LIBCPP_STD_VER > 11
514 template <class _Tp = void>
518 struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp>
520 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
521 _Tp operator()(const _Tp& __x, const _Tp& __y) const
525 #if _LIBCPP_STD_VER > 11
527 struct _LIBCPP_TYPE_VIS_ONLY minus<void>
529 template <class _T1, class _T2>
530 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
531 auto operator()(_T1&& __t, _T2&& __u) const
532 { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
533 typedef void is_transparent;
538 #if _LIBCPP_STD_VER > 11
539 template <class _Tp = void>
543 struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp>
545 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
546 _Tp operator()(const _Tp& __x, const _Tp& __y) const
550 #if _LIBCPP_STD_VER > 11
552 struct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
554 template <class _T1, class _T2>
555 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
556 auto operator()(_T1&& __t, _T2&& __u) const
557 { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
558 typedef void is_transparent;
563 #if _LIBCPP_STD_VER > 11
564 template <class _Tp = void>
568 struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp>
570 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
571 _Tp operator()(const _Tp& __x, const _Tp& __y) const
575 #if _LIBCPP_STD_VER > 11
577 struct _LIBCPP_TYPE_VIS_ONLY divides<void>
579 template <class _T1, class _T2>
580 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
581 auto operator()(_T1&& __t, _T2&& __u) const
582 { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
583 typedef void is_transparent;
588 #if _LIBCPP_STD_VER > 11
589 template <class _Tp = void>
593 struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp>
595 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
596 _Tp operator()(const _Tp& __x, const _Tp& __y) const
600 #if _LIBCPP_STD_VER > 11
602 struct _LIBCPP_TYPE_VIS_ONLY modulus<void>
604 template <class _T1, class _T2>
605 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
606 auto operator()(_T1&& __t, _T2&& __u) const
607 { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
608 typedef void is_transparent;
613 #if _LIBCPP_STD_VER > 11
614 template <class _Tp = void>
618 struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp>
620 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
621 _Tp operator()(const _Tp& __x) const
625 #if _LIBCPP_STD_VER > 11
627 struct _LIBCPP_TYPE_VIS_ONLY negate<void>
630 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
631 auto operator()(_Tp&& __x) const
632 { return -_VSTD::forward<_Tp>(__x); }
633 typedef void is_transparent;
638 #if _LIBCPP_STD_VER > 11
639 template <class _Tp = void>
643 struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool>
645 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
646 bool operator()(const _Tp& __x, const _Tp& __y) const
650 #if _LIBCPP_STD_VER > 11
652 struct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
654 template <class _T1, class _T2>
655 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
656 auto operator()(_T1&& __t, _T2&& __u) const
657 { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
658 typedef void is_transparent;
663 #if _LIBCPP_STD_VER > 11
664 template <class _Tp = void>
668 struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool>
670 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
671 bool operator()(const _Tp& __x, const _Tp& __y) const
675 #if _LIBCPP_STD_VER > 11
677 struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
679 template <class _T1, class _T2>
680 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
681 auto operator()(_T1&& __t, _T2&& __u) const
682 { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
683 typedef void is_transparent;
688 #if _LIBCPP_STD_VER > 11
689 template <class _Tp = void>
693 struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool>
695 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
696 bool operator()(const _Tp& __x, const _Tp& __y) const
700 #if _LIBCPP_STD_VER > 11
702 struct _LIBCPP_TYPE_VIS_ONLY greater<void>
704 template <class _T1, class _T2>
705 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
706 auto operator()(_T1&& __t, _T2&& __u) const
707 { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
708 typedef void is_transparent;
713 // less in <__functional_base>
715 #if _LIBCPP_STD_VER > 11
716 template <class _Tp = void>
720 struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool>
722 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
723 bool operator()(const _Tp& __x, const _Tp& __y) const
727 #if _LIBCPP_STD_VER > 11
729 struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
731 template <class _T1, class _T2>
732 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
733 auto operator()(_T1&& __t, _T2&& __u) const
734 { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
735 typedef void is_transparent;
740 #if _LIBCPP_STD_VER > 11
741 template <class _Tp = void>
745 struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool>
747 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
748 bool operator()(const _Tp& __x, const _Tp& __y) const
752 #if _LIBCPP_STD_VER > 11
754 struct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
756 template <class _T1, class _T2>
757 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
758 auto operator()(_T1&& __t, _T2&& __u) const
759 { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
760 typedef void is_transparent;
765 #if _LIBCPP_STD_VER > 11
766 template <class _Tp = void>
770 struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool>
772 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
773 bool operator()(const _Tp& __x, const _Tp& __y) const
777 #if _LIBCPP_STD_VER > 11
779 struct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
781 template <class _T1, class _T2>
782 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
783 auto operator()(_T1&& __t, _T2&& __u) const
784 { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
785 typedef void is_transparent;
790 #if _LIBCPP_STD_VER > 11
791 template <class _Tp = void>
795 struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool>
797 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
798 bool operator()(const _Tp& __x, const _Tp& __y) const
802 #if _LIBCPP_STD_VER > 11
804 struct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
806 template <class _T1, class _T2>
807 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
808 auto operator()(_T1&& __t, _T2&& __u) const
809 { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
810 typedef void is_transparent;
815 #if _LIBCPP_STD_VER > 11
816 template <class _Tp = void>
820 struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool>
822 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
823 bool operator()(const _Tp& __x) const
827 #if _LIBCPP_STD_VER > 11
829 struct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
832 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
833 auto operator()(_Tp&& __x) const
834 { return !_VSTD::forward<_Tp>(__x); }
835 typedef void is_transparent;
840 #if _LIBCPP_STD_VER > 11
841 template <class _Tp = void>
845 struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp>
847 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
848 _Tp operator()(const _Tp& __x, const _Tp& __y) const
852 #if _LIBCPP_STD_VER > 11
854 struct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
856 template <class _T1, class _T2>
857 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
858 auto operator()(_T1&& __t, _T2&& __u) const
859 { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
860 typedef void is_transparent;
865 #if _LIBCPP_STD_VER > 11
866 template <class _Tp = void>
870 struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp>
872 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
873 _Tp operator()(const _Tp& __x, const _Tp& __y) const
877 #if _LIBCPP_STD_VER > 11
879 struct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
881 template <class _T1, class _T2>
882 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
883 auto operator()(_T1&& __t, _T2&& __u) const
884 { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
885 typedef void is_transparent;
890 #if _LIBCPP_STD_VER > 11
891 template <class _Tp = void>
895 struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp>
897 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
898 _Tp operator()(const _Tp& __x, const _Tp& __y) const
902 #if _LIBCPP_STD_VER > 11
904 struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
906 template <class _T1, class _T2>
907 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
908 auto operator()(_T1&& __t, _T2&& __u) const
909 { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
910 typedef void is_transparent;
915 #if _LIBCPP_STD_VER > 11
916 template <class _Tp = void>
917 struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp>
919 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
920 _Tp operator()(const _Tp& __x) const
925 struct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
928 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
929 auto operator()(_Tp&& __x) const
930 { return ~_VSTD::forward<_Tp>(__x); }
931 typedef void is_transparent;
935 template <class _Predicate>
936 class _LIBCPP_TYPE_VIS_ONLY unary_negate
937 : public unary_function<typename _Predicate::argument_type, bool>
941 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
942 explicit unary_negate(const _Predicate& __pred)
944 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
945 bool operator()(const typename _Predicate::argument_type& __x) const
946 {return !__pred_(__x);}
949 template <class _Predicate>
950 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
951 unary_negate<_Predicate>
952 not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
954 template <class _Predicate>
955 class _LIBCPP_TYPE_VIS_ONLY binary_negate
956 : public binary_function<typename _Predicate::first_argument_type,
957 typename _Predicate::second_argument_type,
962 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
963 binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
965 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
966 bool operator()(const typename _Predicate::first_argument_type& __x,
967 const typename _Predicate::second_argument_type& __y) const
968 {return !__pred_(__x, __y);}
971 template <class _Predicate>
972 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
973 binary_negate<_Predicate>
974 not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
976 template <class __Operation>
977 class _LIBCPP_TYPE_VIS_ONLY binder1st
978 : public unary_function<typename __Operation::second_argument_type,
979 typename __Operation::result_type>
983 typename __Operation::first_argument_type value;
985 _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
986 const typename __Operation::first_argument_type __y)
987 : op(__x), value(__y) {}
988 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
989 (typename __Operation::second_argument_type& __x) const
990 {return op(value, __x);}
991 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
992 (const typename __Operation::second_argument_type& __x) const
993 {return op(value, __x);}
996 template <class __Operation, class _Tp>
997 inline _LIBCPP_INLINE_VISIBILITY
998 binder1st<__Operation>
999 bind1st(const __Operation& __op, const _Tp& __x)
1000 {return binder1st<__Operation>(__op, __x);}
1002 template <class __Operation>
1003 class _LIBCPP_TYPE_VIS_ONLY binder2nd
1004 : public unary_function<typename __Operation::first_argument_type,
1005 typename __Operation::result_type>
1009 typename __Operation::second_argument_type value;
1011 _LIBCPP_INLINE_VISIBILITY
1012 binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
1013 : op(__x), value(__y) {}
1014 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1015 ( typename __Operation::first_argument_type& __x) const
1016 {return op(__x, value);}
1017 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1018 (const typename __Operation::first_argument_type& __x) const
1019 {return op(__x, value);}
1022 template <class __Operation, class _Tp>
1023 inline _LIBCPP_INLINE_VISIBILITY
1024 binder2nd<__Operation>
1025 bind2nd(const __Operation& __op, const _Tp& __x)
1026 {return binder2nd<__Operation>(__op, __x);}
1028 template <class _Arg, class _Result>
1029 class _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function
1030 : public unary_function<_Arg, _Result>
1032 _Result (*__f_)(_Arg);
1034 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
1036 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
1040 template <class _Arg, class _Result>
1041 inline _LIBCPP_INLINE_VISIBILITY
1042 pointer_to_unary_function<_Arg,_Result>
1043 ptr_fun(_Result (*__f)(_Arg))
1044 {return pointer_to_unary_function<_Arg,_Result>(__f);}
1046 template <class _Arg1, class _Arg2, class _Result>
1047 class _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function
1048 : public binary_function<_Arg1, _Arg2, _Result>
1050 _Result (*__f_)(_Arg1, _Arg2);
1052 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
1054 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
1055 {return __f_(__x, __y);}
1058 template <class _Arg1, class _Arg2, class _Result>
1059 inline _LIBCPP_INLINE_VISIBILITY
1060 pointer_to_binary_function<_Arg1,_Arg2,_Result>
1061 ptr_fun(_Result (*__f)(_Arg1,_Arg2))
1062 {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
1064 template<class _Sp, class _Tp>
1065 class _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp>
1069 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
1071 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
1072 {return (__p->*__p_)();}
1075 template<class _Sp, class _Tp, class _Ap>
1076 class _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
1078 _Sp (_Tp::*__p_)(_Ap);
1080 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
1082 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
1083 {return (__p->*__p_)(__x);}
1086 template<class _Sp, class _Tp>
1087 inline _LIBCPP_INLINE_VISIBILITY
1089 mem_fun(_Sp (_Tp::*__f)())
1090 {return mem_fun_t<_Sp,_Tp>(__f);}
1092 template<class _Sp, class _Tp, class _Ap>
1093 inline _LIBCPP_INLINE_VISIBILITY
1094 mem_fun1_t<_Sp,_Tp,_Ap>
1095 mem_fun(_Sp (_Tp::*__f)(_Ap))
1096 {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1098 template<class _Sp, class _Tp>
1099 class _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp>
1103 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
1105 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
1106 {return (__p.*__p_)();}
1109 template<class _Sp, class _Tp, class _Ap>
1110 class _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
1112 _Sp (_Tp::*__p_)(_Ap);
1114 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
1116 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
1117 {return (__p.*__p_)(__x);}
1120 template<class _Sp, class _Tp>
1121 inline _LIBCPP_INLINE_VISIBILITY
1122 mem_fun_ref_t<_Sp,_Tp>
1123 mem_fun_ref(_Sp (_Tp::*__f)())
1124 {return mem_fun_ref_t<_Sp,_Tp>(__f);}
1126 template<class _Sp, class _Tp, class _Ap>
1127 inline _LIBCPP_INLINE_VISIBILITY
1128 mem_fun1_ref_t<_Sp,_Tp,_Ap>
1129 mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
1130 {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1132 template <class _Sp, class _Tp>
1133 class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp>
1135 _Sp (_Tp::*__p_)() const;
1137 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
1139 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
1140 {return (__p->*__p_)();}
1143 template <class _Sp, class _Tp, class _Ap>
1144 class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
1146 _Sp (_Tp::*__p_)(_Ap) const;
1148 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
1150 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
1151 {return (__p->*__p_)(__x);}
1154 template <class _Sp, class _Tp>
1155 inline _LIBCPP_INLINE_VISIBILITY
1156 const_mem_fun_t<_Sp,_Tp>
1157 mem_fun(_Sp (_Tp::*__f)() const)
1158 {return const_mem_fun_t<_Sp,_Tp>(__f);}
1160 template <class _Sp, class _Tp, class _Ap>
1161 inline _LIBCPP_INLINE_VISIBILITY
1162 const_mem_fun1_t<_Sp,_Tp,_Ap>
1163 mem_fun(_Sp (_Tp::*__f)(_Ap) const)
1164 {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1166 template <class _Sp, class _Tp>
1167 class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
1169 _Sp (_Tp::*__p_)() const;
1171 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
1173 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
1174 {return (__p.*__p_)();}
1177 template <class _Sp, class _Tp, class _Ap>
1178 class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t
1179 : public binary_function<_Tp, _Ap, _Sp>
1181 _Sp (_Tp::*__p_)(_Ap) const;
1183 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
1185 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
1186 {return (__p.*__p_)(__x);}
1189 template <class _Sp, class _Tp>
1190 inline _LIBCPP_INLINE_VISIBILITY
1191 const_mem_fun_ref_t<_Sp,_Tp>
1192 mem_fun_ref(_Sp (_Tp::*__f)() const)
1193 {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
1195 template <class _Sp, class _Tp, class _Ap>
1196 inline _LIBCPP_INLINE_VISIBILITY
1197 const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
1198 mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
1199 {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1201 #ifdef _LIBCPP_HAS_NO_VARIADICS
1203 #include <__functional_03>
1205 #else // _LIBCPP_HAS_NO_VARIADICS
1207 template <class _Tp>
1209 : public __weak_result_type<_Tp>
1218 _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}
1221 template <class... _ArgTypes>
1222 _LIBCPP_INLINE_VISIBILITY
1223 typename __invoke_return<type, _ArgTypes...>::type
1224 operator() (_ArgTypes&&... __args) const
1226 return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
1230 template<class _Rp, class _Tp>
1231 inline _LIBCPP_INLINE_VISIBILITY
1232 __mem_fn<_Rp _Tp::*>
1233 mem_fn(_Rp _Tp::* __pm)
1235 return __mem_fn<_Rp _Tp::*>(__pm);
1238 // bad_function_call
1240 class _LIBCPP_EXCEPTION_ABI bad_function_call
1245 template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
1247 namespace __function
1250 template<class _Rp, class ..._ArgTypes>
1251 struct __maybe_derive_from_unary_function
1255 template<class _Rp, class _A1>
1256 struct __maybe_derive_from_unary_function<_Rp(_A1)>
1257 : public unary_function<_A1, _Rp>
1261 template<class _Rp, class ..._ArgTypes>
1262 struct __maybe_derive_from_binary_function
1266 template<class _Rp, class _A1, class _A2>
1267 struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
1268 : public binary_function<_A1, _A2, _Rp>
1272 template<class _Fp> class __base;
1274 template<class _Rp, class ..._ArgTypes>
1275 class __base<_Rp(_ArgTypes...)>
1277 __base(const __base&);
1278 __base& operator=(const __base&);
1280 _LIBCPP_INLINE_VISIBILITY __base() {}
1281 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
1282 virtual __base* __clone() const = 0;
1283 virtual void __clone(__base*) const = 0;
1284 virtual void destroy() _NOEXCEPT = 0;
1285 virtual void destroy_deallocate() _NOEXCEPT = 0;
1286 virtual _Rp operator()(_ArgTypes&& ...) = 0;
1287 #ifndef _LIBCPP_NO_RTTI
1288 virtual const void* target(const type_info&) const _NOEXCEPT = 0;
1289 virtual const std::type_info& target_type() const _NOEXCEPT = 0;
1290 #endif // _LIBCPP_NO_RTTI
1293 template<class _FD, class _Alloc, class _FB> class __func;
1295 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1296 class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
1297 : public __base<_Rp(_ArgTypes...)>
1299 __compressed_pair<_Fp, _Alloc> __f_;
1301 _LIBCPP_INLINE_VISIBILITY
1302 explicit __func(_Fp&& __f)
1303 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1304 _VSTD::forward_as_tuple()) {}
1305 _LIBCPP_INLINE_VISIBILITY
1306 explicit __func(const _Fp& __f, const _Alloc& __a)
1307 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1308 _VSTD::forward_as_tuple(__a)) {}
1310 _LIBCPP_INLINE_VISIBILITY
1311 explicit __func(const _Fp& __f, _Alloc&& __a)
1312 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1313 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1315 _LIBCPP_INLINE_VISIBILITY
1316 explicit __func(_Fp&& __f, _Alloc&& __a)
1317 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1318 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1319 virtual __base<_Rp(_ArgTypes...)>* __clone() const;
1320 virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
1321 virtual void destroy() _NOEXCEPT;
1322 virtual void destroy_deallocate() _NOEXCEPT;
1323 virtual _Rp operator()(_ArgTypes&& ... __arg);
1324 #ifndef _LIBCPP_NO_RTTI
1325 virtual const void* target(const type_info&) const _NOEXCEPT;
1326 virtual const std::type_info& target_type() const _NOEXCEPT;
1327 #endif // _LIBCPP_NO_RTTI
1330 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1331 __base<_Rp(_ArgTypes...)>*
1332 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
1334 typedef typename _Alloc::template rebind<__func>::other _Ap;
1335 _Ap __a(__f_.second());
1336 typedef __allocator_destructor<_Ap> _Dp;
1337 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1338 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
1339 return __hold.release();
1342 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1344 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
1346 ::new (__p) __func(__f_.first(), __f_.second());
1349 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1351 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
1353 __f_.~__compressed_pair<_Fp, _Alloc>();
1356 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1358 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
1360 typedef typename _Alloc::template rebind<__func>::other _Ap;
1361 _Ap __a(__f_.second());
1362 __f_.~__compressed_pair<_Fp, _Alloc>();
1363 __a.deallocate(this, 1);
1366 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1368 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
1370 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1371 return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
1374 #ifndef _LIBCPP_NO_RTTI
1376 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1378 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
1380 if (__ti == typeid(_Fp))
1381 return &__f_.first();
1382 return (const void*)0;
1385 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1386 const std::type_info&
1387 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1392 #endif // _LIBCPP_NO_RTTI
1396 template<class _Rp, class ..._ArgTypes>
1397 class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
1398 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
1399 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
1401 typedef __function::__base<_Rp(_ArgTypes...)> __base;
1402 typename aligned_storage<3*sizeof(void*)>::type __buf_;
1405 template <class _Fp>
1406 _LIBCPP_INLINE_VISIBILITY
1407 static bool __not_null(const _Fp&) {return true;}
1408 template <class _R2, class ..._Ap>
1409 _LIBCPP_INLINE_VISIBILITY
1410 static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;}
1411 template <class _R2, class _Cp, class ..._Ap>
1412 _LIBCPP_INLINE_VISIBILITY
1413 static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;}
1414 template <class _R2, class _Cp, class ..._Ap>
1415 _LIBCPP_INLINE_VISIBILITY
1416 static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;}
1417 template <class _R2, class _Cp, class ..._Ap>
1418 _LIBCPP_INLINE_VISIBILITY
1419 static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;}
1420 template <class _R2, class _Cp, class ..._Ap>
1421 _LIBCPP_INLINE_VISIBILITY
1422 static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;}
1423 template <class _R2, class ..._Ap>
1424 _LIBCPP_INLINE_VISIBILITY
1425 static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;}
1427 template <class _Fp, bool = !is_same<_Fp, function>::value &&
1428 __invokable<_Fp&, _ArgTypes...>::value>
1430 template <class _Fp>
1431 struct __callable<_Fp, true>
1433 static const bool value = is_same<void, _Rp>::value ||
1434 is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
1437 template <class _Fp>
1438 struct __callable<_Fp, false>
1440 static const bool value = false;
1443 typedef _Rp result_type;
1445 // construct/copy/destroy:
1446 _LIBCPP_INLINE_VISIBILITY
1447 function() _NOEXCEPT : __f_(0) {}
1448 _LIBCPP_INLINE_VISIBILITY
1449 function(nullptr_t) _NOEXCEPT : __f_(0) {}
1450 function(const function&);
1451 function(function&&) _NOEXCEPT;
1453 function(_Fp, typename enable_if
1455 __callable<_Fp>::value &&
1456 !is_same<_Fp, function>::value
1459 template<class _Alloc>
1460 _LIBCPP_INLINE_VISIBILITY
1461 function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
1462 template<class _Alloc>
1463 _LIBCPP_INLINE_VISIBILITY
1464 function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
1465 template<class _Alloc>
1466 function(allocator_arg_t, const _Alloc&, const function&);
1467 template<class _Alloc>
1468 function(allocator_arg_t, const _Alloc&, function&&);
1469 template<class _Fp, class _Alloc>
1470 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1471 typename enable_if<__callable<_Fp>::value>::type* = 0);
1473 function& operator=(const function&);
1474 function& operator=(function&&) _NOEXCEPT;
1475 function& operator=(nullptr_t) _NOEXCEPT;
1479 __callable<typename decay<_Fp>::type>::value &&
1480 !is_same<typename remove_reference<_Fp>::type, function>::value,
1487 // function modifiers:
1488 void swap(function&) _NOEXCEPT;
1489 template<class _Fp, class _Alloc>
1490 _LIBCPP_INLINE_VISIBILITY
1491 void assign(_Fp&& __f, const _Alloc& __a)
1492 {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
1494 // function capacity:
1495 _LIBCPP_INLINE_VISIBILITY
1496 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
1498 // deleted overloads close possible hole in the type system
1499 template<class _R2, class... _ArgTypes2>
1500 bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
1501 template<class _R2, class... _ArgTypes2>
1502 bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
1504 // function invocation:
1505 _Rp operator()(_ArgTypes...) const;
1507 #ifndef _LIBCPP_NO_RTTI
1508 // function target access:
1509 const std::type_info& target_type() const _NOEXCEPT;
1510 template <typename _Tp> _Tp* target() _NOEXCEPT;
1511 template <typename _Tp> const _Tp* target() const _NOEXCEPT;
1512 #endif // _LIBCPP_NO_RTTI
1515 template<class _Rp, class ..._ArgTypes>
1516 function<_Rp(_ArgTypes...)>::function(const function& __f)
1520 else if (__f.__f_ == (const __base*)&__f.__buf_)
1522 __f_ = (__base*)&__buf_;
1523 __f.__f_->__clone(__f_);
1526 __f_ = __f.__f_->__clone();
1529 template<class _Rp, class ..._ArgTypes>
1530 template <class _Alloc>
1531 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1532 const function& __f)
1536 else if (__f.__f_ == (const __base*)&__f.__buf_)
1538 __f_ = (__base*)&__buf_;
1539 __f.__f_->__clone(__f_);
1542 __f_ = __f.__f_->__clone();
1545 template<class _Rp, class ..._ArgTypes>
1546 function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
1550 else if (__f.__f_ == (__base*)&__f.__buf_)
1552 __f_ = (__base*)&__buf_;
1553 __f.__f_->__clone(__f_);
1562 template<class _Rp, class ..._ArgTypes>
1563 template <class _Alloc>
1564 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1569 else if (__f.__f_ == (__base*)&__f.__buf_)
1571 __f_ = (__base*)&__buf_;
1572 __f.__f_->__clone(__f_);
1581 template<class _Rp, class ..._ArgTypes>
1582 template <class _Fp>
1583 function<_Rp(_ArgTypes...)>::function(_Fp __f,
1586 __callable<_Fp>::value &&
1587 !is_same<_Fp, function>::value
1591 if (__not_null(__f))
1593 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
1594 if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
1596 __f_ = (__base*)&__buf_;
1597 ::new (__f_) _FF(_VSTD::move(__f));
1601 typedef allocator<_FF> _Ap;
1603 typedef __allocator_destructor<_Ap> _Dp;
1604 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1605 ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
1606 __f_ = __hold.release();
1611 template<class _Rp, class ..._ArgTypes>
1612 template <class _Fp, class _Alloc>
1613 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1614 typename enable_if<__callable<_Fp>::value>::type*)
1617 typedef allocator_traits<_Alloc> __alloc_traits;
1618 if (__not_null(__f))
1620 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
1621 typedef typename __alloc_traits::template
1622 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
1625 rebind_alloc<_FF>::other
1629 if (sizeof(_FF) <= sizeof(__buf_) &&
1630 is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
1632 __f_ = (__base*)&__buf_;
1633 ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));
1637 typedef __allocator_destructor<_Ap> _Dp;
1638 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1639 ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
1640 __f_ = __hold.release();
1645 template<class _Rp, class ..._ArgTypes>
1646 function<_Rp(_ArgTypes...)>&
1647 function<_Rp(_ArgTypes...)>::operator=(const function& __f)
1649 function(__f).swap(*this);
1653 template<class _Rp, class ..._ArgTypes>
1654 function<_Rp(_ArgTypes...)>&
1655 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
1657 if (__f_ == (__base*)&__buf_)
1660 __f_->destroy_deallocate();
1664 else if (__f.__f_ == (__base*)&__f.__buf_)
1666 __f_ = (__base*)&__buf_;
1667 __f.__f_->__clone(__f_);
1677 template<class _Rp, class ..._ArgTypes>
1678 function<_Rp(_ArgTypes...)>&
1679 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
1681 if (__f_ == (__base*)&__buf_)
1684 __f_->destroy_deallocate();
1689 template<class _Rp, class ..._ArgTypes>
1690 template <class _Fp>
1693 function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
1694 !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
1695 function<_Rp(_ArgTypes...)>&
1697 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
1699 function(_VSTD::forward<_Fp>(__f)).swap(*this);
1703 template<class _Rp, class ..._ArgTypes>
1704 function<_Rp(_ArgTypes...)>::~function()
1706 if (__f_ == (__base*)&__buf_)
1709 __f_->destroy_deallocate();
1712 template<class _Rp, class ..._ArgTypes>
1714 function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
1716 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1718 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1719 __base* __t = (__base*)&__tempbuf;
1723 __f.__f_->__clone((__base*)&__buf_);
1724 __f.__f_->destroy();
1726 __f_ = (__base*)&__buf_;
1727 __t->__clone((__base*)&__f.__buf_);
1729 __f.__f_ = (__base*)&__f.__buf_;
1731 else if (__f_ == (__base*)&__buf_)
1733 __f_->__clone((__base*)&__f.__buf_);
1736 __f.__f_ = (__base*)&__f.__buf_;
1738 else if (__f.__f_ == (__base*)&__f.__buf_)
1740 __f.__f_->__clone((__base*)&__buf_);
1741 __f.__f_->destroy();
1743 __f_ = (__base*)&__buf_;
1746 _VSTD::swap(__f_, __f.__f_);
1749 template<class _Rp, class ..._ArgTypes>
1751 function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
1753 #ifndef _LIBCPP_NO_EXCEPTIONS
1755 throw bad_function_call();
1756 #endif // _LIBCPP_NO_EXCEPTIONS
1757 return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
1760 #ifndef _LIBCPP_NO_RTTI
1762 template<class _Rp, class ..._ArgTypes>
1763 const std::type_info&
1764 function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1767 return typeid(void);
1768 return __f_->target_type();
1771 template<class _Rp, class ..._ArgTypes>
1772 template <typename _Tp>
1774 function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
1778 return (_Tp*)__f_->target(typeid(_Tp));
1781 template<class _Rp, class ..._ArgTypes>
1782 template <typename _Tp>
1784 function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
1787 return (const _Tp*)0;
1788 return (const _Tp*)__f_->target(typeid(_Tp));
1791 #endif // _LIBCPP_NO_RTTI
1793 template <class _Rp, class... _ArgTypes>
1794 inline _LIBCPP_INLINE_VISIBILITY
1796 operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
1798 template <class _Rp, class... _ArgTypes>
1799 inline _LIBCPP_INLINE_VISIBILITY
1801 operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
1803 template <class _Rp, class... _ArgTypes>
1804 inline _LIBCPP_INLINE_VISIBILITY
1806 operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
1808 template <class _Rp, class... _ArgTypes>
1809 inline _LIBCPP_INLINE_VISIBILITY
1811 operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
1813 template <class _Rp, class... _ArgTypes>
1814 inline _LIBCPP_INLINE_VISIBILITY
1816 swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
1817 {return __x.swap(__y);}
1819 template<class _Tp> struct __is_bind_expression : public false_type {};
1820 template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
1821 : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
1823 template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
1824 template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
1825 : public __is_placeholder<typename remove_cv<_Tp>::type> {};
1827 namespace placeholders
1830 template <int _Np> struct __ph {};
1832 _LIBCPP_FUNC_VIS extern __ph<1> _1;
1833 _LIBCPP_FUNC_VIS extern __ph<2> _2;
1834 _LIBCPP_FUNC_VIS extern __ph<3> _3;
1835 _LIBCPP_FUNC_VIS extern __ph<4> _4;
1836 _LIBCPP_FUNC_VIS extern __ph<5> _5;
1837 _LIBCPP_FUNC_VIS extern __ph<6> _6;
1838 _LIBCPP_FUNC_VIS extern __ph<7> _7;
1839 _LIBCPP_FUNC_VIS extern __ph<8> _8;
1840 _LIBCPP_FUNC_VIS extern __ph<9> _9;
1841 _LIBCPP_FUNC_VIS extern __ph<10> _10;
1846 struct __is_placeholder<placeholders::__ph<_Np> >
1847 : public integral_constant<int, _Np> {};
1849 template <class _Tp, class _Uj>
1850 inline _LIBCPP_INLINE_VISIBILITY
1852 __mu(reference_wrapper<_Tp> __t, _Uj&)
1857 template <class _Ti, class ..._Uj, size_t ..._Indx>
1858 inline _LIBCPP_INLINE_VISIBILITY
1859 typename __invoke_of<_Ti&, _Uj...>::type
1860 __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
1862 return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
1865 template <class _Ti, class ..._Uj>
1866 inline _LIBCPP_INLINE_VISIBILITY
1867 typename __lazy_enable_if
1869 is_bind_expression<_Ti>::value,
1870 __invoke_of<_Ti&, _Uj...>
1872 __mu(_Ti& __ti, tuple<_Uj...>& __uj)
1874 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
1875 return __mu_expand(__ti, __uj, __indices());
1878 template <bool IsPh, class _Ti, class _Uj>
1879 struct __mu_return2 {};
1881 template <class _Ti, class _Uj>
1882 struct __mu_return2<true, _Ti, _Uj>
1884 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
1887 template <class _Ti, class _Uj>
1888 inline _LIBCPP_INLINE_VISIBILITY
1891 0 < is_placeholder<_Ti>::value,
1892 typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
1894 __mu(_Ti&, _Uj& __uj)
1896 const size_t _Indx = is_placeholder<_Ti>::value - 1;
1897 return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
1900 template <class _Ti, class _Uj>
1901 inline _LIBCPP_INLINE_VISIBILITY
1904 !is_bind_expression<_Ti>::value &&
1905 is_placeholder<_Ti>::value == 0 &&
1906 !__is_reference_wrapper<_Ti>::value,
1909 __mu(_Ti& __ti, _Uj&)
1914 template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
1916 struct ____mu_return;
1918 template <bool _Invokable, class _Ti, class ..._Uj>
1919 struct ____mu_return_invokable // false
1924 template <class _Ti, class ..._Uj>
1925 struct ____mu_return_invokable<true, _Ti, _Uj...>
1927 typedef typename __invoke_of<_Ti&, _Uj...>::type type;
1930 template <class _Ti, class ..._Uj>
1931 struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
1932 : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
1936 template <class _Ti, class _TupleUj>
1937 struct ____mu_return<_Ti, false, false, true, _TupleUj>
1939 typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
1940 _TupleUj>::type&& type;
1943 template <class _Ti, class _TupleUj>
1944 struct ____mu_return<_Ti, true, false, false, _TupleUj>
1946 typedef typename _Ti::type& type;
1949 template <class _Ti, class _TupleUj>
1950 struct ____mu_return<_Ti, false, false, false, _TupleUj>
1955 template <class _Ti, class _TupleUj>
1957 : public ____mu_return<_Ti,
1958 __is_reference_wrapper<_Ti>::value,
1959 is_bind_expression<_Ti>::value,
1960 0 < is_placeholder<_Ti>::value &&
1961 is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
1966 template <class _Fp, class _BoundArgs, class _TupleUj>
1967 struct _is_valid_bind_return
1969 static const bool value = false;
1972 template <class _Fp, class ..._BoundArgs, class _TupleUj>
1973 struct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
1975 static const bool value = __invokable<_Fp,
1976 typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
1979 template <class _Fp, class ..._BoundArgs, class _TupleUj>
1980 struct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
1982 static const bool value = __invokable<_Fp,
1983 typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
1986 template <class _Fp, class _BoundArgs, class _TupleUj,
1987 bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
1988 struct __bind_return;
1990 template <class _Fp, class ..._BoundArgs, class _TupleUj>
1991 struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
1993 typedef typename __invoke_of
1996 typename __mu_return
2004 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2005 struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
2007 typedef typename __invoke_of
2010 typename __mu_return
2018 template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
2019 inline _LIBCPP_INLINE_VISIBILITY
2020 typename __bind_return<_Fp, _BoundArgs, _Args>::type
2021 __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
2024 return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
2027 template<class _Fp, class ..._BoundArgs>
2029 : public __weak_result_type<typename decay<_Fp>::type>
2032 typedef typename decay<_Fp>::type _Fd;
2033 typedef tuple<typename decay<_BoundArgs>::type...> _Td;
2038 typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
2040 #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2042 _LIBCPP_INLINE_VISIBILITY
2043 __bind(const __bind& __b)
2045 __bound_args_(__b.__bound_args_) {}
2047 _LIBCPP_INLINE_VISIBILITY
2048 __bind& operator=(const __bind& __b)
2051 __bound_args_ = __b.__bound_args_;
2055 _LIBCPP_INLINE_VISIBILITY
2056 __bind(__bind&& __b)
2057 : __f_(_VSTD::move(__b.__f_)),
2058 __bound_args_(_VSTD::move(__b.__bound_args_)) {}
2060 _LIBCPP_INLINE_VISIBILITY
2061 __bind& operator=(__bind&& __b)
2063 __f_ = _VSTD::move(__b.__f_);
2064 __bound_args_ = _VSTD::move(__b.__bound_args_);
2068 #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2070 template <class _Gp, class ..._BA,
2071 class = typename enable_if
2073 is_constructible<_Fd, _Gp>::value &&
2074 !is_same<typename remove_reference<_Gp>::type,
2077 _LIBCPP_INLINE_VISIBILITY
2078 explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
2079 : __f_(_VSTD::forward<_Gp>(__f)),
2080 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
2082 template <class ..._Args>
2083 _LIBCPP_INLINE_VISIBILITY
2084 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
2085 operator()(_Args&& ...__args)
2087 return __apply_functor(__f_, __bound_args_, __indices(),
2088 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2091 template <class ..._Args>
2092 _LIBCPP_INLINE_VISIBILITY
2093 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
2094 operator()(_Args&& ...__args) const
2096 return __apply_functor(__f_, __bound_args_, __indices(),
2097 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2101 template<class _Fp, class ..._BoundArgs>
2102 struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
2104 template<class _Rp, class _Fp, class ..._BoundArgs>
2106 : public __bind<_Fp, _BoundArgs...>
2108 typedef __bind<_Fp, _BoundArgs...> base;
2109 typedef typename base::_Fd _Fd;
2110 typedef typename base::_Td _Td;
2112 typedef _Rp result_type;
2114 #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2116 _LIBCPP_INLINE_VISIBILITY
2117 __bind_r(const __bind_r& __b)
2118 : base(_VSTD::forward<const base&>(__b)) {}
2120 _LIBCPP_INLINE_VISIBILITY
2121 __bind_r& operator=(const __bind_r& __b)
2123 base::operator=(_VSTD::forward<const base&>(__b));
2127 _LIBCPP_INLINE_VISIBILITY
2128 __bind_r(__bind_r&& __b)
2129 : base(_VSTD::forward<base>(__b)) {}
2131 _LIBCPP_INLINE_VISIBILITY
2132 __bind_r& operator=(__bind_r&& __b)
2134 base::operator=(_VSTD::forward<base>(__b));
2138 #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2140 template <class _Gp, class ..._BA,
2141 class = typename enable_if
2143 is_constructible<_Fd, _Gp>::value &&
2144 !is_same<typename remove_reference<_Gp>::type,
2147 _LIBCPP_INLINE_VISIBILITY
2148 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
2149 : base(_VSTD::forward<_Gp>(__f),
2150 _VSTD::forward<_BA>(__bound_args)...) {}
2152 template <class ..._Args>
2153 _LIBCPP_INLINE_VISIBILITY
2156 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
2157 result_type>::value,
2160 operator()(_Args&& ...__args)
2162 return base::operator()(_VSTD::forward<_Args>(__args)...);
2165 template <class ..._Args>
2166 _LIBCPP_INLINE_VISIBILITY
2169 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
2170 result_type>::value,
2173 operator()(_Args&& ...__args) const
2175 return base::operator()(_VSTD::forward<_Args>(__args)...);
2179 template<class _Rp, class _Fp, class ..._BoundArgs>
2180 struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
2182 template<class _Fp, class ..._BoundArgs>
2183 inline _LIBCPP_INLINE_VISIBILITY
2184 __bind<_Fp, _BoundArgs...>
2185 bind(_Fp&& __f, _BoundArgs&&... __bound_args)
2187 typedef __bind<_Fp, _BoundArgs...> type;
2188 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2191 template<class _Rp, class _Fp, class ..._BoundArgs>
2192 inline _LIBCPP_INLINE_VISIBILITY
2193 __bind_r<_Rp, _Fp, _BoundArgs...>
2194 bind(_Fp&& __f, _BoundArgs&&... __bound_args)
2196 typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
2197 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2200 #endif // _LIBCPP_HAS_NO_VARIADICS
2203 struct _LIBCPP_TYPE_VIS_ONLY hash<bool>
2204 : public unary_function<bool, size_t>
2206 _LIBCPP_INLINE_VISIBILITY
2207 size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2211 struct _LIBCPP_TYPE_VIS_ONLY hash<char>
2212 : public unary_function<char, size_t>
2214 _LIBCPP_INLINE_VISIBILITY
2215 size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2219 struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
2220 : public unary_function<signed char, size_t>
2222 _LIBCPP_INLINE_VISIBILITY
2223 size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2227 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
2228 : public unary_function<unsigned char, size_t>
2230 _LIBCPP_INLINE_VISIBILITY
2231 size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2234 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
2237 struct _LIBCPP_TYPE_VIS_ONLY hash<char16_t>
2238 : public unary_function<char16_t, size_t>
2240 _LIBCPP_INLINE_VISIBILITY
2241 size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2245 struct _LIBCPP_TYPE_VIS_ONLY hash<char32_t>
2246 : public unary_function<char32_t, size_t>
2248 _LIBCPP_INLINE_VISIBILITY
2249 size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2252 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
2255 struct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t>
2256 : public unary_function<wchar_t, size_t>
2258 _LIBCPP_INLINE_VISIBILITY
2259 size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2263 struct _LIBCPP_TYPE_VIS_ONLY hash<short>
2264 : public unary_function<short, size_t>
2266 _LIBCPP_INLINE_VISIBILITY
2267 size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2271 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
2272 : public unary_function<unsigned short, size_t>
2274 _LIBCPP_INLINE_VISIBILITY
2275 size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2279 struct _LIBCPP_TYPE_VIS_ONLY hash<int>
2280 : public unary_function<int, size_t>
2282 _LIBCPP_INLINE_VISIBILITY
2283 size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2287 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
2288 : public unary_function<unsigned int, size_t>
2290 _LIBCPP_INLINE_VISIBILITY
2291 size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2295 struct _LIBCPP_TYPE_VIS_ONLY hash<long>
2296 : public unary_function<long, size_t>
2298 _LIBCPP_INLINE_VISIBILITY
2299 size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2303 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
2304 : public unary_function<unsigned long, size_t>
2306 _LIBCPP_INLINE_VISIBILITY
2307 size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2311 struct _LIBCPP_TYPE_VIS_ONLY hash<long long>
2312 : public __scalar_hash<long long>
2317 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
2318 : public __scalar_hash<unsigned long long>
2323 struct _LIBCPP_TYPE_VIS_ONLY hash<float>
2324 : public __scalar_hash<float>
2326 _LIBCPP_INLINE_VISIBILITY
2327 size_t operator()(float __v) const _NOEXCEPT
2329 // -0.0 and 0.0 should return same hash
2332 return __scalar_hash<float>::operator()(__v);
2337 struct _LIBCPP_TYPE_VIS_ONLY hash<double>
2338 : public __scalar_hash<double>
2340 _LIBCPP_INLINE_VISIBILITY
2341 size_t operator()(double __v) const _NOEXCEPT
2343 // -0.0 and 0.0 should return same hash
2346 return __scalar_hash<double>::operator()(__v);
2351 struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
2352 : public __scalar_hash<long double>
2354 _LIBCPP_INLINE_VISIBILITY
2355 size_t operator()(long double __v) const _NOEXCEPT
2357 // -0.0 and 0.0 should return same hash
2360 #if defined(__i386__)
2361 // Zero out padding bits
2378 return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d;
2379 #elif defined(__x86_64__)
2380 // Zero out padding bits
2393 return __u.__a ^ __u.__b;
2395 return __scalar_hash<long double>::operator()(__v);
2400 #if _LIBCPP_STD_VER > 11
2401 template <class _Tp>
2402 struct _LIBCPP_TYPE_VIS_ONLY hash
2403 : public unary_function<_Tp, size_t>
2405 static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types");
2407 _LIBCPP_INLINE_VISIBILITY
2408 size_t operator()(_Tp __v) const _NOEXCEPT
2410 typedef typename underlying_type<_Tp>::type type;
2411 return hash<type>{}(static_cast<type>(__v));
2416 // struct hash<T*> in <memory>
2418 _LIBCPP_END_NAMESPACE_STD
2420 #endif // _LIBCPP_FUNCTIONAL