43 #ifndef _GLIBCXX_FUNCTIONAL
44 #define _GLIBCXX_FUNCTIONAL 1
46 #pragma GCC system_header
51 #if __cplusplus >= 201103L
60 namespace std _GLIBCXX_VISIBILITY(default)
62 _GLIBCXX_BEGIN_NAMESPACE_VERSION
64 template<
typename _MemberPo
inter>
66 template<
typename _Tp,
typename _Class>
67 _Mem_fn<_Tp _Class::*>
68 mem_fn(_Tp _Class::*) noexcept;
70 _GLIBCXX_HAS_NESTED_TYPE(result_type)
73 template<
bool _Has_result_type, typename _Functor>
77 template<
typename _Functor>
79 {
typedef typename _Functor::result_type result_type; };
85 template<
typename _Functor>
91 template<
typename _Res,
typename... _ArgTypes>
93 {
typedef _Res result_type; };
95 template<
typename _Res,
typename... _ArgTypes>
97 {
typedef _Res result_type; };
99 template<
typename _Res,
typename... _ArgTypes>
100 struct _Weak_result_type_impl<_Res(_ArgTypes...) const>
101 {
typedef _Res result_type; };
103 template<
typename _Res,
typename... _ArgTypes>
104 struct _Weak_result_type_impl<_Res(_ArgTypes......) const>
105 {
typedef _Res result_type; };
107 template<
typename _Res,
typename... _ArgTypes>
108 struct _Weak_result_type_impl<_Res(_ArgTypes...) volatile>
109 {
typedef _Res result_type; };
111 template<
typename _Res,
typename... _ArgTypes>
112 struct _Weak_result_type_impl<_Res(_ArgTypes......) volatile>
113 {
typedef _Res result_type; };
115 template<
typename _Res,
typename... _ArgTypes>
116 struct _Weak_result_type_impl<_Res(_ArgTypes...) const volatile>
117 {
typedef _Res result_type; };
119 template<
typename _Res,
typename... _ArgTypes>
120 struct _Weak_result_type_impl<_Res(_ArgTypes......) const volatile>
121 {
typedef _Res result_type; };
124 template<
typename _Res,
typename... _ArgTypes>
126 {
typedef _Res result_type; };
128 template<
typename _Res,
typename... _ArgTypes>
130 {
typedef _Res result_type; };
133 template<
typename _Res,
typename... _ArgTypes>
135 {
typedef _Res result_type; };
137 template<
typename _Res,
typename... _ArgTypes>
139 {
typedef _Res result_type; };
142 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
144 {
typedef _Res result_type; };
146 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
148 {
typedef _Res result_type; };
151 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
153 {
typedef _Res result_type; };
155 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
157 {
typedef _Res result_type; };
160 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
162 {
typedef _Res result_type; };
164 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
166 {
typedef _Res result_type; };
169 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
172 {
typedef _Res result_type; };
174 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
177 {
typedef _Res result_type; };
183 template<
typename _Functor>
192 template<
typename _Functor,
typename... _Args>
198 typename result_of<_Functor&(_Args&&...)>::type
202 return __f(std::forward<_Args>(__args)...);
205 template<
typename _Functor,
typename... _Args>
208 (is_member_pointer<_Functor>::value
209 && !is_function<_Functor>::value
210 && !is_function<typename remove_pointer<_Functor>::type>::value),
211 typename result_of<_Functor(_Args&&...)>::type
213 __invoke(_Functor& __f, _Args&&... __args)
215 return std::mem_fn(__f)(std::forward<_Args>(__args)...);
219 template<
typename _Functor,
typename... _Args>
222 (is_pointer<_Functor>::value
223 && is_function<typename remove_pointer<_Functor>::type>::value),
224 typename result_of<_Functor(_Args&&...)>::type
226 __invoke(_Functor __f, _Args&&... __args)
228 return __f(std::forward<_Args>(__args)...);
236 template<
bool _Unary,
bool _Binary,
typename _Tp>
240 template<
typename _Tp>
246 template<
typename _Tp>
250 typedef typename _Tp::argument_type argument_type;
254 template<
typename _Tp>
255 struct _Reference_wrapper_base_impl<false, true, _Tp>
256 : _Weak_result_type<_Tp>
258 typedef typename _Tp::first_argument_type first_argument_type;
259 typedef typename _Tp::second_argument_type second_argument_type;
263 template<
typename _Tp>
264 struct _Reference_wrapper_base_impl<true, true, _Tp>
265 : _Weak_result_type<_Tp>
267 typedef typename _Tp::argument_type argument_type;
268 typedef typename _Tp::first_argument_type first_argument_type;
269 typedef typename _Tp::second_argument_type second_argument_type;
272 _GLIBCXX_HAS_NESTED_TYPE(argument_type)
273 _GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
274 _GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
282 template<typename _Tp>
285 __has_argument_type<_Tp>::value,
286 __has_first_argument_type<_Tp>::value
287 && __has_second_argument_type<_Tp>::value,
292 template<
typename _Res,
typename _T1>
297 template<
typename _Res,
typename _T1>
298 struct _Reference_wrapper_base<_Res(_T1) const>
299 : unary_function<_T1, _Res>
302 template<
typename _Res,
typename _T1>
303 struct _Reference_wrapper_base<_Res(_T1) volatile>
304 : unary_function<_T1, _Res>
307 template<
typename _Res,
typename _T1>
308 struct _Reference_wrapper_base<_Res(_T1) const volatile>
309 : unary_function<_T1, _Res>
313 template<
typename _Res,
typename _T1,
typename _T2>
314 struct _Reference_wrapper_base<_Res(_T1, _T2)>
315 : binary_function<_T1, _T2, _Res>
318 template<
typename _Res,
typename _T1,
typename _T2>
319 struct _Reference_wrapper_base<_Res(_T1, _T2) const>
320 : binary_function<_T1, _T2, _Res>
323 template<
typename _Res,
typename _T1,
typename _T2>
324 struct _Reference_wrapper_base<_Res(_T1, _T2) volatile>
325 : binary_function<_T1, _T2, _Res>
328 template<
typename _Res,
typename _T1,
typename _T2>
329 struct _Reference_wrapper_base<_Res(_T1, _T2) const volatile>
330 : binary_function<_T1, _T2, _Res>
334 template<
typename _Res,
typename _T1>
335 struct _Reference_wrapper_base<_Res(*)(_T1)>
336 : unary_function<_T1, _Res>
340 template<
typename _Res,
typename _T1,
typename _T2>
341 struct _Reference_wrapper_base<_Res(*)(_T1, _T2)>
342 : binary_function<_T1, _T2, _Res>
346 template<
typename _Res,
typename _T1>
347 struct _Reference_wrapper_base<_Res (_T1::*)()>
348 : unary_function<_T1*, _Res>
352 template<
typename _Res,
typename _T1,
typename _T2>
353 struct _Reference_wrapper_base<_Res (_T1::*)(_T2)>
354 : binary_function<_T1*, _T2, _Res>
358 template<
typename _Res,
typename _T1>
359 struct _Reference_wrapper_base<_Res (_T1::*)() const>
360 : unary_function<const _T1*, _Res>
364 template<
typename _Res,
typename _T1,
typename _T2>
365 struct _Reference_wrapper_base<_Res (_T1::*)(_T2) const>
366 : binary_function<const _T1*, _T2, _Res>
370 template<
typename _Res,
typename _T1>
371 struct _Reference_wrapper_base<_Res (_T1::*)() volatile>
372 : unary_function<volatile _T1*, _Res>
376 template<
typename _Res,
typename _T1,
typename _T2>
377 struct _Reference_wrapper_base<_Res (_T1::*)(_T2) volatile>
378 : binary_function<volatile _T1*, _T2, _Res>
382 template<
typename _Res,
typename _T1>
383 struct _Reference_wrapper_base<_Res (_T1::*)() const volatile>
384 : unary_function<const volatile _T1*, _Res>
388 template<
typename _Res,
typename _T1,
typename _T2>
389 struct _Reference_wrapper_base<_Res (_T1::*)(_T2) const volatile>
390 : binary_function<const volatile _T1*, _T2, _Res>
398 template<
typename _Tp>
414 : _M_data(__inref._M_data)
420 _M_data = __inref._M_data;
424 operator _Tp&()
const noexcept
425 {
return this->
get(); }
431 template<
typename... _Args>
432 typename result_of<_Tp&(_Args&&...)>::type
433 operator()(_Args&&... __args)
const
435 return __invoke(
get(), std::forward<_Args>(__args)...);
441 template<
typename _Tp>
447 template<
typename _Tp>
448 inline reference_wrapper<const _Tp>
452 template<
typename _Tp>
453 void ref(
const _Tp&&) =
delete;
455 template<
typename _Tp>
456 void cref(
const _Tp&&) =
delete;
459 template<
typename _Tp>
460 inline reference_wrapper<_Tp>
462 {
return ref(__t.get()); }
465 template<
typename _Tp>
466 inline reference_wrapper<const _Tp>
468 {
return cref(__t.get()); }
472 template<
typename... _Types>
473 struct _Pack : integral_constant<size_t, sizeof...(_Types)>
476 template<
typename _From,
typename _To,
bool = _From::value == _To::value>
480 template<
typename... _From,
typename... _To>
481 struct _AllConvertible<_Pack<_From...>, _Pack<_To...>, true>
482 : __and_<is_convertible<_From, _To>...>
485 template<
typename _Tp1,
typename _Tp2>
486 using _NotSame = __not_<is_same<typename std::decay<_Tp1>::type,
487 typename std::decay<_Tp2>::type>>;
494 template<
typename _Res,
typename... _ArgTypes>
498 template<
typename _Res,
typename _T1>
503 template<
typename _Res,
typename _T1,
typename _T2>
508 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
509 class _Mem_fn<_Res (_Class::*)(_ArgTypes...)>
512 typedef _Res (_Class::*_Functor)(_ArgTypes...);
514 template<
typename _Tp,
typename... _Args>
516 _M_call(_Tp&& __object,
const volatile _Class *,
517 _Args&&... __args)
const
519 return (std::forward<_Tp>(__object).*__pmf)
520 (std::forward<_Args>(__args)...);
523 template<
typename _Tp,
typename... _Args>
525 _M_call(_Tp&& __ptr,
const volatile void *, _Args&&... __args)
const
526 {
return ((*__ptr).*__pmf)(std::forward<_Args>(__args)...); }
529 template<
typename... _Args>
530 using _RequireValidArgs
531 = _Require<_AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
535 template<
typename _Tp,
typename... _Args>
536 using _RequireValidArgs2
537 = _Require<_NotSame<_Class, _Tp>, _NotSame<_Class*, _Tp>,
538 _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
542 template<
typename _Tp,
typename... _Args>
543 using _RequireValidArgs3
544 = _Require<is_base_of<_Class, _Tp>,
545 _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
548 typedef _Res result_type;
550 explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
553 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
555 operator()(_Class& __object, _Args&&... __args)
const
556 {
return (__object.*__pmf)(std::forward<_Args>(__args)...); }
558 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
560 operator()(_Class&& __object, _Args&&... __args)
const
562 return (std::move(__object).*__pmf)(std::forward<_Args>(__args)...);
566 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
568 operator()(_Class* __object, _Args&&... __args)
const
569 {
return (__object->*__pmf)(std::forward<_Args>(__args)...); }
572 template<
typename _Tp,
typename... _Args,
573 typename _Req = _RequireValidArgs2<_Tp, _Args...>>
575 operator()(_Tp&& __object, _Args&&... __args)
const
577 return _M_call(std::forward<_Tp>(__object), &__object,
578 std::forward<_Args>(__args)...);
581 template<
typename _Tp,
typename... _Args,
582 typename _Req = _RequireValidArgs3<_Tp, _Args...>>
585 {
return operator()(__ref.get(), std::forward<_Args>(__args)...); }
592 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
593 class _Mem_fn<_Res (_Class::*)(_ArgTypes...) const>
597 typedef _Res (_Class::*_Functor)(_ArgTypes...)
const;
599 template<
typename _Tp,
typename... _Args>
601 _M_call(_Tp&& __object,
const volatile _Class *,
602 _Args&&... __args)
const
604 return (std::forward<_Tp>(__object).*__pmf)
605 (std::forward<_Args>(__args)...);
608 template<
typename _Tp,
typename... _Args>
610 _M_call(_Tp&& __ptr,
const volatile void *, _Args&&... __args)
const
611 {
return ((*__ptr).*__pmf)(std::forward<_Args>(__args)...); }
613 template<
typename... _Args>
614 using _RequireValidArgs
615 = _Require<_AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
617 template<
typename _Tp,
typename... _Args>
618 using _RequireValidArgs2
619 = _Require<_NotSame<_Class, _Tp>, _NotSame<const _Class*, _Tp>,
620 _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
622 template<
typename _Tp,
typename... _Args>
623 using _RequireValidArgs3
624 = _Require<is_base_of<_Class, _Tp>,
625 _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
628 typedef _Res result_type;
630 explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
633 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
635 operator()(
const _Class& __object, _Args&&... __args)
const
636 {
return (__object.*__pmf)(std::forward<_Args>(__args)...); }
638 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
640 operator()(
const _Class&& __object, _Args&&... __args)
const
642 return (std::move(__object).*__pmf)(std::forward<_Args>(__args)...);
646 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
648 operator()(
const _Class* __object, _Args&&... __args)
const
649 {
return (__object->*__pmf)(std::forward<_Args>(__args)...); }
652 template<
typename _Tp,
typename... _Args,
653 typename _Req = _RequireValidArgs2<_Tp, _Args...>>
654 _Res operator()(_Tp&& __object, _Args&&... __args)
const
656 return _M_call(std::forward<_Tp>(__object), &__object,
657 std::forward<_Args>(__args)...);
660 template<
typename _Tp,
typename... _Args,
661 typename _Req = _RequireValidArgs3<_Tp, _Args...>>
664 {
return operator()(__ref.get(), std::forward<_Args>(__args)...); }
671 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
672 class _Mem_fn<_Res (_Class::*)(_ArgTypes...) volatile>
676 typedef _Res (_Class::*_Functor)(_ArgTypes...)
volatile;
678 template<
typename _Tp,
typename... _Args>
680 _M_call(_Tp&& __object,
const volatile _Class *,
681 _Args&&... __args)
const
683 return (std::forward<_Tp>(__object).*__pmf)
684 (std::forward<_Args>(__args)...);
687 template<
typename _Tp,
typename... _Args>
689 _M_call(_Tp&& __ptr,
const volatile void *, _Args&&... __args)
const
690 {
return ((*__ptr).*__pmf)(std::forward<_Args>(__args)...); }
692 template<
typename... _Args>
693 using _RequireValidArgs
694 = _Require<_AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
696 template<
typename _Tp,
typename... _Args>
697 using _RequireValidArgs2
698 = _Require<_NotSame<_Class, _Tp>, _NotSame<volatile _Class*, _Tp>,
699 _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
701 template<
typename _Tp,
typename... _Args>
702 using _RequireValidArgs3
703 = _Require<is_base_of<_Class, _Tp>,
704 _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
707 typedef _Res result_type;
709 explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
712 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
714 operator()(
volatile _Class& __object, _Args&&... __args)
const
715 {
return (__object.*__pmf)(std::forward<_Args>(__args)...); }
717 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
719 operator()(
volatile _Class&& __object, _Args&&... __args)
const
721 return (std::move(__object).*__pmf)(std::forward<_Args>(__args)...);
725 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
727 operator()(
volatile _Class* __object, _Args&&... __args)
const
728 {
return (__object->*__pmf)(std::forward<_Args>(__args)...); }
731 template<
typename _Tp,
typename... _Args,
732 typename _Req = _RequireValidArgs2<_Tp, _Args...>>
734 operator()(_Tp&& __object, _Args&&... __args)
const
736 return _M_call(std::forward<_Tp>(__object), &__object,
737 std::forward<_Args>(__args)...);
740 template<
typename _Tp,
typename... _Args,
741 typename _Req = _RequireValidArgs3<_Tp, _Args...>>
744 {
return operator()(__ref.get(), std::forward<_Args>(__args)...); }
751 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
752 class _Mem_fn<_Res (_Class::*)(_ArgTypes...) const volatile>
756 typedef _Res (_Class::*_Functor)(_ArgTypes...)
const volatile;
758 template<
typename _Tp,
typename... _Args>
760 _M_call(_Tp&& __object,
const volatile _Class *,
761 _Args&&... __args)
const
763 return (std::forward<_Tp>(__object).*__pmf)
764 (std::forward<_Args>(__args)...);
767 template<
typename _Tp,
typename... _Args>
769 _M_call(_Tp&& __ptr,
const volatile void *, _Args&&... __args)
const
770 {
return ((*__ptr).*__pmf)(std::forward<_Args>(__args)...); }
772 template<
typename... _Args>
773 using _RequireValidArgs
774 = _Require<_AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
776 template<
typename _Tp,
typename... _Args>
777 using _RequireValidArgs2
778 = _Require<_NotSame<_Class, _Tp>,
779 _NotSame<const volatile _Class*, _Tp>,
780 _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
782 template<
typename _Tp,
typename... _Args>
783 using _RequireValidArgs3
784 = _Require<is_base_of<_Class, _Tp>,
785 _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
788 typedef _Res result_type;
790 explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
793 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
795 operator()(
const volatile _Class& __object, _Args&&... __args)
const
796 {
return (__object.*__pmf)(std::forward<_Args>(__args)...); }
798 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
800 operator()(
const volatile _Class&& __object, _Args&&... __args)
const
802 return (std::move(__object).*__pmf)(std::forward<_Args>(__args)...);
806 template<
typename... _Args,
typename _Req = _RequireValidArgs<_Args...>>
808 operator()(
const volatile _Class* __object, _Args&&... __args)
const
809 {
return (__object->*__pmf)(std::forward<_Args>(__args)...); }
812 template<
typename _Tp,
typename... _Args,
813 typename _Req = _RequireValidArgs2<_Tp, _Args...>>
814 _Res operator()(_Tp&& __object, _Args&&... __args)
const
816 return _M_call(std::forward<_Tp>(__object), &__object,
817 std::forward<_Args>(__args)...);
820 template<
typename _Tp,
typename... _Args,
821 typename _Req = _RequireValidArgs3<_Tp, _Args...>>
824 {
return operator()(__ref.get(), std::forward<_Args>(__args)...); }
831 template<
typename _Tp,
bool>
832 struct _Mem_fn_const_or_non
834 typedef const _Tp& type;
837 template<
typename _Tp>
838 struct _Mem_fn_const_or_non<_Tp, false>
843 template<
typename _Res,
typename _Class>
844 class _Mem_fn<_Res _Class::*>
846 using __pm_type = _Res _Class::*;
851 template<
typename _Tp>
853 _M_call(_Tp&& __object,
const _Class *) const noexcept
854 -> decltype(std::
forward<_Tp>(__object).*std::declval<__pm_type&>())
855 {
return std::forward<_Tp>(__object).*__pm; }
857 template<
typename _Tp,
typename _Up>
859 _M_call(_Tp&& __object, _Up *
const *) const noexcept
860 -> decltype((*std::
forward<_Tp>(__object)).*std::declval<__pm_type&>())
861 {
return (*std::forward<_Tp>(__object)).*__pm; }
863 template<
typename _Tp>
865 _M_call(_Tp&& __ptr,
const volatile void*) const
866 noexcept(noexcept((*__ptr).*std::declval<__pm_type&>()))
867 -> decltype((*__ptr).*std::declval<__pm_type&>())
868 {
return (*__ptr).*__pm; }
872 _Mem_fn(_Res _Class::*__pm) noexcept : __pm(__pm) { }
876 operator()(_Class& __object)
const noexcept
877 {
return __object.*__pm; }
880 operator()(
const _Class& __object)
const noexcept
881 {
return __object.*__pm; }
884 operator()(_Class&& __object) const noexcept
885 {
return std::forward<_Class>(__object).*__pm; }
888 operator()(
const _Class&& __object) const noexcept
889 {
return std::forward<const _Class>(__object).*__pm; }
893 operator()(_Class* __object)
const noexcept
894 {
return __object->*__pm; }
897 operator()(
const _Class* __object)
const noexcept
898 {
return __object->*__pm; }
901 template<
typename _Tp,
typename _Req = _Require<_NotSame<_Class*, _Tp>>>
903 operator()(_Tp&& __unknown) const
904 noexcept(noexcept(std::declval<_Mem_fn*>()->_M_call
905 (std::
forward<_Tp>(__unknown), &__unknown)))
906 -> decltype(this->_M_call(std::
forward<_Tp>(__unknown), &__unknown))
907 {
return _M_call(std::forward<_Tp>(__unknown), &__unknown); }
909 template<
typename _Tp,
typename _Req = _Require<is_base_of<_Class, _Tp>>>
911 operator()(reference_wrapper<_Tp> __ref)
const
912 noexcept(noexcept(std::declval<_Mem_fn&>()(__ref.get())))
913 -> decltype((*
this)(__ref.get()))
914 {
return (*
this)(__ref.get()); }
927 template<
typename _Tp,
typename _Class>
928 inline _Mem_fn<_Tp _Class::*>
931 return _Mem_fn<_Tp _Class::*>(__pm);
940 template<
typename _Tp>
949 template<
typename _Tp>
959 _GLIBCXX_END_NAMESPACE_VERSION
965 namespace placeholders
967 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1001 _GLIBCXX_END_NAMESPACE_VERSION
1004 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1025 struct _No_tuple_element;
1032 template<std::
size_t __i,
typename _Tuple,
bool _IsSafe>
1041 template<std::
size_t __i,
typename _Tuple>
1044 typedef _No_tuple_element type;
1051 template<std::
size_t __i,
typename _Tuple>
1054 (__i < tuple_size<_Tuple>::value)>
1068 template<typename _Arg,
1069 bool _IsBindExp = is_bind_expression<_Arg>::value,
1070 bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
1077 template<typename _Tp>
1078 class
_Mu<reference_wrapper<_Tp>, false, false>
1081 typedef _Tp& result_type;
1087 template<
typename _CVRef,
typename _Tuple>
1089 operator()(_CVRef& __arg, _Tuple&)
const volatile
1090 {
return __arg.get(); }
1098 template<
typename _Arg>
1102 template<
typename _CVArg,
typename... _Args>
1104 operator()(_CVArg& __arg,
1106 -> decltype(__arg(declval<_Args>()...))
1109 typedef typename _Build_index_tuple<
sizeof...(_Args)>::__type
1111 return this->__call(__arg, __tuple, _Indexes());
1117 template<
typename _CVArg,
typename... _Args, std::size_t... _Indexes>
1120 const _Index_tuple<_Indexes...>&)
const volatile
1121 -> decltype(__arg(declval<_Args>()...))
1123 return __arg(std::forward<_Args>(get<_Indexes>(__tuple))...);
1132 template<
typename _Arg>
1136 template<
typename _Signature>
class result;
1138 template<
typename _CVMu,
typename _CVArg,
typename _Tuple>
1139 class result<_CVMu(_CVArg, _Tuple)>
1149 typedef typename add_rvalue_reference<__base_type>::type type;
1152 template<
typename _Tuple>
1153 typename result<_Mu(_Arg, _Tuple)>::type
1154 operator()(
const volatile _Arg&, _Tuple& __tuple)
const volatile
1156 return std::forward<typename result<_Mu(_Arg, _Tuple)>::type>(
1157 ::std::get<(is_placeholder<_Arg>::value - 1)>(__tuple));
1166 template<
typename _Arg>
1170 template<
typename _Signature>
struct result;
1172 template<
typename _CVMu,
typename _CVArg,
typename _Tuple>
1173 struct result<_CVMu(_CVArg, _Tuple)>
1175 typedef typename add_lvalue_reference<_CVArg>::type type;
1179 template<
typename _CVArg,
typename _Tuple>
1181 operator()(_CVArg&& __arg, _Tuple&)
const volatile
1182 {
return std::forward<_CVArg>(__arg); }
1190 template<
typename _Tp>
1196 __do_wrap(
const _Tp& __x)
1200 __do_wrap(_Tp&& __x)
1201 {
return static_cast<_Tp&&
>(__x); }
1209 template<
typename _Tp,
typename _Class>
1212 typedef _Mem_fn<_Tp _Class::*> type;
1215 __do_wrap(_Tp _Class::* __pm)
1216 {
return type(__pm); }
1230 template<std::size_t _Ind,
typename... _Tp>
1232 __volget(
volatile tuple<_Tp...>& __tuple)
1233 ->
typename tuple_element<_Ind, tuple<_Tp...>>::type
volatile&
1234 {
return std::get<_Ind>(
const_cast<tuple<_Tp...
>&>(__tuple)); }
1237 template<std::size_t _Ind,
typename... _Tp>
1239 __volget(
const volatile tuple<_Tp...>& __tuple)
1240 ->
typename tuple_element<_Ind, tuple<_Tp...>>::type
const volatile&
1241 {
return std::get<_Ind>(
const_cast<const tuple<_Tp...
>&>(__tuple)); }
1244 template<
typename _Signature>
1247 template<
typename _Functor,
typename... _Bound_args>
1248 class _Bind<_Functor(_Bound_args...)>
1251 typedef _Bind __self_type;
1252 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
1256 tuple<_Bound_args...> _M_bound_args;
1259 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
1264 (get<_Indexes>(_M_bound_args), __args)...);
1268 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
1273 (get<_Indexes>(_M_bound_args), __args)...);
1277 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
1279 __call_v(tuple<_Args...>&& __args,
1280 _Index_tuple<_Indexes...>)
volatile
1282 return _M_f(_Mu<_Bound_args>()
1283 (__volget<_Indexes>(_M_bound_args), __args)...);
1287 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
1289 __call_c_v(tuple<_Args...>&& __args,
1290 _Index_tuple<_Indexes...>)
const volatile
1292 return _M_f(_Mu<_Bound_args>()
1293 (__volget<_Indexes>(_M_bound_args), __args)...);
1297 template<
typename... _Args>
1298 explicit _Bind(
const _Functor& __f, _Args&&... __args)
1299 : _M_f(__f), _M_bound_args(std::
forward<_Args>(__args)...)
1302 template<
typename... _Args>
1303 explicit _Bind(_Functor&& __f, _Args&&... __args)
1304 : _M_f(std::move(__f)), _M_bound_args(std::
forward<_Args>(__args)...)
1307 _Bind(
const _Bind&) =
default;
1310 : _M_f(std::move(__b._M_f)), _M_bound_args(std::move(__b._M_bound_args))
1314 template<
typename... _Args,
typename _Result
1315 = decltype( std::declval<_Functor>()(
1316 _Mu<_Bound_args>()( std::declval<_Bound_args&>(),
1317 std::declval<tuple<_Args...>&>() )... ) )>
1319 operator()(_Args&&... __args)
1321 return this->__call<_Result>(
1322 std::forward_as_tuple(std::forward<_Args>(__args)...),
1327 template<
typename... _Args,
typename _Result
1328 = decltype( std::declval<
typename enable_if<(
sizeof...(_Args) >= 0),
1329 typename add_const<_Functor>::type>::type>()(
1330 _Mu<_Bound_args>()( std::declval<const _Bound_args&>(),
1331 std::declval<tuple<_Args...>&>() )... ) )>
1333 operator()(_Args&&... __args)
const
1335 return this->__call_c<_Result>(
1336 std::forward_as_tuple(std::forward<_Args>(__args)...),
1341 template<
typename... _Args,
typename _Result
1342 = decltype( std::declval<
typename enable_if<(
sizeof...(_Args) >= 0),
1343 typename add_volatile<_Functor>::type>::type>()(
1344 _Mu<_Bound_args>()( std::declval<volatile _Bound_args&>(),
1345 std::declval<tuple<_Args...>&>() )... ) )>
1347 operator()(_Args&&... __args)
volatile
1349 return this->__call_v<_Result>(
1350 std::forward_as_tuple(std::forward<_Args>(__args)...),
1355 template<
typename... _Args,
typename _Result
1356 = decltype( std::declval<
typename enable_if<(
sizeof...(_Args) >= 0),
1357 typename add_cv<_Functor>::type>::type>()(
1358 _Mu<_Bound_args>()( std::declval<const volatile _Bound_args&>(),
1359 std::declval<tuple<_Args...>&>() )... ) )>
1361 operator()(_Args&&... __args)
const volatile
1363 return this->__call_c_v<_Result>(
1364 std::forward_as_tuple(std::forward<_Args>(__args)...),
1370 template<
typename _Result,
typename _Signature>
1373 template<
typename _Result,
typename _Functor,
typename... _Bound_args>
1377 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
1381 tuple<_Bound_args...> _M_bound_args;
1384 template<
typename _Res>
1385 struct __enable_if_void : enable_if<is_void<_Res>::value, int> { };
1386 template<
typename _Res>
1387 struct __disable_if_void : enable_if<!is_void<_Res>::value, int> { };
1390 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
1392 __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
1393 typename __disable_if_void<_Res>::type = 0)
1395 return _M_f(_Mu<_Bound_args>()
1396 (get<_Indexes>(_M_bound_args), __args)...);
1400 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
1402 __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
1403 typename __enable_if_void<_Res>::type = 0)
1405 _M_f(_Mu<_Bound_args>()
1406 (get<_Indexes>(_M_bound_args), __args)...);
1410 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
1412 __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
1413 typename __disable_if_void<_Res>::type = 0)
const
1415 return _M_f(_Mu<_Bound_args>()
1416 (get<_Indexes>(_M_bound_args), __args)...);
1420 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
1422 __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
1423 typename __enable_if_void<_Res>::type = 0)
const
1425 _M_f(_Mu<_Bound_args>()
1426 (get<_Indexes>(_M_bound_args), __args)...);
1430 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
1432 __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
1433 typename __disable_if_void<_Res>::type = 0)
volatile
1435 return _M_f(_Mu<_Bound_args>()
1436 (__volget<_Indexes>(_M_bound_args), __args)...);
1440 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
1442 __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
1443 typename __enable_if_void<_Res>::type = 0)
volatile
1445 _M_f(_Mu<_Bound_args>()
1446 (__volget<_Indexes>(_M_bound_args), __args)...);
1450 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
1452 __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
1453 typename __disable_if_void<_Res>::type = 0)
const volatile
1455 return _M_f(_Mu<_Bound_args>()
1456 (__volget<_Indexes>(_M_bound_args), __args)...);
1460 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
1462 __call(tuple<_Args...>&& __args,
1463 _Index_tuple<_Indexes...>,
1464 typename __enable_if_void<_Res>::type = 0)
const volatile
1466 _M_f(_Mu<_Bound_args>()
1467 (__volget<_Indexes>(_M_bound_args), __args)...);
1471 typedef _Result result_type;
1473 template<
typename... _Args>
1474 explicit _Bind_result(
const _Functor& __f, _Args&&... __args)
1475 : _M_f(__f), _M_bound_args(std::
forward<_Args>(__args)...)
1478 template<
typename... _Args>
1479 explicit _Bind_result(_Functor&& __f, _Args&&... __args)
1480 : _M_f(std::move(__f)), _M_bound_args(std::
forward<_Args>(__args)...)
1483 _Bind_result(
const _Bind_result&) =
default;
1485 _Bind_result(_Bind_result&& __b)
1486 : _M_f(std::move(__b._M_f)), _M_bound_args(std::move(__b._M_bound_args))
1490 template<
typename... _Args>
1492 operator()(_Args&&... __args)
1494 return this->__call<_Result>(
1495 std::forward_as_tuple(std::forward<_Args>(__args)...),
1500 template<
typename... _Args>
1502 operator()(_Args&&... __args)
const
1504 return this->__call<_Result>(
1505 std::forward_as_tuple(std::forward<_Args>(__args)...),
1510 template<
typename... _Args>
1512 operator()(_Args&&... __args)
volatile
1514 return this->__call<_Result>(
1515 std::forward_as_tuple(std::forward<_Args>(__args)...),
1520 template<
typename... _Args>
1522 operator()(_Args&&... __args)
const volatile
1524 return this->__call<_Result>(
1525 std::forward_as_tuple(std::forward<_Args>(__args)...),
1534 template<
typename _Signature>
1542 template<
typename _Signature>
1550 template<
typename _Signature>
1558 template<
typename _Signature>
1566 template<
typename _Result,
typename _Signature>
1574 template<
typename _Result,
typename _Signature>
1582 template<
typename _Result,
typename _Signature>
1590 template<
typename _Result,
typename _Signature>
1597 template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type>
1598 using __is_socketlike = __or_<is_integral<_Tp2>,
is_enum<_Tp2>>;
1600 template<
bool _SocketLike,
typename _Func,
typename... _BoundArgs>
1605 typedef typename __maybe_type::type __func_type;
1612 template<
typename _Func,
typename... _BoundArgs>
1613 struct _Bind_helper<true, _Func, _BoundArgs...>
1620 template<
typename _Func,
typename... _BoundArgs>
1622 _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
1623 bind(_Func&& __f, _BoundArgs&&... __args)
1625 typedef _Bind_helper<
false, _Func, _BoundArgs...> __helper_type;
1626 typedef typename __helper_type::__maybe_type __maybe_type;
1627 typedef typename __helper_type::type __result_type;
1628 return __result_type(__maybe_type::__do_wrap(std::forward<_Func>(__f)),
1629 std::forward<_BoundArgs>(__args)...);
1632 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
1633 struct _Bindres_helper
1635 typedef _Maybe_wrap_member_pointer<typename decay<_Func>::type>
1637 typedef typename __maybe_type::type __functor_type;
1638 typedef _Bind_result<_Result,
1639 __functor_type(
typename decay<_BoundArgs>::type...)>
1647 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
1649 typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type
1650 bind(_Func&& __f, _BoundArgs&&... __args)
1652 typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type;
1653 typedef typename __helper_type::__maybe_type __maybe_type;
1654 typedef typename __helper_type::type __result_type;
1655 return __result_type(__maybe_type::__do_wrap(std::forward<_Func>(__f)),
1656 std::forward<_BoundArgs>(__args)...);
1659 template<
typename _Signature>
1660 struct _Bind_simple;
1662 template<
typename _Callable,
typename... _Args>
1663 struct _Bind_simple<_Callable(_Args...)>
1665 typedef typename result_of<_Callable(_Args...)>::type result_type;
1667 template<
typename... _Args2,
typename =
typename
1668 enable_if<
sizeof...(_Args) ==
sizeof...(_Args2)>::type>
1670 _Bind_simple(
const _Callable& __callable, _Args2&&... __args)
1671 : _M_bound(__callable, std::
forward<_Args2>(__args)...)
1674 template<
typename... _Args2,
typename =
typename
1675 enable_if<
sizeof...(_Args) ==
sizeof...(_Args2)>::type>
1677 _Bind_simple(_Callable&& __callable, _Args2&&... __args)
1678 : _M_bound(std::move(__callable), std::
forward<_Args2>(__args)...)
1681 _Bind_simple(
const _Bind_simple&) =
default;
1682 _Bind_simple(_Bind_simple&&) =
default;
1687 typedef typename _Build_index_tuple<
sizeof...(_Args)>::__type _Indices;
1688 return _M_invoke(_Indices());
1693 template<std::size_t... _Indices>
1694 typename result_of<_Callable(_Args...)>::type
1695 _M_invoke(_Index_tuple<_Indices...>)
1699 return std::forward<_Callable>(std::get<0>(_M_bound))(
1700 std::forward<_Args>(std::get<_Indices+1>(_M_bound))...);
1706 template<
typename _Func,
typename... _BoundArgs>
1707 struct _Bind_simple_helper
1709 typedef _Maybe_wrap_member_pointer<typename decay<_Func>::type>
1711 typedef typename __maybe_type::type __func_type;
1712 typedef _Bind_simple<__func_type(typename decay<_BoundArgs>::type...)>
1718 template<
typename _Callable,
typename... _Args>
1719 typename _Bind_simple_helper<_Callable, _Args...>::__type
1720 __bind_simple(_Callable&& __callable, _Args&&... __args)
1722 typedef _Bind_simple_helper<_Callable, _Args...> __helper_type;
1723 typedef typename __helper_type::__maybe_type __maybe_type;
1724 typedef typename __helper_type::__type __result_type;
1725 return __result_type(
1726 __maybe_type::__do_wrap( std::forward<_Callable>(__callable)),
1727 std::forward<_Args>(__args)...);
1740 const char*
what()
const noexcept;
1748 template<
typename _Tp>
1751 || is_member_pointer<_Tp>::value)>
1754 class _Undefined_class;
1759 const void* _M_const_object;
1760 void (*_M_function_pointer)();
1761 void (_Undefined_class::*_M_member_pointer)();
1766 void* _M_access() {
return &_M_pod_data[0]; }
1767 const void* _M_access()
const {
return &_M_pod_data[0]; }
1769 template<
typename _Tp>
1772 {
return *
static_cast<_Tp*
>(_M_access()); }
1774 template<
typename _Tp>
1777 {
return *
static_cast<const _Tp*
>(_M_access()); }
1779 _Nocopy_types _M_unused;
1780 char _M_pod_data[
sizeof(_Nocopy_types)];
1783 enum _Manager_operation
1793 template<
typename _Tp>
1794 struct _Simple_type_wrapper
1796 _Simple_type_wrapper(_Tp __value) : __value(__value) { }
1801 template<
typename _Tp>
1802 struct __is_location_invariant<_Simple_type_wrapper<_Tp> >
1803 : __is_location_invariant<_Tp>
1808 template<
typename _Functor>
1810 __callable_functor(_Functor& __f)
1813 template<
typename _Member,
typename _Class>
1814 inline _Mem_fn<_Member _Class::*>
1815 __callable_functor(_Member _Class::* &__p)
1818 template<
typename _Member,
typename _Class>
1819 inline _Mem_fn<_Member _Class::*>
1820 __callable_functor(_Member _Class::*
const &__p)
1823 template<
typename _Member,
typename _Class>
1824 inline _Mem_fn<_Member _Class::*>
1825 __callable_functor(_Member _Class::*
volatile &__p)
1828 template<
typename _Member,
typename _Class>
1829 inline _Mem_fn<_Member _Class::*>
1830 __callable_functor(_Member _Class::*
const volatile &__p)
1833 template<
typename _Signature>
1840 static const std::size_t _M_max_size =
sizeof(_Nocopy_types);
1841 static const std::size_t _M_max_align = __alignof__(_Nocopy_types);
1843 template<
typename _Functor>
1847 static const bool __stored_locally =
1849 &&
sizeof(_Functor) <= _M_max_size
1850 && __alignof__(_Functor) <= _M_max_align
1851 && (_M_max_align % __alignof__(_Functor) == 0));
1857 _M_get_pointer(
const _Any_data& __source)
1859 const _Functor* __ptr =
1861 : __source._M_access<_Functor*>();
1862 return const_cast<_Functor*
>(__ptr);
1868 _M_clone(_Any_data& __dest,
const _Any_data& __source,
true_type)
1870 new (__dest._M_access()) _Functor(__source._M_access<_Functor>());
1876 _M_clone(_Any_data& __dest,
const _Any_data& __source,
false_type)
1878 __dest._M_access<_Functor*>() =
1879 new _Functor(*__source._M_access<_Functor*>());
1885 _M_destroy(_Any_data& __victim,
true_type)
1887 __victim._M_access<_Functor>().~_Functor();
1894 delete __victim._M_access<_Functor*>();
1899 _M_manager(_Any_data& __dest,
const _Any_data& __source,
1900 _Manager_operation __op)
1905 case __get_type_info:
1906 __dest._M_access<
const type_info*>() = &
typeid(_Functor);
1909 case __get_functor_ptr:
1910 __dest._M_access<_Functor*>() = _M_get_pointer(__source);
1913 case __clone_functor:
1914 _M_clone(__dest, __source, _Local_storage());
1917 case __destroy_functor:
1918 _M_destroy(__dest, _Local_storage());
1925 _M_init_functor(_Any_data& __functor, _Functor&& __f)
1926 { _M_init_functor(__functor, std::move(__f), _Local_storage()); }
1928 template<
typename _Signature>
1930 _M_not_empty_function(
const function<_Signature>& __f)
1931 {
return static_cast<bool>(__f); }
1933 template<
typename _Tp>
1935 _M_not_empty_function(_Tp*
const& __fp)
1938 template<
typename _Class,
typename _Tp>
1940 _M_not_empty_function(_Tp _Class::*
const& __mp)
1943 template<
typename _Tp>
1945 _M_not_empty_function(
const _Tp&)
1950 _M_init_functor(_Any_data& __functor, _Functor&& __f,
true_type)
1951 {
new (__functor._M_access()) _Functor(std::move(__f)); }
1954 _M_init_functor(_Any_data& __functor, _Functor&& __f,
false_type)
1955 { __functor._M_access<_Functor*>() =
new _Functor(std::move(__f)); }
1958 template<
typename _Functor>
1959 class _Ref_manager :
public _Base_manager<_Functor*>
1961 typedef _Function_base::_Base_manager<_Functor*> _Base;
1965 _M_manager(_Any_data& __dest,
const _Any_data& __source,
1966 _Manager_operation __op)
1971 case __get_type_info:
1972 __dest._M_access<
const type_info*>() = &
typeid(_Functor);
1975 case __get_functor_ptr:
1976 __dest._M_access<_Functor*>() = *_Base::_M_get_pointer(__source);
1981 _Base::_M_manager(__dest, __source, __op);
1998 _M_manager(_M_functor, _M_functor, __destroy_functor);
2002 bool _M_empty()
const {
return !_M_manager; }
2004 typedef bool (*_Manager_type)(_Any_data&,
const _Any_data&,
2005 _Manager_operation);
2007 _Any_data _M_functor;
2008 _Manager_type _M_manager;
2011 template<
typename _Signature,
typename _Functor>
2012 class _Function_handler;
2014 template<
typename _Res,
typename _Functor,
typename... _ArgTypes>
2015 class _Function_handler<_Res(_ArgTypes...), _Functor>
2016 :
public _Function_base::_Base_manager<_Functor>
2018 typedef _Function_base::_Base_manager<_Functor> _Base;
2022 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
2024 return (*_Base::_M_get_pointer(__functor))(
2025 std::forward<_ArgTypes>(__args)...);
2029 template<
typename _Functor,
typename... _ArgTypes>
2030 class _Function_handler<void(_ArgTypes...), _Functor>
2031 :
public _Function_base::_Base_manager<_Functor>
2033 typedef _Function_base::_Base_manager<_Functor> _Base;
2037 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
2039 (*_Base::_M_get_pointer(__functor))(
2040 std::forward<_ArgTypes>(__args)...);
2044 template<
typename _Res,
typename _Functor,
typename... _ArgTypes>
2045 class _Function_handler<_Res(_ArgTypes...), reference_wrapper<_Functor> >
2046 :
public _Function_base::_Ref_manager<_Functor>
2048 typedef _Function_base::_Ref_manager<_Functor> _Base;
2052 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
2054 return __callable_functor(**_Base::_M_get_pointer(__functor))(
2055 std::forward<_ArgTypes>(__args)...);
2059 template<
typename _Functor,
typename... _ArgTypes>
2060 class _Function_handler<void(_ArgTypes...), reference_wrapper<_Functor> >
2061 :
public _Function_base::_Ref_manager<_Functor>
2063 typedef _Function_base::_Ref_manager<_Functor> _Base;
2067 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
2069 __callable_functor(**_Base::_M_get_pointer(__functor))(
2070 std::forward<_ArgTypes>(__args)...);
2074 template<
typename _Class,
typename _Member,
typename _Res,
2075 typename... _ArgTypes>
2076 class _Function_handler<_Res(_ArgTypes...), _Member _Class::*>
2077 :
public _Function_handler<void(_ArgTypes...), _Member _Class::*>
2079 typedef _Function_handler<void(_ArgTypes...), _Member _Class::*>
2084 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
2086 return std::mem_fn(_Base::_M_get_pointer(__functor)->__value)(
2087 std::forward<_ArgTypes>(__args)...);
2091 template<
typename _Class,
typename _Member,
typename... _ArgTypes>
2092 class _Function_handler<void(_ArgTypes...), _Member _Class::*>
2093 :
public _Function_base::_Base_manager<
2094 _Simple_type_wrapper< _Member _Class::* > >
2096 typedef _Member _Class::* _Functor;
2097 typedef _Simple_type_wrapper<_Functor> _Wrapper;
2098 typedef _Function_base::_Base_manager<_Wrapper> _Base;
2102 _M_manager(_Any_data& __dest,
const _Any_data& __source,
2103 _Manager_operation __op)
2108 case __get_type_info:
2109 __dest._M_access<
const type_info*>() = &
typeid(_Functor);
2112 case __get_functor_ptr:
2113 __dest._M_access<_Functor*>() =
2114 &_Base::_M_get_pointer(__source)->__value;
2118 _Base::_M_manager(__dest, __source, __op);
2124 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
2126 std::mem_fn(_Base::_M_get_pointer(__functor)->__value)(
2127 std::forward<_ArgTypes>(__args)...);
2131 template<
typename _From,
typename _To>
2132 using __check_func_return_type
2133 = __or_<is_void<_To>, is_convertible<_From, _To>>;
2141 template<
typename _Res,
typename... _ArgTypes>
2142 class function<_Res(_ArgTypes...)>
2146 typedef _Res _Signature_type(_ArgTypes...);
2148 template<
typename _Functor>
2149 using _Invoke = decltype(__callable_functor(std::declval<_Functor&>())
2150 (std::declval<_ArgTypes>()...) );
2152 template<
typename _Functor>
2153 using _Callable = __check_func_return_type<_Invoke<_Functor>, _Res>;
2155 template<
typename _Cond,
typename _Tp>
2156 using _Requires =
typename enable_if<_Cond::value, _Tp>::type;
2159 typedef _Res result_type;
2174 function(nullptr_t) noexcept
2185 function(
const function& __x);
2217 template<
typename _Functor,
2218 typename = _Requires<_Callable<_Functor>,
void>>
2236 function(__x).
swap(*
this);
2254 function(std::move(__x)).
swap(*
this);
2270 _M_manager(_M_functor, _M_functor, __destroy_functor);
2293 template<
typename _Functor>
2294 _Requires<_Callable<_Functor>,
function&>
2297 function(std::forward<_Functor>(__f)).swap(*
this);
2302 template<
typename _Functor>
2306 function(__f).
swap(*
this);
2347 explicit operator bool() const noexcept
2348 {
return !_M_empty(); }
2360 _Res operator()(_ArgTypes... __args)
const;
2373 const type_info& target_type() const noexcept;
2384 template<typename _Functor> _Functor* target() noexcept;
2387 template<typename _Functor> const _Functor* target() const noexcept;
2391 typedef _Res (*_Invoker_type)(
const _Any_data&, _ArgTypes...);
2392 _Invoker_type _M_invoker;
2396 template<
typename _Res,
typename... _ArgTypes>
2397 function<_Res(_ArgTypes...)>::
2398 function(
const function& __x)
2401 if (static_cast<bool>(__x))
2403 _M_invoker = __x._M_invoker;
2404 _M_manager = __x._M_manager;
2405 __x._M_manager(_M_functor, __x._M_functor, __clone_functor);
2409 template<
typename _Res,
typename... _ArgTypes>
2410 template<
typename _Functor,
typename>
2411 function<_Res(_ArgTypes...)>::
2412 function(_Functor __f)
2415 typedef _Function_handler<_Signature_type, _Functor> _My_handler;
2417 if (_My_handler::_M_not_empty_function(__f))
2419 _My_handler::_M_init_functor(_M_functor, std::move(__f));
2420 _M_invoker = &_My_handler::_M_invoke;
2421 _M_manager = &_My_handler::_M_manager;
2425 template<
typename _Res,
typename... _ArgTypes>
2427 function<_Res(_ArgTypes...)>::
2428 operator()(_ArgTypes... __args)
const
2431 __throw_bad_function_call();
2432 return _M_invoker(_M_functor, std::forward<_ArgTypes>(__args)...);
2436 template<
typename _Res,
typename... _ArgTypes>
2438 function<_Res(_ArgTypes...)>::
2439 target_type() const noexcept
2443 _Any_data __typeinfo_result;
2444 _M_manager(__typeinfo_result, _M_functor, __get_type_info);
2445 return *__typeinfo_result._M_access<
const type_info*>();
2448 return typeid(void);
2451 template<
typename _Res,
typename... _ArgTypes>
2452 template<
typename _Functor>
2454 function<_Res(_ArgTypes...)>::
2457 if (
typeid(_Functor) == target_type() && _M_manager)
2460 if (_M_manager(__ptr, _M_functor, __get_functor_ptr)
2464 return __ptr._M_access<_Functor*>();
2470 template<
typename _Res,
typename... _ArgTypes>
2471 template<
typename _Functor>
2473 function<_Res(_ArgTypes...)>::
2474 target() const noexcept
2476 if (
typeid(_Functor) == target_type() && _M_manager)
2479 _M_manager(__ptr, _M_functor, __get_functor_ptr);
2480 return __ptr._M_access<
const _Functor*>();
2496 template<
typename _Res,
typename... _Args>
2498 operator==(
const function<_Res(_Args...)>& __f, nullptr_t) noexcept
2499 {
return !
static_cast<bool>(__f); }
2502 template<
typename _Res,
typename... _Args>
2504 operator==(nullptr_t,
const function<_Res(_Args...)>& __f) noexcept
2505 {
return !
static_cast<bool>(__f); }
2514 template<
typename _Res,
typename... _Args>
2516 operator!=(
const function<_Res(_Args...)>& __f, nullptr_t) noexcept
2517 {
return static_cast<bool>(__f); }
2520 template<
typename _Res,
typename... _Args>
2522 operator!=(nullptr_t,
const function<_Res(_Args...)>& __f) noexcept
2523 {
return static_cast<bool>(__f); }
2532 template<
typename _Res,
typename... _Args>
2534 swap(
function<_Res(_Args...)>& __x,
function<_Res(_Args...)>& __y)
2537 _GLIBCXX_END_NAMESPACE_VERSION
2542 #endif // _GLIBCXX_FUNCTIONAL
Primary class template for reference_wrapper.
reference_wrapper< _Tp > ref(_Tp &__t) noexcept
Denotes a reference should be taken to a variable.
Exception class thrown when class template function's operator() is called with an empty target...
Primary class template, tuple.
function & operator=(function &&__x)
Function move-assignment operator.
If we have found a result_type, extract it.
Type of the function object returned from bind().
void swap(function &__x)
Swap the targets of two function objects.
Determines if the given type _Tp is a placeholder in a bind() expression and, if so, which placeholder it is. [TR1 3.6.2].
Base class for all library exceptions.
Base class of all polymorphic function object wrappers.
_Requires< _Callable< _Functor >, function & > operator=(_Functor &&__f)
Function assignment to a new target.
const char * what() const noexcept
function & operator=(nullptr_t)
Function assignment to zero.
function & operator=(reference_wrapper< _Functor > __f) noexcept
_Bind_helper< __is_socketlike< _Func >::value, _Func, _BoundArgs...>::type bind(_Func &&__f, _BoundArgs &&...__args)
Function template for std::bind.
reference_wrapper< const _Tp > cref(const _Tp &__t) noexcept
Denotes a const reference should be taken to a variable.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
Determines if the given type _Tp is a function object should be treated as a subexpression when evalu...
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
The type of placeholder objects defined by libstdc++.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
enable_if< (!is_member_pointer< _Functor >::value &&!is_function< _Functor >::value &&!is_function< typename remove_pointer< _Functor >::type >::value), typename result_of< _Functor &(_Args &&...)>::type >::type __invoke(_Functor &__f, _Args &&...__args)
Type of the function object returned from bind<R>().
function & operator=(const function &__x)
Function assignment operator.
_Mem_fn< _Tp _Class::* > mem_fn(_Tp _Class::*) noexcept
Returns a function object that forwards to the member pointer pm.