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>
238 class binder1st // deprecated in C++11, removed in C++17
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); // deprecated in C++11, removed in C++17
254 template <class Operation>
255 class binder2nd // deprecated in C++11, removed in C++17
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); // deprecated in C++11, removed in C++17
271 template <class Arg, class Result> // deprecated in C++11, removed in C++17
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)); // deprecated in C++11, removed in C++17
282 template <class Arg1, class Arg2, class Result> // deprecated in C++11, removed in C++17
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)); // deprecated in C++11, removed in C++17
293 template<class S, class T> // deprecated in C++11, removed in C++17
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> // deprecated in C++11, removed in C++17
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)()); // deprecated in C++11, removed in C++17
310 template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17
312 template<class S, class T>
313 class mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17
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> // deprecated in C++11, removed in C++17
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)()); // deprecated in C++11, removed in C++17
329 template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17
331 template <class S, class T>
332 class const_mem_fun_t : public unary_function<const T*, S> // deprecated in C++11, removed in C++17
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> // deprecated in C++11, removed in C++17
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); // deprecated in C++11, removed in C++17
348 template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17
350 template <class S, class T>
351 class const_mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17
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> // deprecated in C++11, removed in C++17
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); // deprecated in C++11, removed in C++17
367 template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17
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*>;
473 template <> struct hash<nullptr_t>; // C++17
477 POLICY: For non-variadic implementations, the number of arguments is limited
478 to 3. It is hoped that the need for non-variadic implementations
484 #include <type_traits>
491 #include <__functional_base>
493 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
494 #pragma GCC system_header
497 _LIBCPP_BEGIN_NAMESPACE_STD
499 #if _LIBCPP_STD_VER > 11
500 template <class _Tp = void>
504 struct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp>
506 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
507 _Tp operator()(const _Tp& __x, const _Tp& __y) const
511 #if _LIBCPP_STD_VER > 11
513 struct _LIBCPP_TEMPLATE_VIS plus<void>
515 template <class _T1, class _T2>
516 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
517 auto operator()(_T1&& __t, _T2&& __u) const
518 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
519 -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
520 { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
521 typedef void is_transparent;
526 #if _LIBCPP_STD_VER > 11
527 template <class _Tp = void>
531 struct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp>
533 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
534 _Tp operator()(const _Tp& __x, const _Tp& __y) const
538 #if _LIBCPP_STD_VER > 11
540 struct _LIBCPP_TEMPLATE_VIS minus<void>
542 template <class _T1, class _T2>
543 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
544 auto operator()(_T1&& __t, _T2&& __u) const
545 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
546 -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
547 { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
548 typedef void is_transparent;
553 #if _LIBCPP_STD_VER > 11
554 template <class _Tp = void>
558 struct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp>
560 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
561 _Tp operator()(const _Tp& __x, const _Tp& __y) const
565 #if _LIBCPP_STD_VER > 11
567 struct _LIBCPP_TEMPLATE_VIS multiplies<void>
569 template <class _T1, class _T2>
570 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
571 auto operator()(_T1&& __t, _T2&& __u) const
572 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
573 -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
574 { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
575 typedef void is_transparent;
580 #if _LIBCPP_STD_VER > 11
581 template <class _Tp = void>
585 struct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp>
587 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
588 _Tp operator()(const _Tp& __x, const _Tp& __y) const
592 #if _LIBCPP_STD_VER > 11
594 struct _LIBCPP_TEMPLATE_VIS divides<void>
596 template <class _T1, class _T2>
597 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
598 auto operator()(_T1&& __t, _T2&& __u) const
599 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
600 -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
601 { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
602 typedef void is_transparent;
607 #if _LIBCPP_STD_VER > 11
608 template <class _Tp = void>
612 struct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp>
614 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
615 _Tp operator()(const _Tp& __x, const _Tp& __y) const
619 #if _LIBCPP_STD_VER > 11
621 struct _LIBCPP_TEMPLATE_VIS modulus<void>
623 template <class _T1, class _T2>
624 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
625 auto operator()(_T1&& __t, _T2&& __u) const
626 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
627 -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
628 { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
629 typedef void is_transparent;
634 #if _LIBCPP_STD_VER > 11
635 template <class _Tp = void>
639 struct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp>
641 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
642 _Tp operator()(const _Tp& __x) const
646 #if _LIBCPP_STD_VER > 11
648 struct _LIBCPP_TEMPLATE_VIS negate<void>
651 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
652 auto operator()(_Tp&& __x) const
653 _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
654 -> decltype (- _VSTD::forward<_Tp>(__x))
655 { return - _VSTD::forward<_Tp>(__x); }
656 typedef void is_transparent;
661 #if _LIBCPP_STD_VER > 11
662 template <class _Tp = void>
666 struct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool>
668 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
669 bool operator()(const _Tp& __x, const _Tp& __y) const
673 #if _LIBCPP_STD_VER > 11
675 struct _LIBCPP_TEMPLATE_VIS equal_to<void>
677 template <class _T1, class _T2>
678 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
679 auto operator()(_T1&& __t, _T2&& __u) const
680 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
681 -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
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_TEMPLATE_VIS not_equal_to : 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_TEMPLATE_VIS not_equal_to<void>
704 template <class _T1, class _T2>
705 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
706 auto operator()(_T1&& __t, _T2&& __u) const
707 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
708 -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
709 { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
710 typedef void is_transparent;
715 #if _LIBCPP_STD_VER > 11
716 template <class _Tp = void>
720 struct _LIBCPP_TEMPLATE_VIS greater : 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_TEMPLATE_VIS greater<void>
731 template <class _T1, class _T2>
732 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
733 auto operator()(_T1&& __t, _T2&& __u) const
734 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
735 -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
736 { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
737 typedef void is_transparent;
742 // less in <__functional_base>
744 #if _LIBCPP_STD_VER > 11
745 template <class _Tp = void>
749 struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
751 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
752 bool operator()(const _Tp& __x, const _Tp& __y) const
756 #if _LIBCPP_STD_VER > 11
758 struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
760 template <class _T1, class _T2>
761 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
762 auto operator()(_T1&& __t, _T2&& __u) const
763 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
764 -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
765 { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
766 typedef void is_transparent;
771 #if _LIBCPP_STD_VER > 11
772 template <class _Tp = void>
776 struct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool>
778 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
779 bool operator()(const _Tp& __x, const _Tp& __y) const
783 #if _LIBCPP_STD_VER > 11
785 struct _LIBCPP_TEMPLATE_VIS less_equal<void>
787 template <class _T1, class _T2>
788 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
789 auto operator()(_T1&& __t, _T2&& __u) const
790 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
791 -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
792 { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
793 typedef void is_transparent;
798 #if _LIBCPP_STD_VER > 11
799 template <class _Tp = void>
803 struct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool>
805 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
806 bool operator()(const _Tp& __x, const _Tp& __y) const
810 #if _LIBCPP_STD_VER > 11
812 struct _LIBCPP_TEMPLATE_VIS logical_and<void>
814 template <class _T1, class _T2>
815 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
816 auto operator()(_T1&& __t, _T2&& __u) const
817 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
818 -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
819 { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
820 typedef void is_transparent;
825 #if _LIBCPP_STD_VER > 11
826 template <class _Tp = void>
830 struct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool>
832 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
833 bool operator()(const _Tp& __x, const _Tp& __y) const
837 #if _LIBCPP_STD_VER > 11
839 struct _LIBCPP_TEMPLATE_VIS logical_or<void>
841 template <class _T1, class _T2>
842 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
843 auto operator()(_T1&& __t, _T2&& __u) const
844 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
845 -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
846 { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
847 typedef void is_transparent;
852 #if _LIBCPP_STD_VER > 11
853 template <class _Tp = void>
857 struct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool>
859 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
860 bool operator()(const _Tp& __x) const
864 #if _LIBCPP_STD_VER > 11
866 struct _LIBCPP_TEMPLATE_VIS logical_not<void>
869 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
870 auto operator()(_Tp&& __x) const
871 _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
872 -> decltype (!_VSTD::forward<_Tp>(__x))
873 { return !_VSTD::forward<_Tp>(__x); }
874 typedef void is_transparent;
879 #if _LIBCPP_STD_VER > 11
880 template <class _Tp = void>
884 struct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp>
886 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
887 _Tp operator()(const _Tp& __x, const _Tp& __y) const
891 #if _LIBCPP_STD_VER > 11
893 struct _LIBCPP_TEMPLATE_VIS bit_and<void>
895 template <class _T1, class _T2>
896 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
897 auto operator()(_T1&& __t, _T2&& __u) const
898 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
899 -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
900 { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
901 typedef void is_transparent;
906 #if _LIBCPP_STD_VER > 11
907 template <class _Tp = void>
911 struct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp>
913 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
914 _Tp operator()(const _Tp& __x, const _Tp& __y) const
918 #if _LIBCPP_STD_VER > 11
920 struct _LIBCPP_TEMPLATE_VIS bit_or<void>
922 template <class _T1, class _T2>
923 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
924 auto operator()(_T1&& __t, _T2&& __u) const
925 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
926 -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
927 { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
928 typedef void is_transparent;
933 #if _LIBCPP_STD_VER > 11
934 template <class _Tp = void>
938 struct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp>
940 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
941 _Tp operator()(const _Tp& __x, const _Tp& __y) const
945 #if _LIBCPP_STD_VER > 11
947 struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
949 template <class _T1, class _T2>
950 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
951 auto operator()(_T1&& __t, _T2&& __u) const
952 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
953 -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
954 { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
955 typedef void is_transparent;
960 #if _LIBCPP_STD_VER > 11
961 template <class _Tp = void>
962 struct _LIBCPP_TEMPLATE_VIS bit_not : unary_function<_Tp, _Tp>
964 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
965 _Tp operator()(const _Tp& __x) const
970 struct _LIBCPP_TEMPLATE_VIS bit_not<void>
973 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
974 auto operator()(_Tp&& __x) const
975 _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
976 -> decltype (~_VSTD::forward<_Tp>(__x))
977 { return ~_VSTD::forward<_Tp>(__x); }
978 typedef void is_transparent;
982 template <class _Predicate>
983 class _LIBCPP_TEMPLATE_VIS unary_negate
984 : public unary_function<typename _Predicate::argument_type, bool>
988 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
989 explicit unary_negate(const _Predicate& __pred)
991 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
992 bool operator()(const typename _Predicate::argument_type& __x) const
993 {return !__pred_(__x);}
996 template <class _Predicate>
997 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
998 unary_negate<_Predicate>
999 not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
1001 template <class _Predicate>
1002 class _LIBCPP_TEMPLATE_VIS binary_negate
1003 : public binary_function<typename _Predicate::first_argument_type,
1004 typename _Predicate::second_argument_type,
1009 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
1010 binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
1012 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1013 bool operator()(const typename _Predicate::first_argument_type& __x,
1014 const typename _Predicate::second_argument_type& __y) const
1015 {return !__pred_(__x, __y);}
1018 template <class _Predicate>
1019 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1020 binary_negate<_Predicate>
1021 not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
1023 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
1024 template <class __Operation>
1025 class _LIBCPP_TEMPLATE_VIS binder1st
1026 : public unary_function<typename __Operation::second_argument_type,
1027 typename __Operation::result_type>
1031 typename __Operation::first_argument_type value;
1033 _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
1034 const typename __Operation::first_argument_type __y)
1035 : op(__x), value(__y) {}
1036 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1037 (typename __Operation::second_argument_type& __x) const
1038 {return op(value, __x);}
1039 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1040 (const typename __Operation::second_argument_type& __x) const
1041 {return op(value, __x);}
1044 template <class __Operation, class _Tp>
1045 inline _LIBCPP_INLINE_VISIBILITY
1046 binder1st<__Operation>
1047 bind1st(const __Operation& __op, const _Tp& __x)
1048 {return binder1st<__Operation>(__op, __x);}
1050 template <class __Operation>
1051 class _LIBCPP_TEMPLATE_VIS binder2nd
1052 : public unary_function<typename __Operation::first_argument_type,
1053 typename __Operation::result_type>
1057 typename __Operation::second_argument_type value;
1059 _LIBCPP_INLINE_VISIBILITY
1060 binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
1061 : op(__x), value(__y) {}
1062 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1063 ( typename __Operation::first_argument_type& __x) const
1064 {return op(__x, value);}
1065 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1066 (const typename __Operation::first_argument_type& __x) const
1067 {return op(__x, value);}
1070 template <class __Operation, class _Tp>
1071 inline _LIBCPP_INLINE_VISIBILITY
1072 binder2nd<__Operation>
1073 bind2nd(const __Operation& __op, const _Tp& __x)
1074 {return binder2nd<__Operation>(__op, __x);}
1076 template <class _Arg, class _Result>
1077 class _LIBCPP_TEMPLATE_VIS pointer_to_unary_function
1078 : public unary_function<_Arg, _Result>
1080 _Result (*__f_)(_Arg);
1082 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
1084 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
1088 template <class _Arg, class _Result>
1089 inline _LIBCPP_INLINE_VISIBILITY
1090 pointer_to_unary_function<_Arg,_Result>
1091 ptr_fun(_Result (*__f)(_Arg))
1092 {return pointer_to_unary_function<_Arg,_Result>(__f);}
1094 template <class _Arg1, class _Arg2, class _Result>
1095 class _LIBCPP_TEMPLATE_VIS pointer_to_binary_function
1096 : public binary_function<_Arg1, _Arg2, _Result>
1098 _Result (*__f_)(_Arg1, _Arg2);
1100 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
1102 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
1103 {return __f_(__x, __y);}
1106 template <class _Arg1, class _Arg2, class _Result>
1107 inline _LIBCPP_INLINE_VISIBILITY
1108 pointer_to_binary_function<_Arg1,_Arg2,_Result>
1109 ptr_fun(_Result (*__f)(_Arg1,_Arg2))
1110 {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
1112 template<class _Sp, class _Tp>
1113 class _LIBCPP_TEMPLATE_VIS mem_fun_t : public unary_function<_Tp*, _Sp>
1117 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
1119 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
1120 {return (__p->*__p_)();}
1123 template<class _Sp, class _Tp, class _Ap>
1124 class _LIBCPP_TEMPLATE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
1126 _Sp (_Tp::*__p_)(_Ap);
1128 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
1130 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
1131 {return (__p->*__p_)(__x);}
1134 template<class _Sp, class _Tp>
1135 inline _LIBCPP_INLINE_VISIBILITY
1137 mem_fun(_Sp (_Tp::*__f)())
1138 {return mem_fun_t<_Sp,_Tp>(__f);}
1140 template<class _Sp, class _Tp, class _Ap>
1141 inline _LIBCPP_INLINE_VISIBILITY
1142 mem_fun1_t<_Sp,_Tp,_Ap>
1143 mem_fun(_Sp (_Tp::*__f)(_Ap))
1144 {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1146 template<class _Sp, class _Tp>
1147 class _LIBCPP_TEMPLATE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp>
1151 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
1153 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
1154 {return (__p.*__p_)();}
1157 template<class _Sp, class _Tp, class _Ap>
1158 class _LIBCPP_TEMPLATE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
1160 _Sp (_Tp::*__p_)(_Ap);
1162 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
1164 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
1165 {return (__p.*__p_)(__x);}
1168 template<class _Sp, class _Tp>
1169 inline _LIBCPP_INLINE_VISIBILITY
1170 mem_fun_ref_t<_Sp,_Tp>
1171 mem_fun_ref(_Sp (_Tp::*__f)())
1172 {return mem_fun_ref_t<_Sp,_Tp>(__f);}
1174 template<class _Sp, class _Tp, class _Ap>
1175 inline _LIBCPP_INLINE_VISIBILITY
1176 mem_fun1_ref_t<_Sp,_Tp,_Ap>
1177 mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
1178 {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1180 template <class _Sp, class _Tp>
1181 class _LIBCPP_TEMPLATE_VIS const_mem_fun_t : public unary_function<const _Tp*, _Sp>
1183 _Sp (_Tp::*__p_)() const;
1185 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
1187 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
1188 {return (__p->*__p_)();}
1191 template <class _Sp, class _Tp, class _Ap>
1192 class _LIBCPP_TEMPLATE_VIS const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
1194 _Sp (_Tp::*__p_)(_Ap) const;
1196 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
1198 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
1199 {return (__p->*__p_)(__x);}
1202 template <class _Sp, class _Tp>
1203 inline _LIBCPP_INLINE_VISIBILITY
1204 const_mem_fun_t<_Sp,_Tp>
1205 mem_fun(_Sp (_Tp::*__f)() const)
1206 {return const_mem_fun_t<_Sp,_Tp>(__f);}
1208 template <class _Sp, class _Tp, class _Ap>
1209 inline _LIBCPP_INLINE_VISIBILITY
1210 const_mem_fun1_t<_Sp,_Tp,_Ap>
1211 mem_fun(_Sp (_Tp::*__f)(_Ap) const)
1212 {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1214 template <class _Sp, class _Tp>
1215 class _LIBCPP_TEMPLATE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
1217 _Sp (_Tp::*__p_)() const;
1219 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
1221 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
1222 {return (__p.*__p_)();}
1225 template <class _Sp, class _Tp, class _Ap>
1226 class _LIBCPP_TEMPLATE_VIS const_mem_fun1_ref_t
1227 : public binary_function<_Tp, _Ap, _Sp>
1229 _Sp (_Tp::*__p_)(_Ap) const;
1231 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
1233 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
1234 {return (__p.*__p_)(__x);}
1237 template <class _Sp, class _Tp>
1238 inline _LIBCPP_INLINE_VISIBILITY
1239 const_mem_fun_ref_t<_Sp,_Tp>
1240 mem_fun_ref(_Sp (_Tp::*__f)() const)
1241 {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
1243 template <class _Sp, class _Tp, class _Ap>
1244 inline _LIBCPP_INLINE_VISIBILITY
1245 const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
1246 mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
1247 {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1250 ////////////////////////////////////////////////////////////////////////////////
1252 //==============================================================================
1254 template <class _Tp>
1256 : public __weak_result_type<_Tp>
1265 _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
1267 #ifndef _LIBCPP_CXX03_LANG
1269 template <class... _ArgTypes>
1270 _LIBCPP_INLINE_VISIBILITY
1271 typename __invoke_return<type, _ArgTypes...>::type
1272 operator() (_ArgTypes&&... __args) const {
1273 return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
1277 template <class _A0>
1278 _LIBCPP_INLINE_VISIBILITY
1279 typename __invoke_return0<type, _A0>::type
1280 operator() (_A0& __a0) const {
1281 return __invoke(__f_, __a0);
1284 template <class _A0>
1285 _LIBCPP_INLINE_VISIBILITY
1286 typename __invoke_return0<type, _A0 const>::type
1287 operator() (_A0 const& __a0) const {
1288 return __invoke(__f_, __a0);
1291 template <class _A0, class _A1>
1292 _LIBCPP_INLINE_VISIBILITY
1293 typename __invoke_return1<type, _A0, _A1>::type
1294 operator() (_A0& __a0, _A1& __a1) const {
1295 return __invoke(__f_, __a0, __a1);
1298 template <class _A0, class _A1>
1299 _LIBCPP_INLINE_VISIBILITY
1300 typename __invoke_return1<type, _A0 const, _A1>::type
1301 operator() (_A0 const& __a0, _A1& __a1) const {
1302 return __invoke(__f_, __a0, __a1);
1305 template <class _A0, class _A1>
1306 _LIBCPP_INLINE_VISIBILITY
1307 typename __invoke_return1<type, _A0, _A1 const>::type
1308 operator() (_A0& __a0, _A1 const& __a1) const {
1309 return __invoke(__f_, __a0, __a1);
1312 template <class _A0, class _A1>
1313 _LIBCPP_INLINE_VISIBILITY
1314 typename __invoke_return1<type, _A0 const, _A1 const>::type
1315 operator() (_A0 const& __a0, _A1 const& __a1) const {
1316 return __invoke(__f_, __a0, __a1);
1319 template <class _A0, class _A1, class _A2>
1320 _LIBCPP_INLINE_VISIBILITY
1321 typename __invoke_return2<type, _A0, _A1, _A2>::type
1322 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
1323 return __invoke(__f_, __a0, __a1, __a2);
1326 template <class _A0, class _A1, class _A2>
1327 _LIBCPP_INLINE_VISIBILITY
1328 typename __invoke_return2<type, _A0 const, _A1, _A2>::type
1329 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
1330 return __invoke(__f_, __a0, __a1, __a2);
1333 template <class _A0, class _A1, class _A2>
1334 _LIBCPP_INLINE_VISIBILITY
1335 typename __invoke_return2<type, _A0, _A1 const, _A2>::type
1336 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
1337 return __invoke(__f_, __a0, __a1, __a2);
1340 template <class _A0, class _A1, class _A2>
1341 _LIBCPP_INLINE_VISIBILITY
1342 typename __invoke_return2<type, _A0, _A1, _A2 const>::type
1343 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
1344 return __invoke(__f_, __a0, __a1, __a2);
1347 template <class _A0, class _A1, class _A2>
1348 _LIBCPP_INLINE_VISIBILITY
1349 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
1350 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
1351 return __invoke(__f_, __a0, __a1, __a2);
1354 template <class _A0, class _A1, class _A2>
1355 _LIBCPP_INLINE_VISIBILITY
1356 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
1357 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
1358 return __invoke(__f_, __a0, __a1, __a2);
1361 template <class _A0, class _A1, class _A2>
1362 _LIBCPP_INLINE_VISIBILITY
1363 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
1364 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
1365 return __invoke(__f_, __a0, __a1, __a2);
1368 template <class _A0, class _A1, class _A2>
1369 _LIBCPP_INLINE_VISIBILITY
1370 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
1371 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
1372 return __invoke(__f_, __a0, __a1, __a2);
1377 template<class _Rp, class _Tp>
1378 inline _LIBCPP_INLINE_VISIBILITY
1379 __mem_fn<_Rp _Tp::*>
1380 mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
1382 return __mem_fn<_Rp _Tp::*>(__pm);
1385 ////////////////////////////////////////////////////////////////////////////////
1387 //==============================================================================
1389 // bad_function_call
1391 class _LIBCPP_EXCEPTION_ABI bad_function_call
1394 #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
1396 virtual ~bad_function_call() _NOEXCEPT;
1398 virtual const char* what() const _NOEXCEPT;
1402 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
1403 void __throw_bad_function_call()
1405 #ifndef _LIBCPP_NO_EXCEPTIONS
1406 throw bad_function_call();
1412 template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined
1414 namespace __function
1418 struct __maybe_derive_from_unary_function
1422 template<class _Rp, class _A1>
1423 struct __maybe_derive_from_unary_function<_Rp(_A1)>
1424 : public unary_function<_A1, _Rp>
1429 struct __maybe_derive_from_binary_function
1433 template<class _Rp, class _A1, class _A2>
1434 struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
1435 : public binary_function<_A1, _A2, _Rp>
1439 template <class _Fp>
1440 _LIBCPP_INLINE_VISIBILITY
1441 bool __not_null(_Fp const&) { return true; }
1443 template <class _Fp>
1444 _LIBCPP_INLINE_VISIBILITY
1445 bool __not_null(_Fp* __ptr) { return __ptr; }
1447 template <class _Ret, class _Class>
1448 _LIBCPP_INLINE_VISIBILITY
1449 bool __not_null(_Ret _Class::*__ptr) { return __ptr; }
1451 template <class _Fp>
1452 _LIBCPP_INLINE_VISIBILITY
1453 bool __not_null(function<_Fp> const& __f) { return !!__f; }
1455 } // namespace __function
1457 #ifndef _LIBCPP_CXX03_LANG
1459 namespace __function {
1461 template<class _Fp> class __base;
1463 template<class _Rp, class ..._ArgTypes>
1464 class __base<_Rp(_ArgTypes...)>
1466 __base(const __base&);
1467 __base& operator=(const __base&);
1469 _LIBCPP_INLINE_VISIBILITY __base() {}
1470 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
1471 virtual __base* __clone() const = 0;
1472 virtual void __clone(__base*) const = 0;
1473 virtual void destroy() _NOEXCEPT = 0;
1474 virtual void destroy_deallocate() _NOEXCEPT = 0;
1475 virtual _Rp operator()(_ArgTypes&& ...) = 0;
1476 #ifndef _LIBCPP_NO_RTTI
1477 virtual const void* target(const type_info&) const _NOEXCEPT = 0;
1478 virtual const std::type_info& target_type() const _NOEXCEPT = 0;
1479 #endif // _LIBCPP_NO_RTTI
1482 template<class _FD, class _Alloc, class _FB> class __func;
1484 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1485 class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
1486 : public __base<_Rp(_ArgTypes...)>
1488 __compressed_pair<_Fp, _Alloc> __f_;
1490 _LIBCPP_INLINE_VISIBILITY
1491 explicit __func(_Fp&& __f)
1492 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1493 _VSTD::forward_as_tuple()) {}
1494 _LIBCPP_INLINE_VISIBILITY
1495 explicit __func(const _Fp& __f, const _Alloc& __a)
1496 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1497 _VSTD::forward_as_tuple(__a)) {}
1499 _LIBCPP_INLINE_VISIBILITY
1500 explicit __func(const _Fp& __f, _Alloc&& __a)
1501 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1502 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1504 _LIBCPP_INLINE_VISIBILITY
1505 explicit __func(_Fp&& __f, _Alloc&& __a)
1506 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1507 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1508 virtual __base<_Rp(_ArgTypes...)>* __clone() const;
1509 virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
1510 virtual void destroy() _NOEXCEPT;
1511 virtual void destroy_deallocate() _NOEXCEPT;
1512 virtual _Rp operator()(_ArgTypes&& ... __arg);
1513 #ifndef _LIBCPP_NO_RTTI
1514 virtual const void* target(const type_info&) const _NOEXCEPT;
1515 virtual const std::type_info& target_type() const _NOEXCEPT;
1516 #endif // _LIBCPP_NO_RTTI
1519 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1520 __base<_Rp(_ArgTypes...)>*
1521 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
1523 typedef allocator_traits<_Alloc> __alloc_traits;
1524 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1525 _Ap __a(__f_.second());
1526 typedef __allocator_destructor<_Ap> _Dp;
1527 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1528 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
1529 return __hold.release();
1532 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1534 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
1536 ::new (__p) __func(__f_.first(), __f_.second());
1539 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1541 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
1543 __f_.~__compressed_pair<_Fp, _Alloc>();
1546 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1548 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
1550 typedef allocator_traits<_Alloc> __alloc_traits;
1551 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1552 _Ap __a(__f_.second());
1553 __f_.~__compressed_pair<_Fp, _Alloc>();
1554 __a.deallocate(this, 1);
1557 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1559 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
1561 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1562 return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
1565 #ifndef _LIBCPP_NO_RTTI
1567 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1569 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
1571 if (__ti == typeid(_Fp))
1572 return &__f_.first();
1573 return (const void*)0;
1576 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1577 const std::type_info&
1578 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1583 #endif // _LIBCPP_NO_RTTI
1587 template<class _Rp, class ..._ArgTypes>
1588 class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
1589 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
1590 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
1592 typedef __function::__base<_Rp(_ArgTypes...)> __base;
1593 typename aligned_storage<3*sizeof(void*)>::type __buf_;
1596 _LIBCPP_NO_CFI static __base *__as_base(void *p) {
1597 return reinterpret_cast<__base*>(p);
1600 template <class _Fp, bool = !is_same<_Fp, function>::value &&
1601 __invokable<_Fp&, _ArgTypes...>::value>
1603 template <class _Fp>
1604 struct __callable<_Fp, true>
1606 static const bool value = is_same<void, _Rp>::value ||
1607 is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
1610 template <class _Fp>
1611 struct __callable<_Fp, false>
1613 static const bool value = false;
1616 typedef _Rp result_type;
1618 // construct/copy/destroy:
1619 _LIBCPP_INLINE_VISIBILITY
1620 function() _NOEXCEPT : __f_(0) {}
1621 _LIBCPP_INLINE_VISIBILITY
1622 function(nullptr_t) _NOEXCEPT : __f_(0) {}
1623 function(const function&);
1624 function(function&&) _NOEXCEPT;
1625 template<class _Fp, class = typename enable_if<
1626 __callable<_Fp>::value && !is_same<_Fp, function>::value
1630 #if _LIBCPP_STD_VER <= 14
1631 template<class _Alloc>
1632 _LIBCPP_INLINE_VISIBILITY
1633 function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
1634 template<class _Alloc>
1635 _LIBCPP_INLINE_VISIBILITY
1636 function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
1637 template<class _Alloc>
1638 function(allocator_arg_t, const _Alloc&, const function&);
1639 template<class _Alloc>
1640 function(allocator_arg_t, const _Alloc&, function&&);
1641 template<class _Fp, class _Alloc, class = typename enable_if<__callable<_Fp>::value>::type>
1642 function(allocator_arg_t, const _Alloc& __a, _Fp __f);
1645 function& operator=(const function&);
1646 function& operator=(function&&) _NOEXCEPT;
1647 function& operator=(nullptr_t) _NOEXCEPT;
1651 __callable<typename decay<_Fp>::type>::value &&
1652 !is_same<typename remove_reference<_Fp>::type, function>::value,
1659 // function modifiers:
1660 void swap(function&) _NOEXCEPT;
1662 #if _LIBCPP_STD_VER <= 14
1663 template<class _Fp, class _Alloc>
1664 _LIBCPP_INLINE_VISIBILITY
1665 void assign(_Fp&& __f, const _Alloc& __a)
1666 {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
1669 // function capacity:
1670 _LIBCPP_INLINE_VISIBILITY
1671 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
1673 // deleted overloads close possible hole in the type system
1674 template<class _R2, class... _ArgTypes2>
1675 bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
1676 template<class _R2, class... _ArgTypes2>
1677 bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
1679 // function invocation:
1680 _Rp operator()(_ArgTypes...) const;
1682 #ifndef _LIBCPP_NO_RTTI
1683 // function target access:
1684 const std::type_info& target_type() const _NOEXCEPT;
1685 template <typename _Tp> _Tp* target() _NOEXCEPT;
1686 template <typename _Tp> const _Tp* target() const _NOEXCEPT;
1687 #endif // _LIBCPP_NO_RTTI
1690 template<class _Rp, class ..._ArgTypes>
1691 function<_Rp(_ArgTypes...)>::function(const function& __f)
1695 else if ((void *)__f.__f_ == &__f.__buf_)
1697 __f_ = __as_base(&__buf_);
1698 __f.__f_->__clone(__f_);
1701 __f_ = __f.__f_->__clone();
1704 #if _LIBCPP_STD_VER <= 14
1705 template<class _Rp, class ..._ArgTypes>
1706 template <class _Alloc>
1707 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1708 const function& __f)
1712 else if ((void *)__f.__f_ == &__f.__buf_)
1714 __f_ = __as_base(&__buf_);
1715 __f.__f_->__clone(__f_);
1718 __f_ = __f.__f_->__clone();
1722 template<class _Rp, class ..._ArgTypes>
1723 function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
1727 else if ((void *)__f.__f_ == &__f.__buf_)
1729 __f_ = __as_base(&__buf_);
1730 __f.__f_->__clone(__f_);
1739 #if _LIBCPP_STD_VER <= 14
1740 template<class _Rp, class ..._ArgTypes>
1741 template <class _Alloc>
1742 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1747 else if ((void *)__f.__f_ == &__f.__buf_)
1749 __f_ = __as_base(&__buf_);
1750 __f.__f_->__clone(__f_);
1760 template<class _Rp, class ..._ArgTypes>
1761 template <class _Fp, class>
1762 function<_Rp(_ArgTypes...)>::function(_Fp __f)
1765 if (__function::__not_null(__f))
1767 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
1768 if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
1770 __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f));
1774 typedef allocator<_FF> _Ap;
1776 typedef __allocator_destructor<_Ap> _Dp;
1777 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1778 ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
1779 __f_ = __hold.release();
1784 #if _LIBCPP_STD_VER <= 14
1785 template<class _Rp, class ..._ArgTypes>
1786 template <class _Fp, class _Alloc, class>
1787 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f)
1790 typedef allocator_traits<_Alloc> __alloc_traits;
1791 if (__function::__not_null(__f))
1793 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
1794 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1796 if (sizeof(_FF) <= sizeof(__buf_) &&
1797 is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
1799 __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a));
1803 typedef __allocator_destructor<_Ap> _Dp;
1804 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1805 ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
1806 __f_ = __hold.release();
1812 template<class _Rp, class ..._ArgTypes>
1813 function<_Rp(_ArgTypes...)>&
1814 function<_Rp(_ArgTypes...)>::operator=(const function& __f)
1816 function(__f).swap(*this);
1820 template<class _Rp, class ..._ArgTypes>
1821 function<_Rp(_ArgTypes...)>&
1822 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
1824 if ((void *)__f_ == &__buf_)
1827 __f_->destroy_deallocate();
1831 else if ((void *)__f.__f_ == &__f.__buf_)
1833 __f_ = __as_base(&__buf_);
1834 __f.__f_->__clone(__f_);
1844 template<class _Rp, class ..._ArgTypes>
1845 function<_Rp(_ArgTypes...)>&
1846 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
1848 if ((void *)__f_ == &__buf_)
1851 __f_->destroy_deallocate();
1856 template<class _Rp, class ..._ArgTypes>
1857 template <class _Fp>
1860 function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
1861 !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
1862 function<_Rp(_ArgTypes...)>&
1864 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
1866 function(_VSTD::forward<_Fp>(__f)).swap(*this);
1870 template<class _Rp, class ..._ArgTypes>
1871 function<_Rp(_ArgTypes...)>::~function()
1873 if ((void *)__f_ == &__buf_)
1876 __f_->destroy_deallocate();
1879 template<class _Rp, class ..._ArgTypes>
1881 function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
1883 if (_VSTD::addressof(__f) == this)
1885 if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_)
1887 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1888 __base* __t = __as_base(&__tempbuf);
1892 __f.__f_->__clone(__as_base(&__buf_));
1893 __f.__f_->destroy();
1895 __f_ = __as_base(&__buf_);
1896 __t->__clone(__as_base(&__f.__buf_));
1898 __f.__f_ = __as_base(&__f.__buf_);
1900 else if ((void *)__f_ == &__buf_)
1902 __f_->__clone(__as_base(&__f.__buf_));
1905 __f.__f_ = __as_base(&__f.__buf_);
1907 else if ((void *)__f.__f_ == &__f.__buf_)
1909 __f.__f_->__clone(__as_base(&__buf_));
1910 __f.__f_->destroy();
1912 __f_ = __as_base(&__buf_);
1915 _VSTD::swap(__f_, __f.__f_);
1918 template<class _Rp, class ..._ArgTypes>
1920 function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
1923 __throw_bad_function_call();
1924 return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
1927 #ifndef _LIBCPP_NO_RTTI
1929 template<class _Rp, class ..._ArgTypes>
1930 const std::type_info&
1931 function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1934 return typeid(void);
1935 return __f_->target_type();
1938 template<class _Rp, class ..._ArgTypes>
1939 template <typename _Tp>
1941 function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
1945 return (_Tp*)__f_->target(typeid(_Tp));
1948 template<class _Rp, class ..._ArgTypes>
1949 template <typename _Tp>
1951 function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
1954 return (const _Tp*)0;
1955 return (const _Tp*)__f_->target(typeid(_Tp));
1958 #endif // _LIBCPP_NO_RTTI
1960 template <class _Rp, class... _ArgTypes>
1961 inline _LIBCPP_INLINE_VISIBILITY
1963 operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
1965 template <class _Rp, class... _ArgTypes>
1966 inline _LIBCPP_INLINE_VISIBILITY
1968 operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
1970 template <class _Rp, class... _ArgTypes>
1971 inline _LIBCPP_INLINE_VISIBILITY
1973 operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
1975 template <class _Rp, class... _ArgTypes>
1976 inline _LIBCPP_INLINE_VISIBILITY
1978 operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
1980 template <class _Rp, class... _ArgTypes>
1981 inline _LIBCPP_INLINE_VISIBILITY
1983 swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
1984 {return __x.swap(__y);}
1986 #else // _LIBCPP_CXX03_LANG
1988 #include <__functional_03>
1992 ////////////////////////////////////////////////////////////////////////////////
1994 //==============================================================================
1996 template<class _Tp> struct __is_bind_expression : public false_type {};
1997 template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression
1998 : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
2000 #if _LIBCPP_STD_VER > 14
2001 template <class _Tp>
2002 constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
2005 template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
2006 template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder
2007 : public __is_placeholder<typename remove_cv<_Tp>::type> {};
2009 #if _LIBCPP_STD_VER > 14
2010 template <class _Tp>
2011 constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
2014 namespace placeholders
2017 template <int _Np> struct __ph {};
2019 #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
2020 _LIBCPP_FUNC_VIS extern const __ph<1> _1;
2021 _LIBCPP_FUNC_VIS extern const __ph<2> _2;
2022 _LIBCPP_FUNC_VIS extern const __ph<3> _3;
2023 _LIBCPP_FUNC_VIS extern const __ph<4> _4;
2024 _LIBCPP_FUNC_VIS extern const __ph<5> _5;
2025 _LIBCPP_FUNC_VIS extern const __ph<6> _6;
2026 _LIBCPP_FUNC_VIS extern const __ph<7> _7;
2027 _LIBCPP_FUNC_VIS extern const __ph<8> _8;
2028 _LIBCPP_FUNC_VIS extern const __ph<9> _9;
2029 _LIBCPP_FUNC_VIS extern const __ph<10> _10;
2031 constexpr __ph<1> _1{};
2032 constexpr __ph<2> _2{};
2033 constexpr __ph<3> _3{};
2034 constexpr __ph<4> _4{};
2035 constexpr __ph<5> _5{};
2036 constexpr __ph<6> _6{};
2037 constexpr __ph<7> _7{};
2038 constexpr __ph<8> _8{};
2039 constexpr __ph<9> _9{};
2040 constexpr __ph<10> _10{};
2041 #endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
2046 struct __is_placeholder<placeholders::__ph<_Np> >
2047 : public integral_constant<int, _Np> {};
2050 #ifndef _LIBCPP_CXX03_LANG
2052 template <class _Tp, class _Uj>
2053 inline _LIBCPP_INLINE_VISIBILITY
2055 __mu(reference_wrapper<_Tp> __t, _Uj&)
2060 template <class _Ti, class ..._Uj, size_t ..._Indx>
2061 inline _LIBCPP_INLINE_VISIBILITY
2062 typename __invoke_of<_Ti&, _Uj...>::type
2063 __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
2065 return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
2068 template <class _Ti, class ..._Uj>
2069 inline _LIBCPP_INLINE_VISIBILITY
2070 typename __lazy_enable_if
2072 is_bind_expression<_Ti>::value,
2073 __invoke_of<_Ti&, _Uj...>
2075 __mu(_Ti& __ti, tuple<_Uj...>& __uj)
2077 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
2078 return __mu_expand(__ti, __uj, __indices());
2081 template <bool IsPh, class _Ti, class _Uj>
2082 struct __mu_return2 {};
2084 template <class _Ti, class _Uj>
2085 struct __mu_return2<true, _Ti, _Uj>
2087 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
2090 template <class _Ti, class _Uj>
2091 inline _LIBCPP_INLINE_VISIBILITY
2094 0 < is_placeholder<_Ti>::value,
2095 typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
2097 __mu(_Ti&, _Uj& __uj)
2099 const size_t _Indx = is_placeholder<_Ti>::value - 1;
2100 return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
2103 template <class _Ti, class _Uj>
2104 inline _LIBCPP_INLINE_VISIBILITY
2107 !is_bind_expression<_Ti>::value &&
2108 is_placeholder<_Ti>::value == 0 &&
2109 !__is_reference_wrapper<_Ti>::value,
2112 __mu(_Ti& __ti, _Uj&)
2117 template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
2119 struct ____mu_return;
2121 template <bool _Invokable, class _Ti, class ..._Uj>
2122 struct ____mu_return_invokable // false
2127 template <class _Ti, class ..._Uj>
2128 struct ____mu_return_invokable<true, _Ti, _Uj...>
2130 typedef typename __invoke_of<_Ti&, _Uj...>::type type;
2133 template <class _Ti, class ..._Uj>
2134 struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
2135 : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
2139 template <class _Ti, class _TupleUj>
2140 struct ____mu_return<_Ti, false, false, true, _TupleUj>
2142 typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
2143 _TupleUj>::type&& type;
2146 template <class _Ti, class _TupleUj>
2147 struct ____mu_return<_Ti, true, false, false, _TupleUj>
2149 typedef typename _Ti::type& type;
2152 template <class _Ti, class _TupleUj>
2153 struct ____mu_return<_Ti, false, false, false, _TupleUj>
2158 template <class _Ti, class _TupleUj>
2160 : public ____mu_return<_Ti,
2161 __is_reference_wrapper<_Ti>::value,
2162 is_bind_expression<_Ti>::value,
2163 0 < is_placeholder<_Ti>::value &&
2164 is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
2169 template <class _Fp, class _BoundArgs, class _TupleUj>
2170 struct __is_valid_bind_return
2172 static const bool value = false;
2175 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2176 struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
2178 static const bool value = __invokable<_Fp,
2179 typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
2182 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2183 struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
2185 static const bool value = __invokable<_Fp,
2186 typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
2189 template <class _Fp, class _BoundArgs, class _TupleUj,
2190 bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
2191 struct __bind_return;
2193 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2194 struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
2196 typedef typename __invoke_of
2199 typename __mu_return
2207 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2208 struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
2210 typedef typename __invoke_of
2213 typename __mu_return
2221 template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
2222 inline _LIBCPP_INLINE_VISIBILITY
2223 typename __bind_return<_Fp, _BoundArgs, _Args>::type
2224 __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
2227 return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...);
2230 template<class _Fp, class ..._BoundArgs>
2232 : public __weak_result_type<typename decay<_Fp>::type>
2235 typedef typename decay<_Fp>::type _Fd;
2236 typedef tuple<typename decay<_BoundArgs>::type...> _Td;
2241 typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
2243 template <class _Gp, class ..._BA,
2244 class = typename enable_if
2246 is_constructible<_Fd, _Gp>::value &&
2247 !is_same<typename remove_reference<_Gp>::type,
2250 _LIBCPP_INLINE_VISIBILITY
2251 explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
2252 : __f_(_VSTD::forward<_Gp>(__f)),
2253 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
2255 template <class ..._Args>
2256 _LIBCPP_INLINE_VISIBILITY
2257 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
2258 operator()(_Args&& ...__args)
2260 return _VSTD::__apply_functor(__f_, __bound_args_, __indices(),
2261 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2264 template <class ..._Args>
2265 _LIBCPP_INLINE_VISIBILITY
2266 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
2267 operator()(_Args&& ...__args) const
2269 return _VSTD::__apply_functor(__f_, __bound_args_, __indices(),
2270 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2274 template<class _Fp, class ..._BoundArgs>
2275 struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
2277 template<class _Rp, class _Fp, class ..._BoundArgs>
2279 : public __bind<_Fp, _BoundArgs...>
2281 typedef __bind<_Fp, _BoundArgs...> base;
2282 typedef typename base::_Fd _Fd;
2283 typedef typename base::_Td _Td;
2285 typedef _Rp result_type;
2288 template <class _Gp, class ..._BA,
2289 class = typename enable_if
2291 is_constructible<_Fd, _Gp>::value &&
2292 !is_same<typename remove_reference<_Gp>::type,
2295 _LIBCPP_INLINE_VISIBILITY
2296 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
2297 : base(_VSTD::forward<_Gp>(__f),
2298 _VSTD::forward<_BA>(__bound_args)...) {}
2300 template <class ..._Args>
2301 _LIBCPP_INLINE_VISIBILITY
2304 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
2305 result_type>::value || is_void<_Rp>::value,
2308 operator()(_Args&& ...__args)
2310 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2311 return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
2314 template <class ..._Args>
2315 _LIBCPP_INLINE_VISIBILITY
2318 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
2319 result_type>::value || is_void<_Rp>::value,
2322 operator()(_Args&& ...__args) const
2324 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2325 return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
2329 template<class _Rp, class _Fp, class ..._BoundArgs>
2330 struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
2332 template<class _Fp, class ..._BoundArgs>
2333 inline _LIBCPP_INLINE_VISIBILITY
2334 __bind<_Fp, _BoundArgs...>
2335 bind(_Fp&& __f, _BoundArgs&&... __bound_args)
2337 typedef __bind<_Fp, _BoundArgs...> type;
2338 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2341 template<class _Rp, class _Fp, class ..._BoundArgs>
2342 inline _LIBCPP_INLINE_VISIBILITY
2343 __bind_r<_Rp, _Fp, _BoundArgs...>
2344 bind(_Fp&& __f, _BoundArgs&&... __bound_args)
2346 typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
2347 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2350 #endif // _LIBCPP_CXX03_LANG
2352 #if _LIBCPP_STD_VER > 14
2354 #define __cpp_lib_invoke 201411
2356 template <class _Fn, class ..._Args>
2357 result_of_t<_Fn&&(_Args&&...)>
2358 invoke(_Fn&& __f, _Args&&... __args)
2359 noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...)))
2361 return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
2364 template <class _DecayFunc>
2365 class _LIBCPP_TEMPLATE_VIS __not_fn_imp {
2369 __not_fn_imp() = delete;
2371 template <class ..._Args>
2372 _LIBCPP_INLINE_VISIBILITY
2373 auto operator()(_Args&& ...__args) &
2374 noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
2375 -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
2376 { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
2378 template <class ..._Args>
2379 _LIBCPP_INLINE_VISIBILITY
2380 auto operator()(_Args&& ...__args) &&
2381 noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
2382 -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
2383 { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
2385 template <class ..._Args>
2386 _LIBCPP_INLINE_VISIBILITY
2387 auto operator()(_Args&& ...__args) const&
2388 noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
2389 -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
2390 { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
2393 template <class ..._Args>
2394 _LIBCPP_INLINE_VISIBILITY
2395 auto operator()(_Args&& ...__args) const&&
2396 noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
2397 -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
2398 { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
2401 template <class _RawFunc,
2402 class = enable_if_t<!is_same<decay_t<_RawFunc>, __not_fn_imp>::value>>
2403 _LIBCPP_INLINE_VISIBILITY
2404 explicit __not_fn_imp(_RawFunc&& __rf)
2405 : __fd(_VSTD::forward<_RawFunc>(__rf)) {}
2407 template <class _RawFunc>
2408 friend inline _LIBCPP_INLINE_VISIBILITY
2409 __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&&);
2412 template <class _RawFunc>
2413 inline _LIBCPP_INLINE_VISIBILITY
2414 __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) {
2415 return __not_fn_imp<decay_t<_RawFunc>>(_VSTD::forward<_RawFunc>(__fn));
2420 // struct hash<T*> in <memory>
2422 _LIBCPP_END_NAMESPACE_STD
2424 #endif // _LIBCPP_FUNCTIONAL