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 F> unspecified not_fn(F&& f); // C++17
212 template<class T> struct is_bind_expression;
213 template<class T> struct is_placeholder;
215 // See C++14 20.9.9, Function object binders
216 template <class T> constexpr bool is_bind_expression_v
217 = is_bind_expression<T>::value; // C++17
218 template <class T> constexpr int is_placeholder_v
219 = is_placeholder<T>::value; // C++17
222 template<class Fn, class... BoundArgs>
223 unspecified bind(Fn&&, BoundArgs&&...);
224 template<class R, class Fn, class... BoundArgs>
225 unspecified bind(Fn&&, BoundArgs&&...);
227 namespace placeholders {
228 // M is the implementation-defined number of placeholders
229 extern unspecified _1;
230 extern unspecified _2;
234 extern unspecified _Mp;
237 template <class Operation>
239 : public unary_function<typename Operation::second_argument_type,
240 typename Operation::result_type>
244 typename Operation::first_argument_type value;
246 binder1st(const Operation& x, const typename Operation::first_argument_type y);
247 typename Operation::result_type operator()( typename Operation::second_argument_type& x) const;
248 typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
251 template <class Operation, class T>
252 binder1st<Operation> bind1st(const Operation& op, const T& x);
254 template <class Operation>
256 : public unary_function<typename Operation::first_argument_type,
257 typename Operation::result_type>
261 typename Operation::second_argument_type value;
263 binder2nd(const Operation& x, const typename Operation::second_argument_type y);
264 typename Operation::result_type operator()( typename Operation::first_argument_type& x) const;
265 typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
268 template <class Operation, class T>
269 binder2nd<Operation> bind2nd(const Operation& op, const T& x);
271 template <class Arg, class Result>
272 class pointer_to_unary_function : public unary_function<Arg, Result>
275 explicit pointer_to_unary_function(Result (*f)(Arg));
276 Result operator()(Arg x) const;
279 template <class Arg, class Result>
280 pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));
282 template <class Arg1, class Arg2, class Result>
283 class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
286 explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
287 Result operator()(Arg1 x, Arg2 y) const;
290 template <class Arg1, class Arg2, class Result>
291 pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));
293 template<class S, class T>
294 class mem_fun_t : public unary_function<T*, S>
297 explicit mem_fun_t(S (T::*p)());
298 S operator()(T* p) const;
301 template<class S, class T, class A>
302 class mem_fun1_t : public binary_function<T*, A, S>
305 explicit mem_fun1_t(S (T::*p)(A));
306 S operator()(T* p, A x) const;
309 template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)());
310 template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
312 template<class S, class T>
313 class mem_fun_ref_t : public unary_function<T, S>
316 explicit mem_fun_ref_t(S (T::*p)());
317 S operator()(T& p) const;
320 template<class S, class T, class A>
321 class mem_fun1_ref_t : public binary_function<T, A, S>
324 explicit mem_fun1_ref_t(S (T::*p)(A));
325 S operator()(T& p, A x) const;
328 template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)());
329 template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));
331 template <class S, class T>
332 class const_mem_fun_t : public unary_function<const T*, S>
335 explicit const_mem_fun_t(S (T::*p)() const);
336 S operator()(const T* p) const;
339 template <class S, class T, class A>
340 class const_mem_fun1_t : public binary_function<const T*, A, S>
343 explicit const_mem_fun1_t(S (T::*p)(A) const);
344 S operator()(const T* p, A x) const;
347 template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const);
348 template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);
350 template <class S, class T>
351 class const_mem_fun_ref_t : public unary_function<T, S>
354 explicit const_mem_fun_ref_t(S (T::*p)() const);
355 S operator()(const T& p) const;
358 template <class S, class T, class A>
359 class const_mem_fun1_ref_t : public binary_function<T, A, S>
362 explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
363 S operator()(const T& p, A x) const;
366 template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const);
367 template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
369 template<class R, class T> unspecified mem_fn(R T::*);
371 class bad_function_call
376 template<class> class function; // undefined
378 template<class R, class... ArgTypes>
379 class function<R(ArgTypes...)>
380 : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
381 // ArgTypes contains T1
382 : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
383 // ArgTypes contains T1 and T2
386 typedef R result_type;
388 // construct/copy/destroy:
390 function(nullptr_t) noexcept;
391 function(const function&);
392 function(function&&) noexcept;
395 template<Allocator Alloc>
396 function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17
397 template<Allocator Alloc>
398 function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17
399 template<Allocator Alloc>
400 function(allocator_arg_t, const Alloc&, const function&); // removed in C++17
401 template<Allocator Alloc>
402 function(allocator_arg_t, const Alloc&, function&&); // removed in C++17
403 template<class F, Allocator Alloc>
404 function(allocator_arg_t, const Alloc&, F); // removed in C++17
406 function& operator=(const function&);
407 function& operator=(function&&) noexcept;
408 function& operator=(nullptr_t) noexcept;
410 function& operator=(F&&);
412 function& operator=(reference_wrapper<F>) noexcept;
416 // function modifiers:
417 void swap(function&) noexcept;
418 template<class F, class Alloc>
419 void assign(F&&, const Alloc&); // Removed in C++17
421 // function capacity:
422 explicit operator bool() const noexcept;
424 // function invocation:
425 R operator()(ArgTypes...) const;
427 // function target access:
428 const std::type_info& target_type() const noexcept;
429 template <typename T> T* target() noexcept;
430 template <typename T> const T* target() const noexcept;
433 // Null pointer comparisons:
434 template <class R, class ... ArgTypes>
435 bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
437 template <class R, class ... ArgTypes>
438 bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
440 template <class R, class ... ArgTypes>
441 bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
443 template <class R, class ... ArgTypes>
444 bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
446 // specialized algorithms:
447 template <class R, class ... ArgTypes>
448 void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
450 template <class T> struct hash;
452 template <> struct hash<bool>;
453 template <> struct hash<char>;
454 template <> struct hash<signed char>;
455 template <> struct hash<unsigned char>;
456 template <> struct hash<char16_t>;
457 template <> struct hash<char32_t>;
458 template <> struct hash<wchar_t>;
459 template <> struct hash<short>;
460 template <> struct hash<unsigned short>;
461 template <> struct hash<int>;
462 template <> struct hash<unsigned int>;
463 template <> struct hash<long>;
464 template <> struct hash<long long>;
465 template <> struct hash<unsigned long>;
466 template <> struct hash<unsigned long long>;
468 template <> struct hash<float>;
469 template <> struct hash<double>;
470 template <> struct hash<long double>;
472 template<class T> struct hash<T*>;
476 POLICY: For non-variadic implementations, the number of arguments is limited
477 to 3. It is hoped that the need for non-variadic implementations
483 #include <type_traits>
489 #include <__functional_base>
491 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
492 #pragma GCC system_header
495 _LIBCPP_BEGIN_NAMESPACE_STD
497 #if _LIBCPP_STD_VER > 11
498 template <class _Tp = void>
502 struct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp>
504 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
505 _Tp operator()(const _Tp& __x, const _Tp& __y) const
509 #if _LIBCPP_STD_VER > 11
511 struct _LIBCPP_TEMPLATE_VIS plus<void>
513 template <class _T1, class _T2>
514 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
515 auto operator()(_T1&& __t, _T2&& __u) const
516 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
517 -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
518 { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
519 typedef void is_transparent;
524 #if _LIBCPP_STD_VER > 11
525 template <class _Tp = void>
529 struct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp>
531 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
532 _Tp operator()(const _Tp& __x, const _Tp& __y) const
536 #if _LIBCPP_STD_VER > 11
538 struct _LIBCPP_TEMPLATE_VIS minus<void>
540 template <class _T1, class _T2>
541 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
542 auto operator()(_T1&& __t, _T2&& __u) const
543 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
544 -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
545 { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
546 typedef void is_transparent;
551 #if _LIBCPP_STD_VER > 11
552 template <class _Tp = void>
556 struct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp>
558 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
559 _Tp operator()(const _Tp& __x, const _Tp& __y) const
563 #if _LIBCPP_STD_VER > 11
565 struct _LIBCPP_TEMPLATE_VIS multiplies<void>
567 template <class _T1, class _T2>
568 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
569 auto operator()(_T1&& __t, _T2&& __u) const
570 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
571 -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
572 { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
573 typedef void is_transparent;
578 #if _LIBCPP_STD_VER > 11
579 template <class _Tp = void>
583 struct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp>
585 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
586 _Tp operator()(const _Tp& __x, const _Tp& __y) const
590 #if _LIBCPP_STD_VER > 11
592 struct _LIBCPP_TEMPLATE_VIS divides<void>
594 template <class _T1, class _T2>
595 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
596 auto operator()(_T1&& __t, _T2&& __u) const
597 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
598 -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
599 { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
600 typedef void is_transparent;
605 #if _LIBCPP_STD_VER > 11
606 template <class _Tp = void>
610 struct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp>
612 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
613 _Tp operator()(const _Tp& __x, const _Tp& __y) const
617 #if _LIBCPP_STD_VER > 11
619 struct _LIBCPP_TEMPLATE_VIS modulus<void>
621 template <class _T1, class _T2>
622 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
623 auto operator()(_T1&& __t, _T2&& __u) const
624 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
625 -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
626 { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
627 typedef void is_transparent;
632 #if _LIBCPP_STD_VER > 11
633 template <class _Tp = void>
637 struct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp>
639 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
640 _Tp operator()(const _Tp& __x) const
644 #if _LIBCPP_STD_VER > 11
646 struct _LIBCPP_TEMPLATE_VIS negate<void>
649 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
650 auto operator()(_Tp&& __x) const
651 _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
652 -> decltype (- _VSTD::forward<_Tp>(__x))
653 { return - _VSTD::forward<_Tp>(__x); }
654 typedef void is_transparent;
659 #if _LIBCPP_STD_VER > 11
660 template <class _Tp = void>
664 struct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool>
666 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
667 bool operator()(const _Tp& __x, const _Tp& __y) const
671 #if _LIBCPP_STD_VER > 11
673 struct _LIBCPP_TEMPLATE_VIS equal_to<void>
675 template <class _T1, class _T2>
676 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
677 auto operator()(_T1&& __t, _T2&& __u) const
678 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
679 -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
680 { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
681 typedef void is_transparent;
686 #if _LIBCPP_STD_VER > 11
687 template <class _Tp = void>
691 struct _LIBCPP_TEMPLATE_VIS not_equal_to : binary_function<_Tp, _Tp, bool>
693 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
694 bool operator()(const _Tp& __x, const _Tp& __y) const
698 #if _LIBCPP_STD_VER > 11
700 struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
702 template <class _T1, class _T2>
703 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
704 auto operator()(_T1&& __t, _T2&& __u) const
705 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
706 -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
707 { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
708 typedef void is_transparent;
713 #if _LIBCPP_STD_VER > 11
714 template <class _Tp = void>
718 struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
720 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
721 bool operator()(const _Tp& __x, const _Tp& __y) const
725 #if _LIBCPP_STD_VER > 11
727 struct _LIBCPP_TEMPLATE_VIS greater<void>
729 template <class _T1, class _T2>
730 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
731 auto operator()(_T1&& __t, _T2&& __u) const
732 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
733 -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
734 { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
735 typedef void is_transparent;
740 // less in <__functional_base>
742 #if _LIBCPP_STD_VER > 11
743 template <class _Tp = void>
747 struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
749 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
750 bool operator()(const _Tp& __x, const _Tp& __y) const
754 #if _LIBCPP_STD_VER > 11
756 struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
758 template <class _T1, class _T2>
759 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
760 auto operator()(_T1&& __t, _T2&& __u) const
761 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
762 -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
763 { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
764 typedef void is_transparent;
769 #if _LIBCPP_STD_VER > 11
770 template <class _Tp = void>
774 struct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool>
776 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
777 bool operator()(const _Tp& __x, const _Tp& __y) const
781 #if _LIBCPP_STD_VER > 11
783 struct _LIBCPP_TEMPLATE_VIS less_equal<void>
785 template <class _T1, class _T2>
786 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
787 auto operator()(_T1&& __t, _T2&& __u) const
788 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
789 -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
790 { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
791 typedef void is_transparent;
796 #if _LIBCPP_STD_VER > 11
797 template <class _Tp = void>
801 struct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool>
803 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
804 bool operator()(const _Tp& __x, const _Tp& __y) const
808 #if _LIBCPP_STD_VER > 11
810 struct _LIBCPP_TEMPLATE_VIS logical_and<void>
812 template <class _T1, class _T2>
813 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
814 auto operator()(_T1&& __t, _T2&& __u) const
815 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
816 -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
817 { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
818 typedef void is_transparent;
823 #if _LIBCPP_STD_VER > 11
824 template <class _Tp = void>
828 struct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool>
830 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
831 bool operator()(const _Tp& __x, const _Tp& __y) const
835 #if _LIBCPP_STD_VER > 11
837 struct _LIBCPP_TEMPLATE_VIS logical_or<void>
839 template <class _T1, class _T2>
840 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
841 auto operator()(_T1&& __t, _T2&& __u) const
842 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
843 -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
844 { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
845 typedef void is_transparent;
850 #if _LIBCPP_STD_VER > 11
851 template <class _Tp = void>
855 struct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool>
857 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
858 bool operator()(const _Tp& __x) const
862 #if _LIBCPP_STD_VER > 11
864 struct _LIBCPP_TEMPLATE_VIS logical_not<void>
867 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
868 auto operator()(_Tp&& __x) const
869 _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
870 -> decltype (!_VSTD::forward<_Tp>(__x))
871 { return !_VSTD::forward<_Tp>(__x); }
872 typedef void is_transparent;
877 #if _LIBCPP_STD_VER > 11
878 template <class _Tp = void>
882 struct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp>
884 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
885 _Tp operator()(const _Tp& __x, const _Tp& __y) const
889 #if _LIBCPP_STD_VER > 11
891 struct _LIBCPP_TEMPLATE_VIS bit_and<void>
893 template <class _T1, class _T2>
894 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
895 auto operator()(_T1&& __t, _T2&& __u) const
896 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
897 -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
898 { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
899 typedef void is_transparent;
904 #if _LIBCPP_STD_VER > 11
905 template <class _Tp = void>
909 struct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp>
911 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
912 _Tp operator()(const _Tp& __x, const _Tp& __y) const
916 #if _LIBCPP_STD_VER > 11
918 struct _LIBCPP_TEMPLATE_VIS bit_or<void>
920 template <class _T1, class _T2>
921 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
922 auto operator()(_T1&& __t, _T2&& __u) const
923 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
924 -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
925 { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
926 typedef void is_transparent;
931 #if _LIBCPP_STD_VER > 11
932 template <class _Tp = void>
936 struct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp>
938 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
939 _Tp operator()(const _Tp& __x, const _Tp& __y) const
943 #if _LIBCPP_STD_VER > 11
945 struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
947 template <class _T1, class _T2>
948 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
949 auto operator()(_T1&& __t, _T2&& __u) const
950 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
951 -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
952 { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
953 typedef void is_transparent;
958 #if _LIBCPP_STD_VER > 11
959 template <class _Tp = void>
960 struct _LIBCPP_TEMPLATE_VIS bit_not : unary_function<_Tp, _Tp>
962 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
963 _Tp operator()(const _Tp& __x) const
968 struct _LIBCPP_TEMPLATE_VIS bit_not<void>
971 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
972 auto operator()(_Tp&& __x) const
973 _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
974 -> decltype (~_VSTD::forward<_Tp>(__x))
975 { return ~_VSTD::forward<_Tp>(__x); }
976 typedef void is_transparent;
980 template <class _Predicate>
981 class _LIBCPP_TEMPLATE_VIS unary_negate
982 : public unary_function<typename _Predicate::argument_type, bool>
986 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
987 explicit unary_negate(const _Predicate& __pred)
989 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
990 bool operator()(const typename _Predicate::argument_type& __x) const
991 {return !__pred_(__x);}
994 template <class _Predicate>
995 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
996 unary_negate<_Predicate>
997 not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
999 template <class _Predicate>
1000 class _LIBCPP_TEMPLATE_VIS binary_negate
1001 : public binary_function<typename _Predicate::first_argument_type,
1002 typename _Predicate::second_argument_type,
1007 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
1008 binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
1010 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1011 bool operator()(const typename _Predicate::first_argument_type& __x,
1012 const typename _Predicate::second_argument_type& __y) const
1013 {return !__pred_(__x, __y);}
1016 template <class _Predicate>
1017 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1018 binary_negate<_Predicate>
1019 not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
1021 template <class __Operation>
1022 class _LIBCPP_TEMPLATE_VIS binder1st
1023 : public unary_function<typename __Operation::second_argument_type,
1024 typename __Operation::result_type>
1028 typename __Operation::first_argument_type value;
1030 _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
1031 const typename __Operation::first_argument_type __y)
1032 : op(__x), value(__y) {}
1033 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1034 (typename __Operation::second_argument_type& __x) const
1035 {return op(value, __x);}
1036 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1037 (const typename __Operation::second_argument_type& __x) const
1038 {return op(value, __x);}
1041 template <class __Operation, class _Tp>
1042 inline _LIBCPP_INLINE_VISIBILITY
1043 binder1st<__Operation>
1044 bind1st(const __Operation& __op, const _Tp& __x)
1045 {return binder1st<__Operation>(__op, __x);}
1047 template <class __Operation>
1048 class _LIBCPP_TEMPLATE_VIS binder2nd
1049 : public unary_function<typename __Operation::first_argument_type,
1050 typename __Operation::result_type>
1054 typename __Operation::second_argument_type value;
1056 _LIBCPP_INLINE_VISIBILITY
1057 binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
1058 : op(__x), value(__y) {}
1059 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1060 ( typename __Operation::first_argument_type& __x) const
1061 {return op(__x, value);}
1062 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1063 (const typename __Operation::first_argument_type& __x) const
1064 {return op(__x, value);}
1067 template <class __Operation, class _Tp>
1068 inline _LIBCPP_INLINE_VISIBILITY
1069 binder2nd<__Operation>
1070 bind2nd(const __Operation& __op, const _Tp& __x)
1071 {return binder2nd<__Operation>(__op, __x);}
1073 template <class _Arg, class _Result>
1074 class _LIBCPP_TEMPLATE_VIS pointer_to_unary_function
1075 : public unary_function<_Arg, _Result>
1077 _Result (*__f_)(_Arg);
1079 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
1081 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
1085 template <class _Arg, class _Result>
1086 inline _LIBCPP_INLINE_VISIBILITY
1087 pointer_to_unary_function<_Arg,_Result>
1088 ptr_fun(_Result (*__f)(_Arg))
1089 {return pointer_to_unary_function<_Arg,_Result>(__f);}
1091 template <class _Arg1, class _Arg2, class _Result>
1092 class _LIBCPP_TEMPLATE_VIS pointer_to_binary_function
1093 : public binary_function<_Arg1, _Arg2, _Result>
1095 _Result (*__f_)(_Arg1, _Arg2);
1097 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
1099 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
1100 {return __f_(__x, __y);}
1103 template <class _Arg1, class _Arg2, class _Result>
1104 inline _LIBCPP_INLINE_VISIBILITY
1105 pointer_to_binary_function<_Arg1,_Arg2,_Result>
1106 ptr_fun(_Result (*__f)(_Arg1,_Arg2))
1107 {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
1109 template<class _Sp, class _Tp>
1110 class _LIBCPP_TEMPLATE_VIS mem_fun_t : public unary_function<_Tp*, _Sp>
1114 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
1116 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
1117 {return (__p->*__p_)();}
1120 template<class _Sp, class _Tp, class _Ap>
1121 class _LIBCPP_TEMPLATE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
1123 _Sp (_Tp::*__p_)(_Ap);
1125 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
1127 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
1128 {return (__p->*__p_)(__x);}
1131 template<class _Sp, class _Tp>
1132 inline _LIBCPP_INLINE_VISIBILITY
1134 mem_fun(_Sp (_Tp::*__f)())
1135 {return mem_fun_t<_Sp,_Tp>(__f);}
1137 template<class _Sp, class _Tp, class _Ap>
1138 inline _LIBCPP_INLINE_VISIBILITY
1139 mem_fun1_t<_Sp,_Tp,_Ap>
1140 mem_fun(_Sp (_Tp::*__f)(_Ap))
1141 {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1143 template<class _Sp, class _Tp>
1144 class _LIBCPP_TEMPLATE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp>
1148 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
1150 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
1151 {return (__p.*__p_)();}
1154 template<class _Sp, class _Tp, class _Ap>
1155 class _LIBCPP_TEMPLATE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
1157 _Sp (_Tp::*__p_)(_Ap);
1159 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
1161 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
1162 {return (__p.*__p_)(__x);}
1165 template<class _Sp, class _Tp>
1166 inline _LIBCPP_INLINE_VISIBILITY
1167 mem_fun_ref_t<_Sp,_Tp>
1168 mem_fun_ref(_Sp (_Tp::*__f)())
1169 {return mem_fun_ref_t<_Sp,_Tp>(__f);}
1171 template<class _Sp, class _Tp, class _Ap>
1172 inline _LIBCPP_INLINE_VISIBILITY
1173 mem_fun1_ref_t<_Sp,_Tp,_Ap>
1174 mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
1175 {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1177 template <class _Sp, class _Tp>
1178 class _LIBCPP_TEMPLATE_VIS const_mem_fun_t : public unary_function<const _Tp*, _Sp>
1180 _Sp (_Tp::*__p_)() const;
1182 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
1184 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
1185 {return (__p->*__p_)();}
1188 template <class _Sp, class _Tp, class _Ap>
1189 class _LIBCPP_TEMPLATE_VIS const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
1191 _Sp (_Tp::*__p_)(_Ap) const;
1193 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
1195 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
1196 {return (__p->*__p_)(__x);}
1199 template <class _Sp, class _Tp>
1200 inline _LIBCPP_INLINE_VISIBILITY
1201 const_mem_fun_t<_Sp,_Tp>
1202 mem_fun(_Sp (_Tp::*__f)() const)
1203 {return const_mem_fun_t<_Sp,_Tp>(__f);}
1205 template <class _Sp, class _Tp, class _Ap>
1206 inline _LIBCPP_INLINE_VISIBILITY
1207 const_mem_fun1_t<_Sp,_Tp,_Ap>
1208 mem_fun(_Sp (_Tp::*__f)(_Ap) const)
1209 {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1211 template <class _Sp, class _Tp>
1212 class _LIBCPP_TEMPLATE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
1214 _Sp (_Tp::*__p_)() const;
1216 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
1218 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
1219 {return (__p.*__p_)();}
1222 template <class _Sp, class _Tp, class _Ap>
1223 class _LIBCPP_TEMPLATE_VIS const_mem_fun1_ref_t
1224 : public binary_function<_Tp, _Ap, _Sp>
1226 _Sp (_Tp::*__p_)(_Ap) const;
1228 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
1230 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
1231 {return (__p.*__p_)(__x);}
1234 template <class _Sp, class _Tp>
1235 inline _LIBCPP_INLINE_VISIBILITY
1236 const_mem_fun_ref_t<_Sp,_Tp>
1237 mem_fun_ref(_Sp (_Tp::*__f)() const)
1238 {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
1240 template <class _Sp, class _Tp, class _Ap>
1241 inline _LIBCPP_INLINE_VISIBILITY
1242 const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
1243 mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
1244 {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1246 ////////////////////////////////////////////////////////////////////////////////
1248 //==============================================================================
1250 template <class _Tp>
1252 : public __weak_result_type<_Tp>
1261 _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
1263 #ifndef _LIBCPP_HAS_NO_VARIADICS
1265 template <class... _ArgTypes>
1266 _LIBCPP_INLINE_VISIBILITY
1267 typename __invoke_return<type, _ArgTypes...>::type
1268 operator() (_ArgTypes&&... __args) const {
1269 return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
1273 template <class _A0>
1274 _LIBCPP_INLINE_VISIBILITY
1275 typename __invoke_return0<type, _A0>::type
1276 operator() (_A0& __a0) const {
1277 return __invoke(__f_, __a0);
1280 template <class _A0>
1281 _LIBCPP_INLINE_VISIBILITY
1282 typename __invoke_return0<type, _A0 const>::type
1283 operator() (_A0 const& __a0) const {
1284 return __invoke(__f_, __a0);
1287 template <class _A0, class _A1>
1288 _LIBCPP_INLINE_VISIBILITY
1289 typename __invoke_return1<type, _A0, _A1>::type
1290 operator() (_A0& __a0, _A1& __a1) const {
1291 return __invoke(__f_, __a0, __a1);
1294 template <class _A0, class _A1>
1295 _LIBCPP_INLINE_VISIBILITY
1296 typename __invoke_return1<type, _A0 const, _A1>::type
1297 operator() (_A0 const& __a0, _A1& __a1) const {
1298 return __invoke(__f_, __a0, __a1);
1301 template <class _A0, class _A1>
1302 _LIBCPP_INLINE_VISIBILITY
1303 typename __invoke_return1<type, _A0, _A1 const>::type
1304 operator() (_A0& __a0, _A1 const& __a1) const {
1305 return __invoke(__f_, __a0, __a1);
1308 template <class _A0, class _A1>
1309 _LIBCPP_INLINE_VISIBILITY
1310 typename __invoke_return1<type, _A0 const, _A1 const>::type
1311 operator() (_A0 const& __a0, _A1 const& __a1) const {
1312 return __invoke(__f_, __a0, __a1);
1315 template <class _A0, class _A1, class _A2>
1316 _LIBCPP_INLINE_VISIBILITY
1317 typename __invoke_return2<type, _A0, _A1, _A2>::type
1318 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
1319 return __invoke(__f_, __a0, __a1, __a2);
1322 template <class _A0, class _A1, class _A2>
1323 _LIBCPP_INLINE_VISIBILITY
1324 typename __invoke_return2<type, _A0 const, _A1, _A2>::type
1325 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
1326 return __invoke(__f_, __a0, __a1, __a2);
1329 template <class _A0, class _A1, class _A2>
1330 _LIBCPP_INLINE_VISIBILITY
1331 typename __invoke_return2<type, _A0, _A1 const, _A2>::type
1332 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
1333 return __invoke(__f_, __a0, __a1, __a2);
1336 template <class _A0, class _A1, class _A2>
1337 _LIBCPP_INLINE_VISIBILITY
1338 typename __invoke_return2<type, _A0, _A1, _A2 const>::type
1339 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
1340 return __invoke(__f_, __a0, __a1, __a2);
1343 template <class _A0, class _A1, class _A2>
1344 _LIBCPP_INLINE_VISIBILITY
1345 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
1346 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
1347 return __invoke(__f_, __a0, __a1, __a2);
1350 template <class _A0, class _A1, class _A2>
1351 _LIBCPP_INLINE_VISIBILITY
1352 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
1353 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
1354 return __invoke(__f_, __a0, __a1, __a2);
1357 template <class _A0, class _A1, class _A2>
1358 _LIBCPP_INLINE_VISIBILITY
1359 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
1360 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
1361 return __invoke(__f_, __a0, __a1, __a2);
1364 template <class _A0, class _A1, class _A2>
1365 _LIBCPP_INLINE_VISIBILITY
1366 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
1367 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
1368 return __invoke(__f_, __a0, __a1, __a2);
1373 template<class _Rp, class _Tp>
1374 inline _LIBCPP_INLINE_VISIBILITY
1375 __mem_fn<_Rp _Tp::*>
1376 mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
1378 return __mem_fn<_Rp _Tp::*>(__pm);
1381 ////////////////////////////////////////////////////////////////////////////////
1383 //==============================================================================
1385 // bad_function_call
1387 class _LIBCPP_EXCEPTION_ABI bad_function_call
1392 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
1393 void __throw_bad_function_call()
1395 #ifndef _LIBCPP_NO_EXCEPTIONS
1396 throw bad_function_call();
1402 template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined
1404 namespace __function
1408 struct __maybe_derive_from_unary_function
1412 template<class _Rp, class _A1>
1413 struct __maybe_derive_from_unary_function<_Rp(_A1)>
1414 : public unary_function<_A1, _Rp>
1419 struct __maybe_derive_from_binary_function
1423 template<class _Rp, class _A1, class _A2>
1424 struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
1425 : public binary_function<_A1, _A2, _Rp>
1429 template <class _Fp>
1430 _LIBCPP_INLINE_VISIBILITY
1431 bool __not_null(_Fp const&) { return true; }
1433 template <class _Fp>
1434 _LIBCPP_INLINE_VISIBILITY
1435 bool __not_null(_Fp* __ptr) { return __ptr; }
1437 template <class _Ret, class _Class>
1438 _LIBCPP_INLINE_VISIBILITY
1439 bool __not_null(_Ret _Class::*__ptr) { return __ptr; }
1441 template <class _Fp>
1442 _LIBCPP_INLINE_VISIBILITY
1443 bool __not_null(function<_Fp> const& __f) { return !!__f; }
1445 } // namespace __function
1447 #ifndef _LIBCPP_HAS_NO_VARIADICS
1449 namespace __function {
1451 template<class _Fp> class __base;
1453 template<class _Rp, class ..._ArgTypes>
1454 class __base<_Rp(_ArgTypes...)>
1456 __base(const __base&);
1457 __base& operator=(const __base&);
1459 _LIBCPP_INLINE_VISIBILITY __base() {}
1460 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
1461 virtual __base* __clone() const = 0;
1462 virtual void __clone(__base*) const = 0;
1463 virtual void destroy() _NOEXCEPT = 0;
1464 virtual void destroy_deallocate() _NOEXCEPT = 0;
1465 virtual _Rp operator()(_ArgTypes&& ...) = 0;
1466 #ifndef _LIBCPP_NO_RTTI
1467 virtual const void* target(const type_info&) const _NOEXCEPT = 0;
1468 virtual const std::type_info& target_type() const _NOEXCEPT = 0;
1469 #endif // _LIBCPP_NO_RTTI
1472 template<class _FD, class _Alloc, class _FB> class __func;
1474 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1475 class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
1476 : public __base<_Rp(_ArgTypes...)>
1478 __compressed_pair<_Fp, _Alloc> __f_;
1480 _LIBCPP_INLINE_VISIBILITY
1481 explicit __func(_Fp&& __f)
1482 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1483 _VSTD::forward_as_tuple()) {}
1484 _LIBCPP_INLINE_VISIBILITY
1485 explicit __func(const _Fp& __f, const _Alloc& __a)
1486 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1487 _VSTD::forward_as_tuple(__a)) {}
1489 _LIBCPP_INLINE_VISIBILITY
1490 explicit __func(const _Fp& __f, _Alloc&& __a)
1491 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1492 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1494 _LIBCPP_INLINE_VISIBILITY
1495 explicit __func(_Fp&& __f, _Alloc&& __a)
1496 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1497 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1498 virtual __base<_Rp(_ArgTypes...)>* __clone() const;
1499 virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
1500 virtual void destroy() _NOEXCEPT;
1501 virtual void destroy_deallocate() _NOEXCEPT;
1502 virtual _Rp operator()(_ArgTypes&& ... __arg);
1503 #ifndef _LIBCPP_NO_RTTI
1504 virtual const void* target(const type_info&) const _NOEXCEPT;
1505 virtual const std::type_info& target_type() const _NOEXCEPT;
1506 #endif // _LIBCPP_NO_RTTI
1509 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1510 __base<_Rp(_ArgTypes...)>*
1511 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
1513 typedef allocator_traits<_Alloc> __alloc_traits;
1514 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1515 _Ap __a(__f_.second());
1516 typedef __allocator_destructor<_Ap> _Dp;
1517 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1518 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
1519 return __hold.release();
1522 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1524 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
1526 ::new (__p) __func(__f_.first(), __f_.second());
1529 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1531 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
1533 __f_.~__compressed_pair<_Fp, _Alloc>();
1536 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1538 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
1540 typedef allocator_traits<_Alloc> __alloc_traits;
1541 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1542 _Ap __a(__f_.second());
1543 __f_.~__compressed_pair<_Fp, _Alloc>();
1544 __a.deallocate(this, 1);
1547 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1549 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
1551 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1552 return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
1555 #ifndef _LIBCPP_NO_RTTI
1557 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1559 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
1561 if (__ti == typeid(_Fp))
1562 return &__f_.first();
1563 return (const void*)0;
1566 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1567 const std::type_info&
1568 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1573 #endif // _LIBCPP_NO_RTTI
1577 template<class _Rp, class ..._ArgTypes>
1578 class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
1579 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
1580 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
1582 typedef __function::__base<_Rp(_ArgTypes...)> __base;
1583 typename aligned_storage<3*sizeof(void*)>::type __buf_;
1586 _LIBCPP_NO_CFI static __base *__as_base(void *p) {
1587 return reinterpret_cast<__base*>(p);
1590 template <class _Fp, bool = !is_same<_Fp, function>::value &&
1591 __invokable<_Fp&, _ArgTypes...>::value>
1593 template <class _Fp>
1594 struct __callable<_Fp, true>
1596 static const bool value = is_same<void, _Rp>::value ||
1597 is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
1600 template <class _Fp>
1601 struct __callable<_Fp, false>
1603 static const bool value = false;
1606 typedef _Rp result_type;
1608 // construct/copy/destroy:
1609 _LIBCPP_INLINE_VISIBILITY
1610 function() _NOEXCEPT : __f_(0) {}
1611 _LIBCPP_INLINE_VISIBILITY
1612 function(nullptr_t) _NOEXCEPT : __f_(0) {}
1613 function(const function&);
1614 function(function&&) _NOEXCEPT;
1615 template<class _Fp, class = typename enable_if<
1616 __callable<_Fp>::value && !is_same<_Fp, function>::value
1620 #if _LIBCPP_STD_VER <= 14
1621 template<class _Alloc>
1622 _LIBCPP_INLINE_VISIBILITY
1623 function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
1624 template<class _Alloc>
1625 _LIBCPP_INLINE_VISIBILITY
1626 function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
1627 template<class _Alloc>
1628 function(allocator_arg_t, const _Alloc&, const function&);
1629 template<class _Alloc>
1630 function(allocator_arg_t, const _Alloc&, function&&);
1631 template<class _Fp, class _Alloc, class = typename enable_if<__callable<_Fp>::value>::type>
1632 function(allocator_arg_t, const _Alloc& __a, _Fp __f);
1635 function& operator=(const function&);
1636 function& operator=(function&&) _NOEXCEPT;
1637 function& operator=(nullptr_t) _NOEXCEPT;
1641 __callable<typename decay<_Fp>::type>::value &&
1642 !is_same<typename remove_reference<_Fp>::type, function>::value,
1649 // function modifiers:
1650 void swap(function&) _NOEXCEPT;
1652 #if _LIBCPP_STD_VER <= 14
1653 template<class _Fp, class _Alloc>
1654 _LIBCPP_INLINE_VISIBILITY
1655 void assign(_Fp&& __f, const _Alloc& __a)
1656 {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
1659 // function capacity:
1660 _LIBCPP_INLINE_VISIBILITY
1661 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
1663 // deleted overloads close possible hole in the type system
1664 template<class _R2, class... _ArgTypes2>
1665 bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
1666 template<class _R2, class... _ArgTypes2>
1667 bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
1669 // function invocation:
1670 _Rp operator()(_ArgTypes...) const;
1672 #ifndef _LIBCPP_NO_RTTI
1673 // function target access:
1674 const std::type_info& target_type() const _NOEXCEPT;
1675 template <typename _Tp> _Tp* target() _NOEXCEPT;
1676 template <typename _Tp> const _Tp* target() const _NOEXCEPT;
1677 #endif // _LIBCPP_NO_RTTI
1680 template<class _Rp, class ..._ArgTypes>
1681 function<_Rp(_ArgTypes...)>::function(const function& __f)
1685 else if ((void *)__f.__f_ == &__f.__buf_)
1687 __f_ = __as_base(&__buf_);
1688 __f.__f_->__clone(__f_);
1691 __f_ = __f.__f_->__clone();
1694 #if _LIBCPP_STD_VER <= 14
1695 template<class _Rp, class ..._ArgTypes>
1696 template <class _Alloc>
1697 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1698 const function& __f)
1702 else if ((void *)__f.__f_ == &__f.__buf_)
1704 __f_ = __as_base(&__buf_);
1705 __f.__f_->__clone(__f_);
1708 __f_ = __f.__f_->__clone();
1712 template<class _Rp, class ..._ArgTypes>
1713 function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
1717 else if ((void *)__f.__f_ == &__f.__buf_)
1719 __f_ = __as_base(&__buf_);
1720 __f.__f_->__clone(__f_);
1729 #if _LIBCPP_STD_VER <= 14
1730 template<class _Rp, class ..._ArgTypes>
1731 template <class _Alloc>
1732 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1737 else if ((void *)__f.__f_ == &__f.__buf_)
1739 __f_ = __as_base(&__buf_);
1740 __f.__f_->__clone(__f_);
1750 template<class _Rp, class ..._ArgTypes>
1751 template <class _Fp, class>
1752 function<_Rp(_ArgTypes...)>::function(_Fp __f)
1755 if (__function::__not_null(__f))
1757 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
1758 if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
1760 __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f));
1764 typedef allocator<_FF> _Ap;
1766 typedef __allocator_destructor<_Ap> _Dp;
1767 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1768 ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
1769 __f_ = __hold.release();
1774 #if _LIBCPP_STD_VER <= 14
1775 template<class _Rp, class ..._ArgTypes>
1776 template <class _Fp, class _Alloc, class>
1777 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f)
1780 typedef allocator_traits<_Alloc> __alloc_traits;
1781 if (__function::__not_null(__f))
1783 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
1784 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1786 if (sizeof(_FF) <= sizeof(__buf_) &&
1787 is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
1789 __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a));
1793 typedef __allocator_destructor<_Ap> _Dp;
1794 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1795 ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
1796 __f_ = __hold.release();
1802 template<class _Rp, class ..._ArgTypes>
1803 function<_Rp(_ArgTypes...)>&
1804 function<_Rp(_ArgTypes...)>::operator=(const function& __f)
1806 function(__f).swap(*this);
1810 template<class _Rp, class ..._ArgTypes>
1811 function<_Rp(_ArgTypes...)>&
1812 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
1814 if ((void *)__f_ == &__buf_)
1817 __f_->destroy_deallocate();
1821 else if ((void *)__f.__f_ == &__f.__buf_)
1823 __f_ = __as_base(&__buf_);
1824 __f.__f_->__clone(__f_);
1834 template<class _Rp, class ..._ArgTypes>
1835 function<_Rp(_ArgTypes...)>&
1836 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
1838 if ((void *)__f_ == &__buf_)
1841 __f_->destroy_deallocate();
1846 template<class _Rp, class ..._ArgTypes>
1847 template <class _Fp>
1850 function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
1851 !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
1852 function<_Rp(_ArgTypes...)>&
1854 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
1856 function(_VSTD::forward<_Fp>(__f)).swap(*this);
1860 template<class _Rp, class ..._ArgTypes>
1861 function<_Rp(_ArgTypes...)>::~function()
1863 if ((void *)__f_ == &__buf_)
1866 __f_->destroy_deallocate();
1869 template<class _Rp, class ..._ArgTypes>
1871 function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
1873 if (_VSTD::addressof(__f) == this)
1875 if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_)
1877 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1878 __base* __t = __as_base(&__tempbuf);
1882 __f.__f_->__clone(__as_base(&__buf_));
1883 __f.__f_->destroy();
1885 __f_ = __as_base(&__buf_);
1886 __t->__clone(__as_base(&__f.__buf_));
1888 __f.__f_ = __as_base(&__f.__buf_);
1890 else if ((void *)__f_ == &__buf_)
1892 __f_->__clone(__as_base(&__f.__buf_));
1895 __f.__f_ = __as_base(&__f.__buf_);
1897 else if ((void *)__f.__f_ == &__f.__buf_)
1899 __f.__f_->__clone(__as_base(&__buf_));
1900 __f.__f_->destroy();
1902 __f_ = __as_base(&__buf_);
1905 _VSTD::swap(__f_, __f.__f_);
1908 template<class _Rp, class ..._ArgTypes>
1910 function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
1913 __throw_bad_function_call();
1914 return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
1917 #ifndef _LIBCPP_NO_RTTI
1919 template<class _Rp, class ..._ArgTypes>
1920 const std::type_info&
1921 function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1924 return typeid(void);
1925 return __f_->target_type();
1928 template<class _Rp, class ..._ArgTypes>
1929 template <typename _Tp>
1931 function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
1935 return (_Tp*)__f_->target(typeid(_Tp));
1938 template<class _Rp, class ..._ArgTypes>
1939 template <typename _Tp>
1941 function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
1944 return (const _Tp*)0;
1945 return (const _Tp*)__f_->target(typeid(_Tp));
1948 #endif // _LIBCPP_NO_RTTI
1950 template <class _Rp, class... _ArgTypes>
1951 inline _LIBCPP_INLINE_VISIBILITY
1953 operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
1955 template <class _Rp, class... _ArgTypes>
1956 inline _LIBCPP_INLINE_VISIBILITY
1958 operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
1960 template <class _Rp, class... _ArgTypes>
1961 inline _LIBCPP_INLINE_VISIBILITY
1963 operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
1965 template <class _Rp, class... _ArgTypes>
1966 inline _LIBCPP_INLINE_VISIBILITY
1968 operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
1970 template <class _Rp, class... _ArgTypes>
1971 inline _LIBCPP_INLINE_VISIBILITY
1973 swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
1974 {return __x.swap(__y);}
1976 #else // _LIBCPP_HAS_NO_VARIADICS
1978 #include <__functional_03>
1982 ////////////////////////////////////////////////////////////////////////////////
1984 //==============================================================================
1986 template<class _Tp> struct __is_bind_expression : public false_type {};
1987 template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression
1988 : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
1990 #if _LIBCPP_STD_VER > 14
1991 template <class _Tp>
1992 constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
1995 template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
1996 template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder
1997 : public __is_placeholder<typename remove_cv<_Tp>::type> {};
1999 #if _LIBCPP_STD_VER > 14
2000 template <class _Tp>
2001 constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
2004 namespace placeholders
2007 template <int _Np> struct __ph {};
2009 #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
2010 _LIBCPP_FUNC_VIS extern const __ph<1> _1;
2011 _LIBCPP_FUNC_VIS extern const __ph<2> _2;
2012 _LIBCPP_FUNC_VIS extern const __ph<3> _3;
2013 _LIBCPP_FUNC_VIS extern const __ph<4> _4;
2014 _LIBCPP_FUNC_VIS extern const __ph<5> _5;
2015 _LIBCPP_FUNC_VIS extern const __ph<6> _6;
2016 _LIBCPP_FUNC_VIS extern const __ph<7> _7;
2017 _LIBCPP_FUNC_VIS extern const __ph<8> _8;
2018 _LIBCPP_FUNC_VIS extern const __ph<9> _9;
2019 _LIBCPP_FUNC_VIS extern const __ph<10> _10;
2021 constexpr __ph<1> _1{};
2022 constexpr __ph<2> _2{};
2023 constexpr __ph<3> _3{};
2024 constexpr __ph<4> _4{};
2025 constexpr __ph<5> _5{};
2026 constexpr __ph<6> _6{};
2027 constexpr __ph<7> _7{};
2028 constexpr __ph<8> _8{};
2029 constexpr __ph<9> _9{};
2030 constexpr __ph<10> _10{};
2031 #endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
2036 struct __is_placeholder<placeholders::__ph<_Np> >
2037 : public integral_constant<int, _Np> {};
2040 #ifndef _LIBCPP_HAS_NO_VARIADICS
2042 template <class _Tp, class _Uj>
2043 inline _LIBCPP_INLINE_VISIBILITY
2045 __mu(reference_wrapper<_Tp> __t, _Uj&)
2050 template <class _Ti, class ..._Uj, size_t ..._Indx>
2051 inline _LIBCPP_INLINE_VISIBILITY
2052 typename __invoke_of<_Ti&, _Uj...>::type
2053 __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
2055 return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
2058 template <class _Ti, class ..._Uj>
2059 inline _LIBCPP_INLINE_VISIBILITY
2060 typename __lazy_enable_if
2062 is_bind_expression<_Ti>::value,
2063 __invoke_of<_Ti&, _Uj...>
2065 __mu(_Ti& __ti, tuple<_Uj...>& __uj)
2067 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
2068 return __mu_expand(__ti, __uj, __indices());
2071 template <bool IsPh, class _Ti, class _Uj>
2072 struct __mu_return2 {};
2074 template <class _Ti, class _Uj>
2075 struct __mu_return2<true, _Ti, _Uj>
2077 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
2080 template <class _Ti, class _Uj>
2081 inline _LIBCPP_INLINE_VISIBILITY
2084 0 < is_placeholder<_Ti>::value,
2085 typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
2087 __mu(_Ti&, _Uj& __uj)
2089 const size_t _Indx = is_placeholder<_Ti>::value - 1;
2090 return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
2093 template <class _Ti, class _Uj>
2094 inline _LIBCPP_INLINE_VISIBILITY
2097 !is_bind_expression<_Ti>::value &&
2098 is_placeholder<_Ti>::value == 0 &&
2099 !__is_reference_wrapper<_Ti>::value,
2102 __mu(_Ti& __ti, _Uj&)
2107 template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
2109 struct ____mu_return;
2111 template <bool _Invokable, class _Ti, class ..._Uj>
2112 struct ____mu_return_invokable // false
2117 template <class _Ti, class ..._Uj>
2118 struct ____mu_return_invokable<true, _Ti, _Uj...>
2120 typedef typename __invoke_of<_Ti&, _Uj...>::type type;
2123 template <class _Ti, class ..._Uj>
2124 struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
2125 : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
2129 template <class _Ti, class _TupleUj>
2130 struct ____mu_return<_Ti, false, false, true, _TupleUj>
2132 typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
2133 _TupleUj>::type&& type;
2136 template <class _Ti, class _TupleUj>
2137 struct ____mu_return<_Ti, true, false, false, _TupleUj>
2139 typedef typename _Ti::type& type;
2142 template <class _Ti, class _TupleUj>
2143 struct ____mu_return<_Ti, false, false, false, _TupleUj>
2148 template <class _Ti, class _TupleUj>
2150 : public ____mu_return<_Ti,
2151 __is_reference_wrapper<_Ti>::value,
2152 is_bind_expression<_Ti>::value,
2153 0 < is_placeholder<_Ti>::value &&
2154 is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
2159 template <class _Fp, class _BoundArgs, class _TupleUj>
2160 struct __is_valid_bind_return
2162 static const bool value = false;
2165 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2166 struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
2168 static const bool value = __invokable<_Fp,
2169 typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
2172 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2173 struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
2175 static const bool value = __invokable<_Fp,
2176 typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
2179 template <class _Fp, class _BoundArgs, class _TupleUj,
2180 bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
2181 struct __bind_return;
2183 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2184 struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
2186 typedef typename __invoke_of
2189 typename __mu_return
2197 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2198 struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
2200 typedef typename __invoke_of
2203 typename __mu_return
2211 template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
2212 inline _LIBCPP_INLINE_VISIBILITY
2213 typename __bind_return<_Fp, _BoundArgs, _Args>::type
2214 __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
2217 return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
2220 template<class _Fp, class ..._BoundArgs>
2222 : public __weak_result_type<typename decay<_Fp>::type>
2225 typedef typename decay<_Fp>::type _Fd;
2226 typedef tuple<typename decay<_BoundArgs>::type...> _Td;
2231 typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
2233 template <class _Gp, class ..._BA,
2234 class = typename enable_if
2236 is_constructible<_Fd, _Gp>::value &&
2237 !is_same<typename remove_reference<_Gp>::type,
2240 _LIBCPP_INLINE_VISIBILITY
2241 explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
2242 : __f_(_VSTD::forward<_Gp>(__f)),
2243 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
2245 template <class ..._Args>
2246 _LIBCPP_INLINE_VISIBILITY
2247 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
2248 operator()(_Args&& ...__args)
2250 return __apply_functor(__f_, __bound_args_, __indices(),
2251 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2254 template <class ..._Args>
2255 _LIBCPP_INLINE_VISIBILITY
2256 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
2257 operator()(_Args&& ...__args) const
2259 return __apply_functor(__f_, __bound_args_, __indices(),
2260 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2264 template<class _Fp, class ..._BoundArgs>
2265 struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
2267 template<class _Rp, class _Fp, class ..._BoundArgs>
2269 : public __bind<_Fp, _BoundArgs...>
2271 typedef __bind<_Fp, _BoundArgs...> base;
2272 typedef typename base::_Fd _Fd;
2273 typedef typename base::_Td _Td;
2275 typedef _Rp result_type;
2278 template <class _Gp, class ..._BA,
2279 class = typename enable_if
2281 is_constructible<_Fd, _Gp>::value &&
2282 !is_same<typename remove_reference<_Gp>::type,
2285 _LIBCPP_INLINE_VISIBILITY
2286 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
2287 : base(_VSTD::forward<_Gp>(__f),
2288 _VSTD::forward<_BA>(__bound_args)...) {}
2290 template <class ..._Args>
2291 _LIBCPP_INLINE_VISIBILITY
2294 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
2295 result_type>::value || is_void<_Rp>::value,
2298 operator()(_Args&& ...__args)
2300 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2301 return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
2304 template <class ..._Args>
2305 _LIBCPP_INLINE_VISIBILITY
2308 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
2309 result_type>::value || is_void<_Rp>::value,
2312 operator()(_Args&& ...__args) const
2314 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2315 return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
2319 template<class _Rp, class _Fp, class ..._BoundArgs>
2320 struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
2322 template<class _Fp, class ..._BoundArgs>
2323 inline _LIBCPP_INLINE_VISIBILITY
2324 __bind<_Fp, _BoundArgs...>
2325 bind(_Fp&& __f, _BoundArgs&&... __bound_args)
2327 typedef __bind<_Fp, _BoundArgs...> type;
2328 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2331 template<class _Rp, class _Fp, class ..._BoundArgs>
2332 inline _LIBCPP_INLINE_VISIBILITY
2333 __bind_r<_Rp, _Fp, _BoundArgs...>
2334 bind(_Fp&& __f, _BoundArgs&&... __bound_args)
2336 typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
2337 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2340 #endif // _LIBCPP_HAS_NO_VARIADICS
2343 struct _LIBCPP_TEMPLATE_VIS hash<bool>
2344 : public unary_function<bool, size_t>
2346 _LIBCPP_INLINE_VISIBILITY
2347 size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2351 struct _LIBCPP_TEMPLATE_VIS hash<char>
2352 : public unary_function<char, size_t>
2354 _LIBCPP_INLINE_VISIBILITY
2355 size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2359 struct _LIBCPP_TEMPLATE_VIS hash<signed char>
2360 : public unary_function<signed char, size_t>
2362 _LIBCPP_INLINE_VISIBILITY
2363 size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2367 struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
2368 : public unary_function<unsigned char, size_t>
2370 _LIBCPP_INLINE_VISIBILITY
2371 size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2374 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
2377 struct _LIBCPP_TEMPLATE_VIS hash<char16_t>
2378 : public unary_function<char16_t, size_t>
2380 _LIBCPP_INLINE_VISIBILITY
2381 size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2385 struct _LIBCPP_TEMPLATE_VIS hash<char32_t>
2386 : public unary_function<char32_t, size_t>
2388 _LIBCPP_INLINE_VISIBILITY
2389 size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2392 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
2395 struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>
2396 : public unary_function<wchar_t, size_t>
2398 _LIBCPP_INLINE_VISIBILITY
2399 size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2403 struct _LIBCPP_TEMPLATE_VIS hash<short>
2404 : public unary_function<short, size_t>
2406 _LIBCPP_INLINE_VISIBILITY
2407 size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2411 struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
2412 : public unary_function<unsigned short, size_t>
2414 _LIBCPP_INLINE_VISIBILITY
2415 size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2419 struct _LIBCPP_TEMPLATE_VIS hash<int>
2420 : public unary_function<int, size_t>
2422 _LIBCPP_INLINE_VISIBILITY
2423 size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2427 struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
2428 : public unary_function<unsigned int, size_t>
2430 _LIBCPP_INLINE_VISIBILITY
2431 size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2435 struct _LIBCPP_TEMPLATE_VIS hash<long>
2436 : public unary_function<long, size_t>
2438 _LIBCPP_INLINE_VISIBILITY
2439 size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2443 struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
2444 : public unary_function<unsigned long, size_t>
2446 _LIBCPP_INLINE_VISIBILITY
2447 size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2451 struct _LIBCPP_TEMPLATE_VIS hash<long long>
2452 : public __scalar_hash<long long>
2457 struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long>
2458 : public __scalar_hash<unsigned long long>
2462 #ifndef _LIBCPP_HAS_NO_INT128
2465 struct _LIBCPP_TEMPLATE_VIS hash<__int128_t>
2466 : public __scalar_hash<__int128_t>
2471 struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t>
2472 : public __scalar_hash<__uint128_t>
2479 struct _LIBCPP_TEMPLATE_VIS hash<float>
2480 : public __scalar_hash<float>
2482 _LIBCPP_INLINE_VISIBILITY
2483 size_t operator()(float __v) const _NOEXCEPT
2485 // -0.0 and 0.0 should return same hash
2488 return __scalar_hash<float>::operator()(__v);
2493 struct _LIBCPP_TEMPLATE_VIS hash<double>
2494 : public __scalar_hash<double>
2496 _LIBCPP_INLINE_VISIBILITY
2497 size_t operator()(double __v) const _NOEXCEPT
2499 // -0.0 and 0.0 should return same hash
2502 return __scalar_hash<double>::operator()(__v);
2507 struct _LIBCPP_TEMPLATE_VIS hash<long double>
2508 : public __scalar_hash<long double>
2510 _LIBCPP_INLINE_VISIBILITY
2511 size_t operator()(long double __v) const _NOEXCEPT
2513 // -0.0 and 0.0 should return same hash
2516 #if defined(__i386__)
2517 // Zero out padding bits
2534 return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
2535 #elif defined(__x86_64__)
2536 // Zero out padding bits
2549 return __u.__s.__a ^ __u.__s.__b;
2551 return __scalar_hash<long double>::operator()(__v);
2556 #if _LIBCPP_STD_VER > 11
2558 template <class _Tp, bool = is_enum<_Tp>::value>
2559 struct _LIBCPP_TEMPLATE_VIS __enum_hash
2560 : public unary_function<_Tp, size_t>
2562 _LIBCPP_INLINE_VISIBILITY
2563 size_t operator()(_Tp __v) const _NOEXCEPT
2565 typedef typename underlying_type<_Tp>::type type;
2566 return hash<type>{}(static_cast<type>(__v));
2569 template <class _Tp>
2570 struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> {
2571 __enum_hash() = delete;
2572 __enum_hash(__enum_hash const&) = delete;
2573 __enum_hash& operator=(__enum_hash const&) = delete;
2576 template <class _Tp>
2577 struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
2583 #if _LIBCPP_STD_VER > 14
2585 #define __cpp_lib_invoke 201411
2587 template <class _Fn, class ..._Args>
2588 result_of_t<_Fn&&(_Args&&...)>
2589 invoke(_Fn&& __f, _Args&&... __args)
2590 noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...)))
2592 return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
2595 template <class _DecayFunc>
2596 class _LIBCPP_TEMPLATE_VIS __not_fn_imp {
2600 __not_fn_imp() = delete;
2602 template <class ..._Args>
2603 _LIBCPP_INLINE_VISIBILITY
2604 auto operator()(_Args&& ...__args) &
2605 noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
2606 -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
2607 { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
2609 template <class ..._Args>
2610 _LIBCPP_INLINE_VISIBILITY
2611 auto operator()(_Args&& ...__args) &&
2612 noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
2613 -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
2614 { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
2616 template <class ..._Args>
2617 _LIBCPP_INLINE_VISIBILITY
2618 auto operator()(_Args&& ...__args) const&
2619 noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
2620 -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
2621 { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
2624 template <class ..._Args>
2625 _LIBCPP_INLINE_VISIBILITY
2626 auto operator()(_Args&& ...__args) const&&
2627 noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
2628 -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
2629 { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
2632 template <class _RawFunc,
2633 class = enable_if_t<!is_same<decay_t<_RawFunc>, __not_fn_imp>::value>>
2634 _LIBCPP_INLINE_VISIBILITY
2635 explicit __not_fn_imp(_RawFunc&& __rf)
2636 : __fd(_VSTD::forward<_RawFunc>(__rf)) {}
2638 template <class _RawFunc>
2639 friend inline _LIBCPP_INLINE_VISIBILITY
2640 __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&&);
2643 template <class _RawFunc>
2644 inline _LIBCPP_INLINE_VISIBILITY
2645 __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) {
2646 return __not_fn_imp<decay_t<_RawFunc>>(_VSTD::forward<_RawFunc>(__fn));
2651 // struct hash<T*> in <memory>
2653 _LIBCPP_END_NAMESPACE_STD
2655 #endif // _LIBCPP_FUNCTIONAL