2 //===------------------------ functional ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_FUNCTIONAL
12 #define _LIBCPP_FUNCTIONAL
20 template <class Arg, class Result>
23 typedef Arg argument_type;
24 typedef Result result_type;
27 template <class Arg1, class Arg2, class Result>
28 struct binary_function
30 typedef Arg1 first_argument_type;
31 typedef Arg2 second_argument_type;
32 typedef Result result_type;
36 class reference_wrapper
37 : public unary_function<T1, R> // if wrapping a unary functor
38 : public binary_function<T1, T2, R> // if wraping a binary functor
43 typedef see below result_type; // Not always defined
45 // construct/copy/destroy
46 reference_wrapper(T&) noexcept;
47 reference_wrapper(T&&) = delete; // do not bind to temps
48 reference_wrapper(const reference_wrapper<T>& x) noexcept;
51 reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;
54 operator T& () const noexcept;
55 T& get() const noexcept;
58 template <class... ArgTypes>
59 typename result_of<T&(ArgTypes&&...)>::type
60 operator() (ArgTypes&&...) const;
63 template <class T> reference_wrapper<T> ref(T& t) noexcept;
64 template <class T> void ref(const T&& t) = delete;
65 template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;
67 template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
68 template <class T> void cref(const T&& t) = delete;
69 template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
71 template <class T> // <class T=void> in C++14
72 struct plus : binary_function<T, T, T>
74 T operator()(const T& x, const T& y) const;
77 template <class T> // <class T=void> in C++14
78 struct minus : binary_function<T, T, T>
80 T operator()(const T& x, const T& y) const;
83 template <class T> // <class T=void> in C++14
84 struct multiplies : binary_function<T, T, T>
86 T operator()(const T& x, const T& y) const;
89 template <class T> // <class T=void> in C++14
90 struct divides : binary_function<T, T, T>
92 T operator()(const T& x, const T& y) const;
95 template <class T> // <class T=void> in C++14
96 struct modulus : binary_function<T, T, T>
98 T operator()(const T& x, const T& y) const;
101 template <class T> // <class T=void> in C++14
102 struct negate : unary_function<T, T>
104 T operator()(const T& x) const;
107 template <class T> // <class T=void> in C++14
108 struct equal_to : binary_function<T, T, bool>
110 bool operator()(const T& x, const T& y) const;
113 template <class T> // <class T=void> in C++14
114 struct not_equal_to : binary_function<T, T, bool>
116 bool operator()(const T& x, const T& y) const;
119 template <class T> // <class T=void> in C++14
120 struct greater : binary_function<T, T, bool>
122 bool operator()(const T& x, const T& y) const;
125 template <class T> // <class T=void> in C++14
126 struct less : binary_function<T, T, bool>
128 bool operator()(const T& x, const T& y) const;
131 template <class T> // <class T=void> in C++14
132 struct greater_equal : binary_function<T, T, bool>
134 bool operator()(const T& x, const T& y) const;
137 template <class T> // <class T=void> in C++14
138 struct less_equal : binary_function<T, T, bool>
140 bool operator()(const T& x, const T& y) const;
143 template <class T> // <class T=void> in C++14
144 struct logical_and : binary_function<T, T, bool>
146 bool operator()(const T& x, const T& y) const;
149 template <class T> // <class T=void> in C++14
150 struct logical_or : binary_function<T, T, bool>
152 bool operator()(const T& x, const T& y) const;
155 template <class T> // <class T=void> in C++14
156 struct logical_not : unary_function<T, bool>
158 bool operator()(const T& x) const;
161 template <class T> // <class T=void> in C++14
162 struct bit_and : unary_function<T, bool>
164 bool operator()(const T& x, const T& y) const;
167 template <class T> // <class T=void> in C++14
168 struct bit_or : unary_function<T, bool>
170 bool operator()(const T& x, const T& y) const;
173 template <class T> // <class T=void> in C++14
174 struct bit_xor : unary_function<T, bool>
176 bool operator()(const T& x, const T& y) const;
179 template <class T=void> // C++14
180 struct bit_xor : unary_function<T, bool>
182 bool operator()(const T& x) const;
185 template <class Predicate>
187 : public unary_function<typename Predicate::argument_type, bool>
190 explicit unary_negate(const Predicate& pred);
191 bool operator()(const typename Predicate::argument_type& x) const;
194 template <class Predicate> unary_negate<Predicate> not1(const Predicate& pred);
196 template <class Predicate>
198 : public binary_function<typename Predicate::first_argument_type,
199 typename Predicate::second_argument_type,
203 explicit binary_negate(const Predicate& pred);
204 bool operator()(const typename Predicate::first_argument_type& x,
205 const typename Predicate::second_argument_type& y) const;
208 template <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);
210 template<class T> struct is_bind_expression;
211 template<class T> struct is_placeholder;
213 template<class Fn, class... BoundArgs>
214 unspecified bind(Fn&&, BoundArgs&&...);
215 template<class R, class Fn, class... BoundArgs>
216 unspecified bind(Fn&&, BoundArgs&&...);
218 namespace placeholders {
219 // M is the implementation-defined number of placeholders
220 extern unspecified _1;
221 extern unspecified _2;
225 extern unspecified _Mp;
228 template <class Operation>
230 : public unary_function<typename Operation::second_argument_type,
231 typename Operation::result_type>
235 typename Operation::first_argument_type value;
237 binder1st(const Operation& x, const typename Operation::first_argument_type y);
238 typename Operation::result_type operator()( typename Operation::second_argument_type& x) const;
239 typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
242 template <class Operation, class T>
243 binder1st<Operation> bind1st(const Operation& op, const T& x);
245 template <class Operation>
247 : public unary_function<typename Operation::first_argument_type,
248 typename Operation::result_type>
252 typename Operation::second_argument_type value;
254 binder2nd(const Operation& x, const typename Operation::second_argument_type y);
255 typename Operation::result_type operator()( typename Operation::first_argument_type& x) const;
256 typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
259 template <class Operation, class T>
260 binder2nd<Operation> bind2nd(const Operation& op, const T& x);
262 template <class Arg, class Result>
263 class pointer_to_unary_function : public unary_function<Arg, Result>
266 explicit pointer_to_unary_function(Result (*f)(Arg));
267 Result operator()(Arg x) const;
270 template <class Arg, class Result>
271 pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));
273 template <class Arg1, class Arg2, class Result>
274 class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
277 explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
278 Result operator()(Arg1 x, Arg2 y) const;
281 template <class Arg1, class Arg2, class Result>
282 pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));
284 template<class S, class T>
285 class mem_fun_t : public unary_function<T*, S>
288 explicit mem_fun_t(S (T::*p)());
289 S operator()(T* p) const;
292 template<class S, class T, class A>
293 class mem_fun1_t : public binary_function<T*, A, S>
296 explicit mem_fun1_t(S (T::*p)(A));
297 S operator()(T* p, A x) const;
300 template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)());
301 template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
303 template<class S, class T>
304 class mem_fun_ref_t : public unary_function<T, S>
307 explicit mem_fun_ref_t(S (T::*p)());
308 S operator()(T& p) const;
311 template<class S, class T, class A>
312 class mem_fun1_ref_t : public binary_function<T, A, S>
315 explicit mem_fun1_ref_t(S (T::*p)(A));
316 S operator()(T& p, A x) const;
319 template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)());
320 template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));
322 template <class S, class T>
323 class const_mem_fun_t : public unary_function<const T*, S>
326 explicit const_mem_fun_t(S (T::*p)() const);
327 S operator()(const T* p) const;
330 template <class S, class T, class A>
331 class const_mem_fun1_t : public binary_function<const T*, A, S>
334 explicit const_mem_fun1_t(S (T::*p)(A) const);
335 S operator()(const T* p, A x) const;
338 template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const);
339 template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);
341 template <class S, class T>
342 class const_mem_fun_ref_t : public unary_function<T, S>
345 explicit const_mem_fun_ref_t(S (T::*p)() const);
346 S operator()(const T& p) const;
349 template <class S, class T, class A>
350 class const_mem_fun1_ref_t : public binary_function<T, A, S>
353 explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
354 S operator()(const T& p, A x) const;
357 template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const);
358 template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
360 template<class R, class T> unspecified mem_fn(R T::*);
362 class bad_function_call
367 template<class> class function; // undefined
369 template<class R, class... ArgTypes>
370 class function<R(ArgTypes...)>
371 : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
372 // ArgTypes contains T1
373 : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
374 // ArgTypes contains T1 and T2
377 typedef R result_type;
379 // construct/copy/destroy:
381 function(nullptr_t) noexcept;
382 function(const function&);
383 function(function&&) noexcept;
386 template<Allocator Alloc>
387 function(allocator_arg_t, const Alloc&) noexcept;
388 template<Allocator Alloc>
389 function(allocator_arg_t, const Alloc&, nullptr_t) noexcept;
390 template<Allocator Alloc>
391 function(allocator_arg_t, const Alloc&, const function&);
392 template<Allocator Alloc>
393 function(allocator_arg_t, const Alloc&, function&&);
394 template<class F, Allocator Alloc>
395 function(allocator_arg_t, const Alloc&, F);
397 function& operator=(const function&);
398 function& operator=(function&&) noexcept;
399 function& operator=(nullptr_t) noexcept;
401 function& operator=(F&&);
403 function& operator=(reference_wrapper<F>) noexcept;
407 // function modifiers:
408 void swap(function&) noexcept;
409 template<class F, class Alloc>
410 void assign(F&&, const Alloc&);
412 // function capacity:
413 explicit operator bool() const noexcept;
415 // function invocation:
416 R operator()(ArgTypes...) const;
418 // function target access:
419 const std::type_info& target_type() const noexcept;
420 template <typename T> T* target() noexcept;
421 template <typename T> const T* target() const noexcept;
424 // Null pointer comparisons:
425 template <class R, class ... ArgTypes>
426 bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
428 template <class R, class ... ArgTypes>
429 bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
431 template <class R, class ... ArgTypes>
432 bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
434 template <class R, class ... ArgTypes>
435 bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
437 // specialized algorithms:
438 template <class R, class ... ArgTypes>
439 void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
441 template <class T> struct hash;
443 template <> struct hash<bool>;
444 template <> struct hash<char>;
445 template <> struct hash<signed char>;
446 template <> struct hash<unsigned char>;
447 template <> struct hash<char16_t>;
448 template <> struct hash<char32_t>;
449 template <> struct hash<wchar_t>;
450 template <> struct hash<short>;
451 template <> struct hash<unsigned short>;
452 template <> struct hash<int>;
453 template <> struct hash<unsigned int>;
454 template <> struct hash<long>;
455 template <> struct hash<long long>;
456 template <> struct hash<unsigned long>;
457 template <> struct hash<unsigned long long>;
459 template <> struct hash<float>;
460 template <> struct hash<double>;
461 template <> struct hash<long double>;
463 template<class T> struct hash<T*>;
467 POLICY: For non-variadic implementations, the number of arguments is limited
468 to 3. It is hoped that the need for non-variadic implementations
474 #include <type_traits>
480 #include <__functional_base>
482 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
483 #pragma GCC system_header
486 _LIBCPP_BEGIN_NAMESPACE_STD
488 #if _LIBCPP_STD_VER > 11
489 template <class _Tp = void>
493 struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp>
495 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
496 _Tp operator()(const _Tp& __x, const _Tp& __y) const
500 #if _LIBCPP_STD_VER > 11
502 struct _LIBCPP_TYPE_VIS_ONLY plus<void>
504 template <class _T1, class _T2>
505 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
506 auto operator()(_T1&& __t, _T2&& __u) const
507 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
508 -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
509 { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
510 typedef void is_transparent;
515 #if _LIBCPP_STD_VER > 11
516 template <class _Tp = void>
520 struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp>
522 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
523 _Tp operator()(const _Tp& __x, const _Tp& __y) const
527 #if _LIBCPP_STD_VER > 11
529 struct _LIBCPP_TYPE_VIS_ONLY minus<void>
531 template <class _T1, class _T2>
532 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
533 auto operator()(_T1&& __t, _T2&& __u) const
534 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
535 -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
536 { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
537 typedef void is_transparent;
542 #if _LIBCPP_STD_VER > 11
543 template <class _Tp = void>
547 struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp>
549 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
550 _Tp operator()(const _Tp& __x, const _Tp& __y) const
554 #if _LIBCPP_STD_VER > 11
556 struct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
558 template <class _T1, class _T2>
559 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
560 auto operator()(_T1&& __t, _T2&& __u) const
561 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
562 -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
563 { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
564 typedef void is_transparent;
569 #if _LIBCPP_STD_VER > 11
570 template <class _Tp = void>
574 struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp>
576 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
577 _Tp operator()(const _Tp& __x, const _Tp& __y) const
581 #if _LIBCPP_STD_VER > 11
583 struct _LIBCPP_TYPE_VIS_ONLY divides<void>
585 template <class _T1, class _T2>
586 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
587 auto operator()(_T1&& __t, _T2&& __u) const
588 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
589 -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
590 { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
591 typedef void is_transparent;
596 #if _LIBCPP_STD_VER > 11
597 template <class _Tp = void>
601 struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp>
603 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
604 _Tp operator()(const _Tp& __x, const _Tp& __y) const
608 #if _LIBCPP_STD_VER > 11
610 struct _LIBCPP_TYPE_VIS_ONLY modulus<void>
612 template <class _T1, class _T2>
613 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
614 auto operator()(_T1&& __t, _T2&& __u) const
615 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
616 -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
617 { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
618 typedef void is_transparent;
623 #if _LIBCPP_STD_VER > 11
624 template <class _Tp = void>
628 struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp>
630 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
631 _Tp operator()(const _Tp& __x) const
635 #if _LIBCPP_STD_VER > 11
637 struct _LIBCPP_TYPE_VIS_ONLY negate<void>
640 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
641 auto operator()(_Tp&& __x) const
642 _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
643 -> decltype (- _VSTD::forward<_Tp>(__x))
644 { return - _VSTD::forward<_Tp>(__x); }
645 typedef void is_transparent;
650 #if _LIBCPP_STD_VER > 11
651 template <class _Tp = void>
655 struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool>
657 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
658 bool operator()(const _Tp& __x, const _Tp& __y) const
662 #if _LIBCPP_STD_VER > 11
664 struct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
666 template <class _T1, class _T2>
667 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
668 auto operator()(_T1&& __t, _T2&& __u) const
669 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
670 -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
671 { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
672 typedef void is_transparent;
677 #if _LIBCPP_STD_VER > 11
678 template <class _Tp = void>
682 struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool>
684 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
685 bool operator()(const _Tp& __x, const _Tp& __y) const
689 #if _LIBCPP_STD_VER > 11
691 struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
693 template <class _T1, class _T2>
694 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
695 auto operator()(_T1&& __t, _T2&& __u) const
696 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
697 -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
698 { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
699 typedef void is_transparent;
704 #if _LIBCPP_STD_VER > 11
705 template <class _Tp = void>
709 struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool>
711 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
712 bool operator()(const _Tp& __x, const _Tp& __y) const
716 #if _LIBCPP_STD_VER > 11
718 struct _LIBCPP_TYPE_VIS_ONLY greater<void>
720 template <class _T1, class _T2>
721 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
722 auto operator()(_T1&& __t, _T2&& __u) const
723 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
724 -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
725 { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
726 typedef void is_transparent;
731 // less in <__functional_base>
733 #if _LIBCPP_STD_VER > 11
734 template <class _Tp = void>
738 struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool>
740 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
741 bool operator()(const _Tp& __x, const _Tp& __y) const
745 #if _LIBCPP_STD_VER > 11
747 struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
749 template <class _T1, class _T2>
750 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
751 auto operator()(_T1&& __t, _T2&& __u) const
752 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
753 -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
754 { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
755 typedef void is_transparent;
760 #if _LIBCPP_STD_VER > 11
761 template <class _Tp = void>
765 struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool>
767 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
768 bool operator()(const _Tp& __x, const _Tp& __y) const
772 #if _LIBCPP_STD_VER > 11
774 struct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
776 template <class _T1, class _T2>
777 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
778 auto operator()(_T1&& __t, _T2&& __u) const
779 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
780 -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
781 { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
782 typedef void is_transparent;
787 #if _LIBCPP_STD_VER > 11
788 template <class _Tp = void>
792 struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool>
794 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
795 bool operator()(const _Tp& __x, const _Tp& __y) const
799 #if _LIBCPP_STD_VER > 11
801 struct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
803 template <class _T1, class _T2>
804 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
805 auto operator()(_T1&& __t, _T2&& __u) const
806 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
807 -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
808 { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
809 typedef void is_transparent;
814 #if _LIBCPP_STD_VER > 11
815 template <class _Tp = void>
819 struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool>
821 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
822 bool operator()(const _Tp& __x, const _Tp& __y) const
826 #if _LIBCPP_STD_VER > 11
828 struct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
830 template <class _T1, class _T2>
831 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
832 auto operator()(_T1&& __t, _T2&& __u) const
833 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
834 -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
835 { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
836 typedef void is_transparent;
841 #if _LIBCPP_STD_VER > 11
842 template <class _Tp = void>
846 struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool>
848 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
849 bool operator()(const _Tp& __x) const
853 #if _LIBCPP_STD_VER > 11
855 struct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
858 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
859 auto operator()(_Tp&& __x) const
860 _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
861 -> decltype (!_VSTD::forward<_Tp>(__x))
862 { return !_VSTD::forward<_Tp>(__x); }
863 typedef void is_transparent;
868 #if _LIBCPP_STD_VER > 11
869 template <class _Tp = void>
873 struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp>
875 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
876 _Tp operator()(const _Tp& __x, const _Tp& __y) const
880 #if _LIBCPP_STD_VER > 11
882 struct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
884 template <class _T1, class _T2>
885 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
886 auto operator()(_T1&& __t, _T2&& __u) const
887 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
888 -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
889 { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
890 typedef void is_transparent;
895 #if _LIBCPP_STD_VER > 11
896 template <class _Tp = void>
900 struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp>
902 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
903 _Tp operator()(const _Tp& __x, const _Tp& __y) const
907 #if _LIBCPP_STD_VER > 11
909 struct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
911 template <class _T1, class _T2>
912 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
913 auto operator()(_T1&& __t, _T2&& __u) const
914 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
915 -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
916 { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
917 typedef void is_transparent;
922 #if _LIBCPP_STD_VER > 11
923 template <class _Tp = void>
927 struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp>
929 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
930 _Tp operator()(const _Tp& __x, const _Tp& __y) const
934 #if _LIBCPP_STD_VER > 11
936 struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
938 template <class _T1, class _T2>
939 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
940 auto operator()(_T1&& __t, _T2&& __u) const
941 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
942 -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
943 { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
944 typedef void is_transparent;
949 #if _LIBCPP_STD_VER > 11
950 template <class _Tp = void>
951 struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp>
953 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
954 _Tp operator()(const _Tp& __x) const
959 struct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
962 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
963 auto operator()(_Tp&& __x) const
964 _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
965 -> decltype (~_VSTD::forward<_Tp>(__x))
966 { return ~_VSTD::forward<_Tp>(__x); }
967 typedef void is_transparent;
971 template <class _Predicate>
972 class _LIBCPP_TYPE_VIS_ONLY unary_negate
973 : public unary_function<typename _Predicate::argument_type, bool>
977 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
978 explicit unary_negate(const _Predicate& __pred)
980 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
981 bool operator()(const typename _Predicate::argument_type& __x) const
982 {return !__pred_(__x);}
985 template <class _Predicate>
986 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
987 unary_negate<_Predicate>
988 not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
990 template <class _Predicate>
991 class _LIBCPP_TYPE_VIS_ONLY binary_negate
992 : public binary_function<typename _Predicate::first_argument_type,
993 typename _Predicate::second_argument_type,
998 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
999 binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
1001 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1002 bool operator()(const typename _Predicate::first_argument_type& __x,
1003 const typename _Predicate::second_argument_type& __y) const
1004 {return !__pred_(__x, __y);}
1007 template <class _Predicate>
1008 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1009 binary_negate<_Predicate>
1010 not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
1012 template <class __Operation>
1013 class _LIBCPP_TYPE_VIS_ONLY binder1st
1014 : public unary_function<typename __Operation::second_argument_type,
1015 typename __Operation::result_type>
1019 typename __Operation::first_argument_type value;
1021 _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
1022 const typename __Operation::first_argument_type __y)
1023 : op(__x), value(__y) {}
1024 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1025 (typename __Operation::second_argument_type& __x) const
1026 {return op(value, __x);}
1027 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1028 (const typename __Operation::second_argument_type& __x) const
1029 {return op(value, __x);}
1032 template <class __Operation, class _Tp>
1033 inline _LIBCPP_INLINE_VISIBILITY
1034 binder1st<__Operation>
1035 bind1st(const __Operation& __op, const _Tp& __x)
1036 {return binder1st<__Operation>(__op, __x);}
1038 template <class __Operation>
1039 class _LIBCPP_TYPE_VIS_ONLY binder2nd
1040 : public unary_function<typename __Operation::first_argument_type,
1041 typename __Operation::result_type>
1045 typename __Operation::second_argument_type value;
1047 _LIBCPP_INLINE_VISIBILITY
1048 binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
1049 : op(__x), value(__y) {}
1050 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1051 ( typename __Operation::first_argument_type& __x) const
1052 {return op(__x, value);}
1053 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1054 (const typename __Operation::first_argument_type& __x) const
1055 {return op(__x, value);}
1058 template <class __Operation, class _Tp>
1059 inline _LIBCPP_INLINE_VISIBILITY
1060 binder2nd<__Operation>
1061 bind2nd(const __Operation& __op, const _Tp& __x)
1062 {return binder2nd<__Operation>(__op, __x);}
1064 template <class _Arg, class _Result>
1065 class _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function
1066 : public unary_function<_Arg, _Result>
1068 _Result (*__f_)(_Arg);
1070 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
1072 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
1076 template <class _Arg, class _Result>
1077 inline _LIBCPP_INLINE_VISIBILITY
1078 pointer_to_unary_function<_Arg,_Result>
1079 ptr_fun(_Result (*__f)(_Arg))
1080 {return pointer_to_unary_function<_Arg,_Result>(__f);}
1082 template <class _Arg1, class _Arg2, class _Result>
1083 class _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function
1084 : public binary_function<_Arg1, _Arg2, _Result>
1086 _Result (*__f_)(_Arg1, _Arg2);
1088 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
1090 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
1091 {return __f_(__x, __y);}
1094 template <class _Arg1, class _Arg2, class _Result>
1095 inline _LIBCPP_INLINE_VISIBILITY
1096 pointer_to_binary_function<_Arg1,_Arg2,_Result>
1097 ptr_fun(_Result (*__f)(_Arg1,_Arg2))
1098 {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
1100 template<class _Sp, class _Tp>
1101 class _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp>
1105 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
1107 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
1108 {return (__p->*__p_)();}
1111 template<class _Sp, class _Tp, class _Ap>
1112 class _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
1114 _Sp (_Tp::*__p_)(_Ap);
1116 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
1118 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
1119 {return (__p->*__p_)(__x);}
1122 template<class _Sp, class _Tp>
1123 inline _LIBCPP_INLINE_VISIBILITY
1125 mem_fun(_Sp (_Tp::*__f)())
1126 {return mem_fun_t<_Sp,_Tp>(__f);}
1128 template<class _Sp, class _Tp, class _Ap>
1129 inline _LIBCPP_INLINE_VISIBILITY
1130 mem_fun1_t<_Sp,_Tp,_Ap>
1131 mem_fun(_Sp (_Tp::*__f)(_Ap))
1132 {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1134 template<class _Sp, class _Tp>
1135 class _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp>
1139 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
1141 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
1142 {return (__p.*__p_)();}
1145 template<class _Sp, class _Tp, class _Ap>
1146 class _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
1148 _Sp (_Tp::*__p_)(_Ap);
1150 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
1152 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
1153 {return (__p.*__p_)(__x);}
1156 template<class _Sp, class _Tp>
1157 inline _LIBCPP_INLINE_VISIBILITY
1158 mem_fun_ref_t<_Sp,_Tp>
1159 mem_fun_ref(_Sp (_Tp::*__f)())
1160 {return mem_fun_ref_t<_Sp,_Tp>(__f);}
1162 template<class _Sp, class _Tp, class _Ap>
1163 inline _LIBCPP_INLINE_VISIBILITY
1164 mem_fun1_ref_t<_Sp,_Tp,_Ap>
1165 mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
1166 {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1168 template <class _Sp, class _Tp>
1169 class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp>
1171 _Sp (_Tp::*__p_)() const;
1173 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
1175 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
1176 {return (__p->*__p_)();}
1179 template <class _Sp, class _Tp, class _Ap>
1180 class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
1182 _Sp (_Tp::*__p_)(_Ap) const;
1184 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
1186 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
1187 {return (__p->*__p_)(__x);}
1190 template <class _Sp, class _Tp>
1191 inline _LIBCPP_INLINE_VISIBILITY
1192 const_mem_fun_t<_Sp,_Tp>
1193 mem_fun(_Sp (_Tp::*__f)() const)
1194 {return const_mem_fun_t<_Sp,_Tp>(__f);}
1196 template <class _Sp, class _Tp, class _Ap>
1197 inline _LIBCPP_INLINE_VISIBILITY
1198 const_mem_fun1_t<_Sp,_Tp,_Ap>
1199 mem_fun(_Sp (_Tp::*__f)(_Ap) const)
1200 {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1202 template <class _Sp, class _Tp>
1203 class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
1205 _Sp (_Tp::*__p_)() const;
1207 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
1209 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
1210 {return (__p.*__p_)();}
1213 template <class _Sp, class _Tp, class _Ap>
1214 class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t
1215 : public binary_function<_Tp, _Ap, _Sp>
1217 _Sp (_Tp::*__p_)(_Ap) const;
1219 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
1221 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
1222 {return (__p.*__p_)(__x);}
1225 template <class _Sp, class _Tp>
1226 inline _LIBCPP_INLINE_VISIBILITY
1227 const_mem_fun_ref_t<_Sp,_Tp>
1228 mem_fun_ref(_Sp (_Tp::*__f)() const)
1229 {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
1231 template <class _Sp, class _Tp, class _Ap>
1232 inline _LIBCPP_INLINE_VISIBILITY
1233 const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
1234 mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
1235 {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1237 ////////////////////////////////////////////////////////////////////////////////
1239 //==============================================================================
1241 template <class _Tp>
1243 : public __weak_result_type<_Tp>
1252 _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}
1254 #ifndef _LIBCPP_HAS_NO_VARIADICS
1256 template <class... _ArgTypes>
1257 _LIBCPP_INLINE_VISIBILITY
1258 typename __invoke_return<type, _ArgTypes...>::type
1259 operator() (_ArgTypes&&... __args) const {
1260 return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
1264 template <class _A0>
1265 typename __invoke_return0<type, _A0>::type
1266 operator() (_A0& __a0) const {
1267 return __invoke(__f_, __a0);
1270 template <class _A0, class _A1>
1271 typename __invoke_return1<type, _A0, _A1>::type
1272 operator() (_A0& __a0, _A1& __a1) const {
1273 return __invoke(__f_, __a0, __a1);
1276 template <class _A0, class _A1, class _A2>
1277 typename __invoke_return2<type, _A0, _A1, _A2>::type
1278 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
1279 return __invoke(__f_, __a0, __a1, __a2);
1284 template<class _Rp, class _Tp>
1285 inline _LIBCPP_INLINE_VISIBILITY
1286 __mem_fn<_Rp _Tp::*>
1287 mem_fn(_Rp _Tp::* __pm)
1289 return __mem_fn<_Rp _Tp::*>(__pm);
1292 ////////////////////////////////////////////////////////////////////////////////
1294 //==============================================================================
1296 // bad_function_call
1298 class _LIBCPP_EXCEPTION_ABI bad_function_call
1303 template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
1305 namespace __function
1309 struct __maybe_derive_from_unary_function
1313 template<class _Rp, class _A1>
1314 struct __maybe_derive_from_unary_function<_Rp(_A1)>
1315 : public unary_function<_A1, _Rp>
1320 struct __maybe_derive_from_binary_function
1324 template<class _Rp, class _A1, class _A2>
1325 struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
1326 : public binary_function<_A1, _A2, _Rp>
1330 template <class _Fp>
1331 _LIBCPP_INLINE_VISIBILITY
1332 bool __not_null(_Fp const&) { return true; }
1334 template <class _Fp>
1335 _LIBCPP_INLINE_VISIBILITY
1336 bool __not_null(_Fp* __ptr) { return __ptr; }
1338 template <class _Ret, class _Class>
1339 _LIBCPP_INLINE_VISIBILITY
1340 bool __not_null(_Ret _Class::*__ptr) { return __ptr; }
1342 template <class _Fp>
1343 _LIBCPP_INLINE_VISIBILITY
1344 bool __not_null(function<_Fp> const& __f) { return !!__f; }
1346 } // namespace __function
1348 #ifndef _LIBCPP_HAS_NO_VARIADICS
1350 namespace __function {
1352 template<class _Fp> class __base;
1354 template<class _Rp, class ..._ArgTypes>
1355 class __base<_Rp(_ArgTypes...)>
1357 __base(const __base&);
1358 __base& operator=(const __base&);
1360 _LIBCPP_INLINE_VISIBILITY __base() {}
1361 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
1362 virtual __base* __clone() const = 0;
1363 virtual void __clone(__base*) const = 0;
1364 virtual void destroy() _NOEXCEPT = 0;
1365 virtual void destroy_deallocate() _NOEXCEPT = 0;
1366 virtual _Rp operator()(_ArgTypes&& ...) = 0;
1367 #ifndef _LIBCPP_NO_RTTI
1368 virtual const void* target(const type_info&) const _NOEXCEPT = 0;
1369 virtual const std::type_info& target_type() const _NOEXCEPT = 0;
1370 #endif // _LIBCPP_NO_RTTI
1373 template<class _FD, class _Alloc, class _FB> class __func;
1375 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1376 class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
1377 : public __base<_Rp(_ArgTypes...)>
1379 __compressed_pair<_Fp, _Alloc> __f_;
1381 _LIBCPP_INLINE_VISIBILITY
1382 explicit __func(_Fp&& __f)
1383 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1384 _VSTD::forward_as_tuple()) {}
1385 _LIBCPP_INLINE_VISIBILITY
1386 explicit __func(const _Fp& __f, const _Alloc& __a)
1387 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1388 _VSTD::forward_as_tuple(__a)) {}
1390 _LIBCPP_INLINE_VISIBILITY
1391 explicit __func(const _Fp& __f, _Alloc&& __a)
1392 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1393 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1395 _LIBCPP_INLINE_VISIBILITY
1396 explicit __func(_Fp&& __f, _Alloc&& __a)
1397 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1398 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1399 virtual __base<_Rp(_ArgTypes...)>* __clone() const;
1400 virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
1401 virtual void destroy() _NOEXCEPT;
1402 virtual void destroy_deallocate() _NOEXCEPT;
1403 virtual _Rp operator()(_ArgTypes&& ... __arg);
1404 #ifndef _LIBCPP_NO_RTTI
1405 virtual const void* target(const type_info&) const _NOEXCEPT;
1406 virtual const std::type_info& target_type() const _NOEXCEPT;
1407 #endif // _LIBCPP_NO_RTTI
1410 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1411 __base<_Rp(_ArgTypes...)>*
1412 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
1414 typedef allocator_traits<_Alloc> __alloc_traits;
1415 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1416 _Ap __a(__f_.second());
1417 typedef __allocator_destructor<_Ap> _Dp;
1418 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1419 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
1420 return __hold.release();
1423 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1425 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
1427 ::new (__p) __func(__f_.first(), __f_.second());
1430 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1432 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
1434 __f_.~__compressed_pair<_Fp, _Alloc>();
1437 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1439 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
1441 typedef allocator_traits<_Alloc> __alloc_traits;
1442 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1443 _Ap __a(__f_.second());
1444 __f_.~__compressed_pair<_Fp, _Alloc>();
1445 __a.deallocate(this, 1);
1448 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1450 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
1452 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1453 return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
1456 #ifndef _LIBCPP_NO_RTTI
1458 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1460 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
1462 if (__ti == typeid(_Fp))
1463 return &__f_.first();
1464 return (const void*)0;
1467 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1468 const std::type_info&
1469 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1474 #endif // _LIBCPP_NO_RTTI
1478 template<class _Rp, class ..._ArgTypes>
1479 class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
1480 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
1481 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
1483 typedef __function::__base<_Rp(_ArgTypes...)> __base;
1484 typename aligned_storage<3*sizeof(void*)>::type __buf_;
1487 template <class _Fp, bool = !is_same<_Fp, function>::value &&
1488 __invokable<_Fp&, _ArgTypes...>::value>
1490 template <class _Fp>
1491 struct __callable<_Fp, true>
1493 static const bool value = is_same<void, _Rp>::value ||
1494 is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
1497 template <class _Fp>
1498 struct __callable<_Fp, false>
1500 static const bool value = false;
1503 typedef _Rp result_type;
1505 // construct/copy/destroy:
1506 _LIBCPP_INLINE_VISIBILITY
1507 function() _NOEXCEPT : __f_(0) {}
1508 _LIBCPP_INLINE_VISIBILITY
1509 function(nullptr_t) _NOEXCEPT : __f_(0) {}
1510 function(const function&);
1511 function(function&&) _NOEXCEPT;
1513 function(_Fp, typename enable_if
1515 __callable<_Fp>::value &&
1516 !is_same<_Fp, function>::value
1519 template<class _Alloc>
1520 _LIBCPP_INLINE_VISIBILITY
1521 function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
1522 template<class _Alloc>
1523 _LIBCPP_INLINE_VISIBILITY
1524 function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
1525 template<class _Alloc>
1526 function(allocator_arg_t, const _Alloc&, const function&);
1527 template<class _Alloc>
1528 function(allocator_arg_t, const _Alloc&, function&&);
1529 template<class _Fp, class _Alloc>
1530 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1531 typename enable_if<__callable<_Fp>::value>::type* = 0);
1533 function& operator=(const function&);
1534 function& operator=(function&&) _NOEXCEPT;
1535 function& operator=(nullptr_t) _NOEXCEPT;
1539 __callable<typename decay<_Fp>::type>::value &&
1540 !is_same<typename remove_reference<_Fp>::type, function>::value,
1547 // function modifiers:
1548 void swap(function&) _NOEXCEPT;
1549 template<class _Fp, class _Alloc>
1550 _LIBCPP_INLINE_VISIBILITY
1551 void assign(_Fp&& __f, const _Alloc& __a)
1552 {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
1554 // function capacity:
1555 _LIBCPP_INLINE_VISIBILITY
1556 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
1558 // deleted overloads close possible hole in the type system
1559 template<class _R2, class... _ArgTypes2>
1560 bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
1561 template<class _R2, class... _ArgTypes2>
1562 bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
1564 // function invocation:
1565 _Rp operator()(_ArgTypes...) const;
1567 #ifndef _LIBCPP_NO_RTTI
1568 // function target access:
1569 const std::type_info& target_type() const _NOEXCEPT;
1570 template <typename _Tp> _Tp* target() _NOEXCEPT;
1571 template <typename _Tp> const _Tp* target() const _NOEXCEPT;
1572 #endif // _LIBCPP_NO_RTTI
1575 template<class _Rp, class ..._ArgTypes>
1576 function<_Rp(_ArgTypes...)>::function(const function& __f)
1580 else if (__f.__f_ == (const __base*)&__f.__buf_)
1582 __f_ = (__base*)&__buf_;
1583 __f.__f_->__clone(__f_);
1586 __f_ = __f.__f_->__clone();
1589 template<class _Rp, class ..._ArgTypes>
1590 template <class _Alloc>
1591 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1592 const function& __f)
1596 else if (__f.__f_ == (const __base*)&__f.__buf_)
1598 __f_ = (__base*)&__buf_;
1599 __f.__f_->__clone(__f_);
1602 __f_ = __f.__f_->__clone();
1605 template<class _Rp, class ..._ArgTypes>
1606 function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
1610 else if (__f.__f_ == (__base*)&__f.__buf_)
1612 __f_ = (__base*)&__buf_;
1613 __f.__f_->__clone(__f_);
1622 template<class _Rp, class ..._ArgTypes>
1623 template <class _Alloc>
1624 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
1629 else if (__f.__f_ == (__base*)&__f.__buf_)
1631 __f_ = (__base*)&__buf_;
1632 __f.__f_->__clone(__f_);
1641 template<class _Rp, class ..._ArgTypes>
1642 template <class _Fp>
1643 function<_Rp(_ArgTypes...)>::function(_Fp __f,
1646 __callable<_Fp>::value &&
1647 !is_same<_Fp, function>::value
1651 if (__function::__not_null(__f))
1653 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
1654 if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
1656 __f_ = (__base*)&__buf_;
1657 ::new (__f_) _FF(_VSTD::move(__f));
1661 typedef allocator<_FF> _Ap;
1663 typedef __allocator_destructor<_Ap> _Dp;
1664 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1665 ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
1666 __f_ = __hold.release();
1671 template<class _Rp, class ..._ArgTypes>
1672 template <class _Fp, class _Alloc>
1673 function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1674 typename enable_if<__callable<_Fp>::value>::type*)
1677 typedef allocator_traits<_Alloc> __alloc_traits;
1678 if (__function::__not_null(__f))
1680 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
1681 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1683 if (sizeof(_FF) <= sizeof(__buf_) &&
1684 is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
1686 __f_ = (__base*)&__buf_;
1687 ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));
1691 typedef __allocator_destructor<_Ap> _Dp;
1692 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1693 ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
1694 __f_ = __hold.release();
1699 template<class _Rp, class ..._ArgTypes>
1700 function<_Rp(_ArgTypes...)>&
1701 function<_Rp(_ArgTypes...)>::operator=(const function& __f)
1703 function(__f).swap(*this);
1707 template<class _Rp, class ..._ArgTypes>
1708 function<_Rp(_ArgTypes...)>&
1709 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
1711 if (__f_ == (__base*)&__buf_)
1714 __f_->destroy_deallocate();
1718 else if (__f.__f_ == (__base*)&__f.__buf_)
1720 __f_ = (__base*)&__buf_;
1721 __f.__f_->__clone(__f_);
1731 template<class _Rp, class ..._ArgTypes>
1732 function<_Rp(_ArgTypes...)>&
1733 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
1735 if (__f_ == (__base*)&__buf_)
1738 __f_->destroy_deallocate();
1743 template<class _Rp, class ..._ArgTypes>
1744 template <class _Fp>
1747 function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
1748 !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
1749 function<_Rp(_ArgTypes...)>&
1751 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
1753 function(_VSTD::forward<_Fp>(__f)).swap(*this);
1757 template<class _Rp, class ..._ArgTypes>
1758 function<_Rp(_ArgTypes...)>::~function()
1760 if (__f_ == (__base*)&__buf_)
1763 __f_->destroy_deallocate();
1766 template<class _Rp, class ..._ArgTypes>
1768 function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
1770 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1772 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1773 __base* __t = (__base*)&__tempbuf;
1777 __f.__f_->__clone((__base*)&__buf_);
1778 __f.__f_->destroy();
1780 __f_ = (__base*)&__buf_;
1781 __t->__clone((__base*)&__f.__buf_);
1783 __f.__f_ = (__base*)&__f.__buf_;
1785 else if (__f_ == (__base*)&__buf_)
1787 __f_->__clone((__base*)&__f.__buf_);
1790 __f.__f_ = (__base*)&__f.__buf_;
1792 else if (__f.__f_ == (__base*)&__f.__buf_)
1794 __f.__f_->__clone((__base*)&__buf_);
1795 __f.__f_->destroy();
1797 __f_ = (__base*)&__buf_;
1800 _VSTD::swap(__f_, __f.__f_);
1803 template<class _Rp, class ..._ArgTypes>
1805 function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
1807 #ifndef _LIBCPP_NO_EXCEPTIONS
1809 throw bad_function_call();
1810 #endif // _LIBCPP_NO_EXCEPTIONS
1811 return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
1814 #ifndef _LIBCPP_NO_RTTI
1816 template<class _Rp, class ..._ArgTypes>
1817 const std::type_info&
1818 function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
1821 return typeid(void);
1822 return __f_->target_type();
1825 template<class _Rp, class ..._ArgTypes>
1826 template <typename _Tp>
1828 function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
1832 return (_Tp*)__f_->target(typeid(_Tp));
1835 template<class _Rp, class ..._ArgTypes>
1836 template <typename _Tp>
1838 function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
1841 return (const _Tp*)0;
1842 return (const _Tp*)__f_->target(typeid(_Tp));
1845 #endif // _LIBCPP_NO_RTTI
1847 template <class _Rp, class... _ArgTypes>
1848 inline _LIBCPP_INLINE_VISIBILITY
1850 operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
1852 template <class _Rp, class... _ArgTypes>
1853 inline _LIBCPP_INLINE_VISIBILITY
1855 operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
1857 template <class _Rp, class... _ArgTypes>
1858 inline _LIBCPP_INLINE_VISIBILITY
1860 operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
1862 template <class _Rp, class... _ArgTypes>
1863 inline _LIBCPP_INLINE_VISIBILITY
1865 operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
1867 template <class _Rp, class... _ArgTypes>
1868 inline _LIBCPP_INLINE_VISIBILITY
1870 swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
1871 {return __x.swap(__y);}
1873 #else // _LIBCPP_HAS_NO_VARIADICS
1875 #include <__functional_03>
1879 ////////////////////////////////////////////////////////////////////////////////
1881 //==============================================================================
1883 template<class _Tp> struct __is_bind_expression : public false_type {};
1884 template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
1885 : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
1887 template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
1888 template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
1889 : public __is_placeholder<typename remove_cv<_Tp>::type> {};
1891 namespace placeholders
1894 template <int _Np> struct __ph {};
1896 _LIBCPP_FUNC_VIS extern __ph<1> _1;
1897 _LIBCPP_FUNC_VIS extern __ph<2> _2;
1898 _LIBCPP_FUNC_VIS extern __ph<3> _3;
1899 _LIBCPP_FUNC_VIS extern __ph<4> _4;
1900 _LIBCPP_FUNC_VIS extern __ph<5> _5;
1901 _LIBCPP_FUNC_VIS extern __ph<6> _6;
1902 _LIBCPP_FUNC_VIS extern __ph<7> _7;
1903 _LIBCPP_FUNC_VIS extern __ph<8> _8;
1904 _LIBCPP_FUNC_VIS extern __ph<9> _9;
1905 _LIBCPP_FUNC_VIS extern __ph<10> _10;
1910 struct __is_placeholder<placeholders::__ph<_Np> >
1911 : public integral_constant<int, _Np> {};
1914 #ifndef _LIBCPP_HAS_NO_VARIADICS
1916 template <class _Tp, class _Uj>
1917 inline _LIBCPP_INLINE_VISIBILITY
1919 __mu(reference_wrapper<_Tp> __t, _Uj&)
1924 template <class _Ti, class ..._Uj, size_t ..._Indx>
1925 inline _LIBCPP_INLINE_VISIBILITY
1926 typename __invoke_of<_Ti&, _Uj...>::type
1927 __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
1929 return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
1932 template <class _Ti, class ..._Uj>
1933 inline _LIBCPP_INLINE_VISIBILITY
1934 typename __lazy_enable_if
1936 is_bind_expression<_Ti>::value,
1937 __invoke_of<_Ti&, _Uj...>
1939 __mu(_Ti& __ti, tuple<_Uj...>& __uj)
1941 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
1942 return __mu_expand(__ti, __uj, __indices());
1945 template <bool IsPh, class _Ti, class _Uj>
1946 struct __mu_return2 {};
1948 template <class _Ti, class _Uj>
1949 struct __mu_return2<true, _Ti, _Uj>
1951 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
1954 template <class _Ti, class _Uj>
1955 inline _LIBCPP_INLINE_VISIBILITY
1958 0 < is_placeholder<_Ti>::value,
1959 typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
1961 __mu(_Ti&, _Uj& __uj)
1963 const size_t _Indx = is_placeholder<_Ti>::value - 1;
1964 return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
1967 template <class _Ti, class _Uj>
1968 inline _LIBCPP_INLINE_VISIBILITY
1971 !is_bind_expression<_Ti>::value &&
1972 is_placeholder<_Ti>::value == 0 &&
1973 !__is_reference_wrapper<_Ti>::value,
1976 __mu(_Ti& __ti, _Uj&)
1981 template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
1983 struct ____mu_return;
1985 template <bool _Invokable, class _Ti, class ..._Uj>
1986 struct ____mu_return_invokable // false
1991 template <class _Ti, class ..._Uj>
1992 struct ____mu_return_invokable<true, _Ti, _Uj...>
1994 typedef typename __invoke_of<_Ti&, _Uj...>::type type;
1997 template <class _Ti, class ..._Uj>
1998 struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
1999 : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
2003 template <class _Ti, class _TupleUj>
2004 struct ____mu_return<_Ti, false, false, true, _TupleUj>
2006 typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
2007 _TupleUj>::type&& type;
2010 template <class _Ti, class _TupleUj>
2011 struct ____mu_return<_Ti, true, false, false, _TupleUj>
2013 typedef typename _Ti::type& type;
2016 template <class _Ti, class _TupleUj>
2017 struct ____mu_return<_Ti, false, false, false, _TupleUj>
2022 template <class _Ti, class _TupleUj>
2024 : public ____mu_return<_Ti,
2025 __is_reference_wrapper<_Ti>::value,
2026 is_bind_expression<_Ti>::value,
2027 0 < is_placeholder<_Ti>::value &&
2028 is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
2033 template <class _Fp, class _BoundArgs, class _TupleUj>
2034 struct __is_valid_bind_return
2036 static const bool value = false;
2039 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2040 struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
2042 static const bool value = __invokable<_Fp,
2043 typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
2046 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2047 struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
2049 static const bool value = __invokable<_Fp,
2050 typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
2053 template <class _Fp, class _BoundArgs, class _TupleUj,
2054 bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
2055 struct __bind_return;
2057 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2058 struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
2060 typedef typename __invoke_of
2063 typename __mu_return
2071 template <class _Fp, class ..._BoundArgs, class _TupleUj>
2072 struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
2074 typedef typename __invoke_of
2077 typename __mu_return
2085 template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
2086 inline _LIBCPP_INLINE_VISIBILITY
2087 typename __bind_return<_Fp, _BoundArgs, _Args>::type
2088 __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
2091 return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
2094 template<class _Fp, class ..._BoundArgs>
2096 : public __weak_result_type<typename decay<_Fp>::type>
2099 typedef typename decay<_Fp>::type _Fd;
2100 typedef tuple<typename decay<_BoundArgs>::type...> _Td;
2105 typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
2107 #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2109 _LIBCPP_INLINE_VISIBILITY
2110 __bind(const __bind& __b)
2112 __bound_args_(__b.__bound_args_) {}
2114 _LIBCPP_INLINE_VISIBILITY
2115 __bind& operator=(const __bind& __b)
2118 __bound_args_ = __b.__bound_args_;
2122 _LIBCPP_INLINE_VISIBILITY
2123 __bind(__bind&& __b)
2124 : __f_(_VSTD::move(__b.__f_)),
2125 __bound_args_(_VSTD::move(__b.__bound_args_)) {}
2127 _LIBCPP_INLINE_VISIBILITY
2128 __bind& operator=(__bind&& __b)
2130 __f_ = _VSTD::move(__b.__f_);
2131 __bound_args_ = _VSTD::move(__b.__bound_args_);
2135 #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2137 template <class _Gp, class ..._BA,
2138 class = typename enable_if
2140 is_constructible<_Fd, _Gp>::value &&
2141 !is_same<typename remove_reference<_Gp>::type,
2144 _LIBCPP_INLINE_VISIBILITY
2145 explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
2146 : __f_(_VSTD::forward<_Gp>(__f)),
2147 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
2149 template <class ..._Args>
2150 _LIBCPP_INLINE_VISIBILITY
2151 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
2152 operator()(_Args&& ...__args)
2154 return __apply_functor(__f_, __bound_args_, __indices(),
2155 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2158 template <class ..._Args>
2159 _LIBCPP_INLINE_VISIBILITY
2160 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
2161 operator()(_Args&& ...__args) const
2163 return __apply_functor(__f_, __bound_args_, __indices(),
2164 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
2168 template<class _Fp, class ..._BoundArgs>
2169 struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
2171 template<class _Rp, class _Fp, class ..._BoundArgs>
2173 : public __bind<_Fp, _BoundArgs...>
2175 typedef __bind<_Fp, _BoundArgs...> base;
2176 typedef typename base::_Fd _Fd;
2177 typedef typename base::_Td _Td;
2179 typedef _Rp result_type;
2181 #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2183 _LIBCPP_INLINE_VISIBILITY
2184 __bind_r(const __bind_r& __b)
2185 : base(_VSTD::forward<const base&>(__b)) {}
2187 _LIBCPP_INLINE_VISIBILITY
2188 __bind_r& operator=(const __bind_r& __b)
2190 base::operator=(_VSTD::forward<const base&>(__b));
2194 _LIBCPP_INLINE_VISIBILITY
2195 __bind_r(__bind_r&& __b)
2196 : base(_VSTD::forward<base>(__b)) {}
2198 _LIBCPP_INLINE_VISIBILITY
2199 __bind_r& operator=(__bind_r&& __b)
2201 base::operator=(_VSTD::forward<base>(__b));
2205 #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2207 template <class _Gp, class ..._BA,
2208 class = typename enable_if
2210 is_constructible<_Fd, _Gp>::value &&
2211 !is_same<typename remove_reference<_Gp>::type,
2214 _LIBCPP_INLINE_VISIBILITY
2215 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
2216 : base(_VSTD::forward<_Gp>(__f),
2217 _VSTD::forward<_BA>(__bound_args)...) {}
2219 template <class ..._Args>
2220 _LIBCPP_INLINE_VISIBILITY
2223 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
2224 result_type>::value || is_void<_Rp>::value,
2227 operator()(_Args&& ...__args)
2229 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2230 return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
2233 template <class ..._Args>
2234 _LIBCPP_INLINE_VISIBILITY
2237 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
2238 result_type>::value || is_void<_Rp>::value,
2241 operator()(_Args&& ...__args) const
2243 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2244 return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
2248 template<class _Rp, class _Fp, class ..._BoundArgs>
2249 struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
2251 template<class _Fp, class ..._BoundArgs>
2252 inline _LIBCPP_INLINE_VISIBILITY
2253 __bind<_Fp, _BoundArgs...>
2254 bind(_Fp&& __f, _BoundArgs&&... __bound_args)
2256 typedef __bind<_Fp, _BoundArgs...> type;
2257 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2260 template<class _Rp, class _Fp, class ..._BoundArgs>
2261 inline _LIBCPP_INLINE_VISIBILITY
2262 __bind_r<_Rp, _Fp, _BoundArgs...>
2263 bind(_Fp&& __f, _BoundArgs&&... __bound_args)
2265 typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
2266 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
2269 #endif // _LIBCPP_HAS_NO_VARIADICS
2272 struct _LIBCPP_TYPE_VIS_ONLY hash<bool>
2273 : public unary_function<bool, size_t>
2275 _LIBCPP_INLINE_VISIBILITY
2276 size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2280 struct _LIBCPP_TYPE_VIS_ONLY hash<char>
2281 : public unary_function<char, size_t>
2283 _LIBCPP_INLINE_VISIBILITY
2284 size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2288 struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
2289 : public unary_function<signed char, size_t>
2291 _LIBCPP_INLINE_VISIBILITY
2292 size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2296 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
2297 : public unary_function<unsigned char, size_t>
2299 _LIBCPP_INLINE_VISIBILITY
2300 size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2303 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
2306 struct _LIBCPP_TYPE_VIS_ONLY hash<char16_t>
2307 : public unary_function<char16_t, size_t>
2309 _LIBCPP_INLINE_VISIBILITY
2310 size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2314 struct _LIBCPP_TYPE_VIS_ONLY hash<char32_t>
2315 : public unary_function<char32_t, size_t>
2317 _LIBCPP_INLINE_VISIBILITY
2318 size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2321 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
2324 struct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t>
2325 : public unary_function<wchar_t, size_t>
2327 _LIBCPP_INLINE_VISIBILITY
2328 size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2332 struct _LIBCPP_TYPE_VIS_ONLY hash<short>
2333 : public unary_function<short, size_t>
2335 _LIBCPP_INLINE_VISIBILITY
2336 size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2340 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
2341 : public unary_function<unsigned short, size_t>
2343 _LIBCPP_INLINE_VISIBILITY
2344 size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2348 struct _LIBCPP_TYPE_VIS_ONLY hash<int>
2349 : public unary_function<int, size_t>
2351 _LIBCPP_INLINE_VISIBILITY
2352 size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2356 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
2357 : public unary_function<unsigned int, size_t>
2359 _LIBCPP_INLINE_VISIBILITY
2360 size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2364 struct _LIBCPP_TYPE_VIS_ONLY hash<long>
2365 : public unary_function<long, size_t>
2367 _LIBCPP_INLINE_VISIBILITY
2368 size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2372 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
2373 : public unary_function<unsigned long, size_t>
2375 _LIBCPP_INLINE_VISIBILITY
2376 size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
2380 struct _LIBCPP_TYPE_VIS_ONLY hash<long long>
2381 : public __scalar_hash<long long>
2386 struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
2387 : public __scalar_hash<unsigned long long>
2392 struct _LIBCPP_TYPE_VIS_ONLY hash<float>
2393 : public __scalar_hash<float>
2395 _LIBCPP_INLINE_VISIBILITY
2396 size_t operator()(float __v) const _NOEXCEPT
2398 // -0.0 and 0.0 should return same hash
2401 return __scalar_hash<float>::operator()(__v);
2406 struct _LIBCPP_TYPE_VIS_ONLY hash<double>
2407 : public __scalar_hash<double>
2409 _LIBCPP_INLINE_VISIBILITY
2410 size_t operator()(double __v) const _NOEXCEPT
2412 // -0.0 and 0.0 should return same hash
2415 return __scalar_hash<double>::operator()(__v);
2420 struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
2421 : public __scalar_hash<long double>
2423 _LIBCPP_INLINE_VISIBILITY
2424 size_t operator()(long double __v) const _NOEXCEPT
2426 // -0.0 and 0.0 should return same hash
2429 #if defined(__i386__)
2430 // Zero out padding bits
2447 return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
2448 #elif defined(__x86_64__)
2449 // Zero out padding bits
2462 return __u.__s.__a ^ __u.__s.__b;
2464 return __scalar_hash<long double>::operator()(__v);
2469 #if _LIBCPP_STD_VER > 11
2470 template <class _Tp>
2471 struct _LIBCPP_TYPE_VIS_ONLY hash
2472 : public unary_function<_Tp, size_t>
2474 static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types");
2476 _LIBCPP_INLINE_VISIBILITY
2477 size_t operator()(_Tp __v) const _NOEXCEPT
2479 typedef typename underlying_type<_Tp>::type type;
2480 return hash<type>{}(static_cast<type>(__v));
2486 #if _LIBCPP_STD_VER > 14
2487 template <class _Fn, class ..._Args>
2488 result_of_t<_Fn&&(_Args&&...)>
2489 invoke(_Fn&& __f, _Args&&... __args) {
2490 return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
2494 // struct hash<T*> in <memory>
2496 _LIBCPP_END_NAMESPACE_STD
2498 #endif // _LIBCPP_FUNCTIONAL