32 _GLIBCXX_BEGIN_NAMESPACE_TR1
34 template<
typename _MemberPo
inter>
42 template<
typename _Tp>
45 template<
typename _Up>
49 template<
typename _Up>
50 static __one __test(_Wrap_type<typename _Up::result_type>*);
52 template<
typename _Up>
53 static __two __test(...);
56 static const bool value =
sizeof(__test<_Tp>(0)) == 1;
59 template<
typename _Tp>
60 struct _Has_result_type
62 _Has_result_type_helper<typename remove_cv<_Tp>::type>::value>
69 template<
bool _Has_result_type,
typename _Functor>
73 template<
typename _Functor>
76 typedef typename _Functor::result_type result_type;
83 template<
typename _Functor>
90 template<
typename _Res,
typename... _ArgTypes>
93 typedef _Res result_type;
97 template<
typename _Res,
typename... _ArgTypes>
100 typedef _Res result_type;
104 template<
typename _Res,
typename... _ArgTypes>
107 typedef _Res result_type;
111 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
114 typedef _Res result_type;
118 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
121 typedef _Res result_type;
125 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
128 typedef _Res result_type;
132 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
135 typedef _Res result_type;
142 template<
typename _Functor>
148 template<
typename _Signature>
157 template<
bool _Has_result_type,
typename _Signature>
161 template<
typename _Res,
typename _Class,
typename _T1>
164 typedef typename _Mem_fn<_Res _Class::*>
165 ::template _Result_type<_T1>::type type;
172 template<
typename _Functor,
typename... _ArgTypes>
173 class result_of<_Functor(_ArgTypes...)>
175 _Has_result_type<_Weak_result_type<_Functor> >::value,
176 _Functor(_ArgTypes...)>
181 template<
typename _Functor,
typename... _ArgTypes>
191 template<
typename _Functor,
typename... _ArgTypes>
194 typedef typename _Functor
195 ::template result<_Functor(_ArgTypes...)>::type type;
202 template<
typename _Functor>
209 template<
typename _Tp>
213 template<
typename _T1,
typename _Res>
218 static __two __test(...);
221 static const bool value =
sizeof(__test((_Tp*)0)) == 1;
225 template<
typename _Tp>
229 template<
typename _T1,
typename _T2,
typename _Res>
234 static __two __test(...);
237 static const bool value =
sizeof(__test((_Tp*)0)) == 1;
241 template<typename _Tp, bool _IsFunctionType = is_function<_Tp>::value>
247 template<
typename _Tp>
257 template<
typename _Functor,
typename... _Args>
259 typename __gnu_cxx::__enable_if<
260 (!is_member_pointer<_Functor>::value
261 && !is_function<_Functor>::value
262 && !is_function<typename remove_pointer<_Functor>::type>::value),
263 typename result_of<_Functor(_Args...)>::type
267 return __f(__args...);
270 template<
typename _Functor,
typename... _Args>
272 typename __gnu_cxx::__enable_if<
273 (is_member_pointer<_Functor>::value
274 && !is_function<_Functor>::value
275 && !is_function<typename remove_pointer<_Functor>::type>::value),
276 typename result_of<_Functor(_Args...)>::type
278 __invoke(_Functor& __f, _Args&... __args)
280 return mem_fn(__f)(__args...);
284 template<
typename _Functor,
typename... _Args>
286 typename __gnu_cxx::__enable_if<
287 (is_pointer<_Functor>::value
288 && is_function<typename remove_pointer<_Functor>::type>::value),
289 typename result_of<_Functor(_Args...)>::type
291 __invoke(_Functor __f, _Args&... __args)
293 return __f(__args...);
301 template<
bool _Unary,
bool _Binary,
typename _Tp>
305 template<
typename _Tp>
311 template<
typename _Tp>
314 typename _Tp::result_type>
318 template<
typename _Tp>
319 struct _Reference_wrapper_base_impl<false, true, _Tp>
320 : binary_function<typename _Tp::first_argument_type,
321 typename _Tp::second_argument_type,
322 typename _Tp::result_type>
327 template<
typename _Tp>
328 struct _Reference_wrapper_base_impl<true, true, _Tp>
329 : unary_function<typename _Tp::argument_type,
330 typename _Tp::result_type>,
331 binary_function<typename _Tp::first_argument_type,
332 typename _Tp::second_argument_type,
333 typename _Tp::result_type>
335 typedef typename _Tp::result_type result_type;
344 template<
typename _Tp>
347 _Derives_from_unary_function<_Tp>::value,
348 _Derives_from_binary_function<_Tp>::value,
353 template<
typename _Res,
typename _T1>
359 template<
typename _Res,
typename _T1,
typename _T2>
360 struct _Reference_wrapper_base<_Res(_T1, _T2)>
361 : binary_function<_T1, _T2, _Res>
365 template<
typename _Res,
typename _T1>
366 struct _Reference_wrapper_base<_Res(*)(_T1)>
367 : unary_function<_T1, _Res>
371 template<
typename _Res,
typename _T1,
typename _T2>
372 struct _Reference_wrapper_base<_Res(*)(_T1, _T2)>
373 : binary_function<_T1, _T2, _Res>
377 template<
typename _Res,
typename _T1>
378 struct _Reference_wrapper_base<_Res (_T1::*)()>
379 : unary_function<_T1*, _Res>
383 template<
typename _Res,
typename _T1,
typename _T2>
384 struct _Reference_wrapper_base<_Res (_T1::*)(_T2)>
385 : binary_function<_T1*, _T2, _Res>
389 template<
typename _Res,
typename _T1>
390 struct _Reference_wrapper_base<_Res (_T1::*)() const>
391 : unary_function<const _T1*, _Res>
395 template<
typename _Res,
typename _T1,
typename _T2>
396 struct _Reference_wrapper_base<_Res (_T1::*)(_T2) const>
397 : binary_function<const _T1*, _T2, _Res>
401 template<
typename _Res,
typename _T1>
402 struct _Reference_wrapper_base<_Res (_T1::*)() volatile>
403 : unary_function<volatile _T1*, _Res>
407 template<
typename _Res,
typename _T1,
typename _T2>
408 struct _Reference_wrapper_base<_Res (_T1::*)(_T2) volatile>
409 : binary_function<volatile _T1*, _T2, _Res>
413 template<
typename _Res,
typename _T1>
414 struct _Reference_wrapper_base<_Res (_T1::*)() const volatile>
415 : unary_function<const volatile _T1*, _Res>
419 template<
typename _Res,
typename _T1,
typename _T2>
420 struct _Reference_wrapper_base<_Res (_T1::*)(_T2) const volatile>
421 : binary_function<const volatile _T1*, _T2, _Res>
425 template<
typename _Tp>
431 typedef typename _Function_to_function_pointer<_Tp>::type
443 _M_data(__inref._M_data)
449 _M_data = __inref._M_data;
453 operator _Tp&()
const
454 {
return this->
get(); }
460 template<
typename... _Args>
461 typename result_of<_M_func_type(_Args...)>::type
462 operator()(_Args&... __args)
const
470 template<
typename _Tp>
476 template<
typename _Tp>
477 inline reference_wrapper<const _Tp>
479 {
return reference_wrapper<const _Tp>(__t); }
481 template<
typename _Tp>
482 inline reference_wrapper<_Tp>
483 ref(reference_wrapper<_Tp> __t)
484 {
return ref(__t.get()); }
486 template<
typename _Tp>
487 inline reference_wrapper<const _Tp>
488 cref(reference_wrapper<_Tp> __t)
489 {
return cref(__t.get()); }
491 template<
typename _Tp,
bool>
492 struct _Mem_fn_const_or_non
494 typedef const _Tp& type;
497 template<
typename _Tp>
498 struct _Mem_fn_const_or_non<_Tp, false>
508 template<
typename _Res,
typename... _ArgTypes>
512 template<
typename _Res,
typename _T1>
517 template<
typename _Res,
typename _T1,
typename _T2>
522 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
523 class _Mem_fn<_Res (_Class::*)(_ArgTypes...)>
526 typedef _Res (_Class::*_Functor)(_ArgTypes...);
528 template<
typename _Tp>
530 _M_call(_Tp& __object,
const volatile _Class *,
531 _ArgTypes... __args)
const
532 {
return (__object.*__pmf)(__args...); }
534 template<
typename _Tp>
536 _M_call(_Tp& __ptr,
const volatile void *, _ArgTypes... __args)
const
537 {
return ((*__ptr).*__pmf)(__args...); }
540 typedef _Res result_type;
542 explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
546 operator()(_Class& __object, _ArgTypes... __args)
const
547 {
return (__object.*__pmf)(__args...); }
551 operator()(_Class* __object, _ArgTypes... __args)
const
552 {
return (__object->*__pmf)(__args...); }
555 template<
typename _Tp>
557 operator()(_Tp& __object, _ArgTypes... __args)
const
558 {
return _M_call(__object, &__object, __args...); }
565 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
566 class _Mem_fn<_Res (_Class::*)(_ArgTypes...) const>
570 typedef _Res (_Class::*_Functor)(_ArgTypes...)
const;
572 template<
typename _Tp>
574 _M_call(_Tp& __object,
const volatile _Class *,
575 _ArgTypes... __args)
const
576 {
return (__object.*__pmf)(__args...); }
578 template<
typename _Tp>
580 _M_call(_Tp& __ptr,
const volatile void *, _ArgTypes... __args)
const
581 {
return ((*__ptr).*__pmf)(__args...); }
584 typedef _Res result_type;
586 explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
590 operator()(
const _Class& __object, _ArgTypes... __args)
const
591 {
return (__object.*__pmf)(__args...); }
595 operator()(
const _Class* __object, _ArgTypes... __args)
const
596 {
return (__object->*__pmf)(__args...); }
599 template<
typename _Tp>
600 _Res operator()(_Tp& __object, _ArgTypes... __args)
const
601 {
return _M_call(__object, &__object, __args...); }
608 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
609 class _Mem_fn<_Res (_Class::*)(_ArgTypes...) volatile>
613 typedef _Res (_Class::*_Functor)(_ArgTypes...)
volatile;
615 template<
typename _Tp>
617 _M_call(_Tp& __object,
const volatile _Class *,
618 _ArgTypes... __args)
const
619 {
return (__object.*__pmf)(__args...); }
621 template<
typename _Tp>
623 _M_call(_Tp& __ptr,
const volatile void *, _ArgTypes... __args)
const
624 {
return ((*__ptr).*__pmf)(__args...); }
627 typedef _Res result_type;
629 explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
633 operator()(
volatile _Class& __object, _ArgTypes... __args)
const
634 {
return (__object.*__pmf)(__args...); }
638 operator()(
volatile _Class* __object, _ArgTypes... __args)
const
639 {
return (__object->*__pmf)(__args...); }
642 template<
typename _Tp>
644 operator()(_Tp& __object, _ArgTypes... __args)
const
645 {
return _M_call(__object, &__object, __args...); }
652 template<
typename _Res,
typename _Class,
typename... _ArgTypes>
653 class _Mem_fn<_Res (_Class::*)(_ArgTypes...) const volatile>
657 typedef _Res (_Class::*_Functor)(_ArgTypes...)
const volatile;
659 template<
typename _Tp>
661 _M_call(_Tp& __object,
const volatile _Class *,
662 _ArgTypes... __args)
const
663 {
return (__object.*__pmf)(__args...); }
665 template<
typename _Tp>
667 _M_call(_Tp& __ptr,
const volatile void *, _ArgTypes... __args)
const
668 {
return ((*__ptr).*__pmf)(__args...); }
671 typedef _Res result_type;
673 explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
677 operator()(
const volatile _Class& __object, _ArgTypes... __args)
const
678 {
return (__object.*__pmf)(__args...); }
682 operator()(
const volatile _Class* __object, _ArgTypes... __args)
const
683 {
return (__object->*__pmf)(__args...); }
686 template<
typename _Tp>
687 _Res operator()(_Tp& __object, _ArgTypes... __args)
const
688 {
return _M_call(__object, &__object, __args...); }
695 template<
typename _Res,
typename _Class>
696 class _Mem_fn<_Res _Class::*>
700 template<
typename _Tp>
702 _M_call(_Tp& __object, _Class *)
const
703 {
return __object.*__pm; }
705 template<
typename _Tp,
typename _Up>
707 _M_call(_Tp& __object, _Up *
const *)
const
708 {
return (*__object).*__pm; }
710 template<
typename _Tp,
typename _Up>
712 _M_call(_Tp& __object,
const _Up *
const *)
const
713 {
return (*__object).*__pm; }
715 template<
typename _Tp>
717 _M_call(_Tp& __object,
const _Class *)
const
718 {
return __object.*__pm; }
720 template<
typename _Tp>
722 _M_call(_Tp& __ptr,
const volatile void*)
const
723 {
return (*__ptr).*__pm; }
725 template<
typename _Tp>
static _Tp& __get_ref();
727 template<
typename _Tp>
728 static __sfinae_types::__one __check_const(_Tp&, _Class*);
729 template<
typename _Tp,
typename _Up>
730 static __sfinae_types::__one __check_const(_Tp&, _Up *
const *);
731 template<
typename _Tp,
typename _Up>
732 static __sfinae_types::__two __check_const(_Tp&,
const _Up *
const *);
733 template<
typename _Tp>
734 static __sfinae_types::__two __check_const(_Tp&,
const _Class*);
735 template<
typename _Tp>
736 static __sfinae_types::__two __check_const(_Tp&,
const volatile void*);
739 template<
typename _Tp>
741 : _Mem_fn_const_or_non<_Res,
742 (sizeof(__sfinae_types::__two)
743 == sizeof(__check_const<_Tp>(__get_ref<_Tp>(), (_Tp*)0)))>
746 template<
typename _Signature>
749 template<
typename _CVMem,
typename _Tp>
750 struct result<_CVMem(_Tp)>
751 :
public _Result_type<_Tp> { };
753 template<
typename _CVMem,
typename _Tp>
754 struct result<_CVMem(_Tp&)>
755 :
public _Result_type<_Tp> { };
758 _Mem_fn(_Res _Class::*__pm) : __pm(__pm) { }
762 operator()(_Class& __object)
const
763 {
return __object.*__pm; }
766 operator()(
const _Class& __object)
const
767 {
return __object.*__pm; }
771 operator()(_Class* __object)
const
772 {
return __object->*__pm; }
775 operator()(
const _Class* __object)
const
776 {
return __object->*__pm; }
779 template<
typename _Tp>
780 typename _Result_type<_Tp>::type
781 operator()(_Tp& __unknown)
const
782 {
return _M_call(__unknown, &__unknown); }
792 template<
typename _Tp,
typename _Class>
793 inline _Mem_fn<_Tp _Class::*>
796 return _Mem_fn<_Tp _Class::*>(__pm);
804 template<
typename _Tp>
806 {
static const bool value =
false; };
808 template<
typename _Tp>
815 template<
typename _Tp>
817 {
static const int value = 0; };
819 template<
typename _Tp>
832 namespace placeholders
874 {
static const int value = _Num; };
883 template<
int... _Indexes>
887 template<std::
size_t _Num,
typename _Tuple = _Index_tuple<> >
890 template<std::size_t _Num,
int... _Indexes>
893 _Index_tuple<_Indexes..., sizeof...(_Indexes)> >
897 template<
int... _Indexes>
907 struct _No_tuple_element;
914 template<
int __i,
typename _Tuple,
bool _IsSafe>
923 template<
int __i,
typename _Tuple>
926 typedef _No_tuple_element type;
933 template<
int __i,
typename _Tuple>
936 (__i >= 0 && __i < tuple_size<_Tuple>::value)>
951 template<
typename _Arg,
960 template<
typename _Tp>
964 typedef _Tp& result_type;
970 template<
typename _CVRef,
typename _Tuple>
972 operator()(_CVRef& __arg,
const _Tuple&)
const volatile
973 {
return __arg.get(); }
981 template<
typename _Arg>
982 class _Mu<_Arg, true, false>
985 template<
typename _Signature>
class result;
990 template<
typename _CVMu,
typename _CVArg,
typename... _Args>
991 class result<_CVMu(_CVArg, tuple<_Args...>)>
992 :
public result_of<_CVArg(_Args...)> { };
994 template<
typename _CVArg,
typename... _Args>
995 typename result_of<_CVArg(_Args...)>::type
996 operator()(_CVArg& __arg,
1002 return this->__call(__arg, __tuple, _Indexes());
1008 template<
typename _CVArg,
typename... _Args,
int... _Indexes>
1009 typename result_of<_CVArg(_Args...)>::type
1013 return __arg(_GLIBCXX_TR1 get<_Indexes>(__tuple)...);
1022 template<
typename _Arg>
1026 template<
typename _Signature>
class result;
1028 template<
typename _CVMu,
typename _CVArg,
typename _Tuple>
1029 class result<_CVMu(_CVArg, _Tuple)>
1039 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
1040 typedef typename add_lvalue_reference<__base_type>::type type;
1042 typedef typename add_reference<__base_type>::type type;
1046 template<
typename _Tuple>
1047 typename result<_Mu(_Arg, _Tuple)>::type
1048 operator()(
const volatile _Arg&,
const _Tuple& __tuple)
const volatile
1050 return ::std::_GLIBCXX_TR1 get<(is_placeholder<_Arg>::value
1060 template<
typename _Arg>
1064 template<
typename _Signature>
struct result;
1066 template<
typename _CVMu,
typename _CVArg,
typename _Tuple>
1067 struct result<_CVMu(_CVArg, _Tuple)>
1069 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
1070 typedef typename add_lvalue_reference<_CVArg>::type type;
1072 typedef typename add_reference<_CVArg>::type type;
1077 template<
typename _CVArg,
typename _Tuple>
1079 operator()(_CVArg& __arg,
const _Tuple&)
const volatile
1088 template<
typename _Tp>
1094 __do_wrap(
const _Tp& __x)
1103 template<
typename _Tp,
typename _Class>
1106 typedef _Mem_fn<_Tp _Class::*> type;
1109 __do_wrap(_Tp _Class::* __pm)
1110 {
return type(__pm); }
1114 template<
typename _Signature>
1117 template<
typename _Functor,
typename... _Bound_args>
1118 class _Bind<_Functor(_Bound_args...)>
1121 typedef _Bind __self_type;
1126 tuple<_Bound_args...> _M_bound_args;
1129 template<
typename... _Args,
int... _Indexes>
1137 (_GLIBCXX_TR1 get<_Indexes>(_M_bound_args), __args)...);
1141 template<
typename... _Args,
int... _Indexes>
1149 (_GLIBCXX_TR1 get<_Indexes>(_M_bound_args), __args)...);
1153 template<
typename... _Args,
int... _Indexes>
1155 volatile _Functor(
typename result_of<_Mu<_Bound_args>
1156 (
volatile _Bound_args, tuple<_Args...>)
1158 __call(
const tuple<_Args...>& __args,
1159 _Index_tuple<_Indexes...>)
volatile
1161 return _M_f(_Mu<_Bound_args>()
1162 (_GLIBCXX_TR1 get<_Indexes>(_M_bound_args), __args)...);
1166 template<
typename... _Args,
int... _Indexes>
1168 const volatile _Functor(
typename result_of<_Mu<_Bound_args>
1169 (
const volatile _Bound_args,
1172 __call(
const tuple<_Args...>& __args,
1173 _Index_tuple<_Indexes...>)
const volatile
1175 return _M_f(_Mu<_Bound_args>()
1176 (_GLIBCXX_TR1 get<_Indexes>(_M_bound_args), __args)...);
1180 explicit _Bind(_Functor __f, _Bound_args... __bound_args)
1181 : _M_f(__f), _M_bound_args(__bound_args...) { }
1184 template<
typename... _Args>
1186 _Functor(
typename result_of<_Mu<_Bound_args>
1187 (_Bound_args, tuple<_Args...>)>::type...)
1189 operator()(_Args&... __args)
1191 return this->__call(_GLIBCXX_TR1 tie(__args...), _Bound_indexes());
1195 template<
typename... _Args>
1197 const _Functor(
typename result_of<_Mu<_Bound_args>
1198 (
const _Bound_args, tuple<_Args...>)>::type...)
1200 operator()(_Args&... __args)
const
1202 return this->__call(_GLIBCXX_TR1 tie(__args...), _Bound_indexes());
1207 template<
typename... _Args>
1209 volatile _Functor(
typename result_of<_Mu<_Bound_args>
1210 (
volatile _Bound_args, tuple<_Args...>)>::type...)
1212 operator()(_Args&... __args)
volatile
1214 return this->__call(_GLIBCXX_TR1 tie(__args...), _Bound_indexes());
1219 template<
typename... _Args>
1221 const volatile _Functor(
typename result_of<_Mu<_Bound_args>
1222 (
const volatile _Bound_args,
1223 tuple<_Args...>)>::type...)
1225 operator()(_Args&... __args)
const volatile
1227 return this->__call(_GLIBCXX_TR1 tie(__args...), _Bound_indexes());
1232 template<
typename _Result,
typename _Signature>
1235 template<
typename _Result,
typename _Functor,
typename... _Bound_args>
1243 tuple<_Bound_args...> _M_bound_args;
1246 template<
typename... _Args,
int... _Indexes>
1251 (_GLIBCXX_TR1 get<_Indexes>(_M_bound_args), __args)...);
1255 template<
typename... _Args,
int... _Indexes>
1260 (_GLIBCXX_TR1 get<_Indexes>(_M_bound_args), __args)...);
1264 template<
typename... _Args,
int... _Indexes>
1266 __call(
const tuple<_Args...>& __args,
1267 _Index_tuple<_Indexes...>)
volatile
1269 return _M_f(_Mu<_Bound_args>()
1270 (_GLIBCXX_TR1 get<_Indexes>(_M_bound_args), __args)...);
1274 template<
typename... _Args,
int... _Indexes>
1276 __call(
const tuple<_Args...>& __args,
1277 _Index_tuple<_Indexes...>)
const volatile
1279 return _M_f(_Mu<_Bound_args>()
1280 (_GLIBCXX_TR1 get<_Indexes>(_M_bound_args), __args)...);
1284 typedef _Result result_type;
1287 _Bind_result(_Functor __f, _Bound_args... __bound_args)
1288 : _M_f(__f), _M_bound_args(__bound_args...) { }
1291 template<
typename... _Args>
1293 operator()(_Args&... __args)
1295 return this->__call(_GLIBCXX_TR1 tie(__args...), _Bound_indexes());
1299 template<
typename... _Args>
1301 operator()(_Args&... __args)
const
1303 return this->__call(_GLIBCXX_TR1 tie(__args...), _Bound_indexes());
1307 template<
typename... _Args>
1309 operator()(_Args&... __args)
volatile
1311 return this->__call(_GLIBCXX_TR1 tie(__args...), _Bound_indexes());
1315 template<
typename... _Args>
1317 operator()(_Args&... __args)
const volatile
1319 return this->__call(_GLIBCXX_TR1 tie(__args...), _Bound_indexes());
1324 template<
typename _Signature>
1326 {
static const bool value =
true; };
1328 template<
typename _Signature>
1332 template<
typename _Result,
typename _Signature>
1334 {
static const bool value =
true; };
1336 template<
typename _Result,
typename _Signature>
1340 template<
typename _Functor,
typename... _ArgTypes>
1343 bind(_Functor __f, _ArgTypes... __args)
1346 typedef typename __maybe_type::type __functor_type;
1347 typedef _Bind<__functor_type(_ArgTypes...)> __result_type;
1348 return __result_type(__maybe_type::__do_wrap(__f), __args...);
1351 template<
typename _Result,
typename _Functor,
typename... _ArgTypes>
1353 _Bind_result<_Result,
1354 typename _Maybe_wrap_member_pointer<_Functor>::type
1356 bind(_Functor __f, _ArgTypes... __args)
1358 typedef _Maybe_wrap_member_pointer<_Functor> __maybe_type;
1359 typedef typename __maybe_type::type __functor_type;
1360 typedef _Bind_result<_Result, __functor_type(_ArgTypes...)>
1362 return __result_type(__maybe_type::__do_wrap(__f), __args...);
1377 struct _M_clear_type;
1384 template<
typename _Tp>
1387 (is_pointer<_Tp>::value
1388 || is_member_pointer<_Tp>::value)>
1392 class _Undefined_class;
1397 const void* _M_const_object;
1398 void (*_M_function_pointer)();
1399 void (_Undefined_class::*_M_member_pointer)();
1404 void* _M_access() {
return &_M_pod_data[0]; }
1405 const void* _M_access()
const {
return &_M_pod_data[0]; }
1407 template<
typename _Tp>
1410 {
return *
static_cast<_Tp*
>(_M_access()); }
1412 template<
typename _Tp>
1415 {
return *
static_cast<const _Tp*
>(_M_access()); }
1417 _Nocopy_types _M_unused;
1418 char _M_pod_data[
sizeof(_Nocopy_types)];
1421 enum _Manager_operation
1431 template<
typename _Tp>
1432 struct _Simple_type_wrapper
1434 _Simple_type_wrapper(_Tp __value) : __value(__value) { }
1439 template<
typename _Tp>
1440 struct __is_location_invariant<_Simple_type_wrapper<_Tp> >
1441 : __is_location_invariant<_Tp>
1447 template<
typename _Functor>
1449 __callable_functor(_Functor& __f)
1452 template<
typename _Member,
typename _Class>
1453 inline _Mem_fn<_Member _Class::*>
1454 __callable_functor(_Member _Class::* &__p)
1457 template<
typename _Member,
typename _Class>
1458 inline _Mem_fn<_Member _Class::*>
1459 __callable_functor(_Member _Class::*
const &__p)
1462 template<
typename _Signature>
1469 static const std::size_t _M_max_size =
sizeof(_Nocopy_types);
1470 static const std::size_t _M_max_align = __alignof__(_Nocopy_types);
1472 template<
typename _Functor>
1476 static const bool __stored_locally =
1478 &&
sizeof(_Functor) <= _M_max_size
1479 && __alignof__(_Functor) <= _M_max_align
1480 && (_M_max_align % __alignof__(_Functor) == 0));
1486 _M_get_pointer(
const _Any_data& __source)
1488 const _Functor* __ptr =
1489 __stored_locally? &__source._M_access<_Functor>()
1490 : __source._M_access<_Functor*>();
1491 return const_cast<_Functor*
>(__ptr);
1497 _M_clone(_Any_data& __dest,
const _Any_data& __source,
true_type)
1499 new (__dest._M_access()) _Functor(__source._M_access<_Functor>());
1505 _M_clone(_Any_data& __dest,
const _Any_data& __source,
false_type)
1507 __dest._M_access<_Functor*>() =
1508 new _Functor(*__source._M_access<_Functor*>());
1514 _M_destroy(_Any_data& __victim,
true_type)
1516 __victim._M_access<_Functor>().~_Functor();
1523 delete __victim._M_access<_Functor*>();
1528 _M_manager(_Any_data& __dest,
const _Any_data& __source,
1529 _Manager_operation __op)
1534 case __get_type_info:
1535 __dest._M_access<
const type_info*>() = &
typeid(_Functor);
1538 case __get_functor_ptr:
1539 __dest._M_access<_Functor*>() = _M_get_pointer(__source);
1542 case __clone_functor:
1543 _M_clone(__dest, __source, _Local_storage());
1546 case __destroy_functor:
1547 _M_destroy(__dest, _Local_storage());
1554 _M_init_functor(_Any_data& __functor,
const _Functor& __f)
1555 { _M_init_functor(__functor, __f, _Local_storage()); }
1557 template<
typename _Signature>
1559 _M_not_empty_function(
const function<_Signature>& __f)
1562 template<
typename _Tp>
1564 _M_not_empty_function(
const _Tp*& __fp)
1567 template<
typename _Class,
typename _Tp>
1569 _M_not_empty_function(_Tp _Class::*
const& __mp)
1572 template<
typename _Tp>
1574 _M_not_empty_function(
const _Tp&)
1579 _M_init_functor(_Any_data& __functor,
const _Functor& __f,
true_type)
1580 {
new (__functor._M_access()) _Functor(__f); }
1583 _M_init_functor(_Any_data& __functor,
const _Functor& __f,
false_type)
1584 { __functor._M_access<_Functor*>() =
new _Functor(__f); }
1587 template<
typename _Functor>
1588 class _Ref_manager :
public _Base_manager<_Functor*>
1590 typedef _Function_base::_Base_manager<_Functor*> _Base;
1594 _M_manager(_Any_data& __dest,
const _Any_data& __source,
1595 _Manager_operation __op)
1600 case __get_type_info:
1601 __dest._M_access<
const type_info*>() = &
typeid(_Functor);
1604 case __get_functor_ptr:
1605 __dest._M_access<_Functor*>() = *_Base::_M_get_pointer(__source);
1610 _Base::_M_manager(__dest, __source, __op);
1619 _Base::_M_init_functor(__functor, &__f.get());
1628 _M_manager(_M_functor, _M_functor, __destroy_functor);
1632 bool _M_empty()
const {
return !_M_manager; }
1634 typedef bool (*_Manager_type)(_Any_data&,
const _Any_data&,
1635 _Manager_operation);
1637 _Any_data _M_functor;
1638 _Manager_type _M_manager;
1641 template<
typename _Signature,
typename _Functor>
1642 class _Function_handler;
1644 template<
typename _Res,
typename _Functor,
typename... _ArgTypes>
1645 class _Function_handler<_Res(_ArgTypes...), _Functor>
1646 :
public _Function_base::_Base_manager<_Functor>
1648 typedef _Function_base::_Base_manager<_Functor> _Base;
1652 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
1654 return (*_Base::_M_get_pointer(__functor))(__args...);
1658 template<
typename _Functor,
typename... _ArgTypes>
1659 class _Function_handler<void(_ArgTypes...), _Functor>
1660 :
public _Function_base::_Base_manager<_Functor>
1662 typedef _Function_base::_Base_manager<_Functor> _Base;
1666 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
1668 (*_Base::_M_get_pointer(__functor))(__args...);
1672 template<
typename _Res,
typename _Functor,
typename... _ArgTypes>
1673 class _Function_handler<_Res(_ArgTypes...), reference_wrapper<_Functor> >
1674 :
public _Function_base::_Ref_manager<_Functor>
1676 typedef _Function_base::_Ref_manager<_Functor> _Base;
1680 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
1683 __callable_functor(**_Base::_M_get_pointer(__functor))(__args...);
1687 template<
typename _Functor,
typename... _ArgTypes>
1688 class _Function_handler<void(_ArgTypes...), reference_wrapper<_Functor> >
1689 :
public _Function_base::_Ref_manager<_Functor>
1691 typedef _Function_base::_Ref_manager<_Functor> _Base;
1695 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
1697 __callable_functor(**_Base::_M_get_pointer(__functor))(__args...);
1701 template<
typename _Class,
typename _Member,
typename _Res,
1702 typename... _ArgTypes>
1703 class _Function_handler<_Res(_ArgTypes...), _Member _Class::*>
1704 :
public _Function_handler<void(_ArgTypes...), _Member _Class::*>
1706 typedef _Function_handler<void(_ArgTypes...), _Member _Class::*>
1711 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
1714 mem_fn(_Base::_M_get_pointer(__functor)->__value)(__args...);
1718 template<
typename _Class,
typename _Member,
typename... _ArgTypes>
1719 class _Function_handler<void(_ArgTypes...), _Member _Class::*>
1720 :
public _Function_base::_Base_manager<
1721 _Simple_type_wrapper< _Member _Class::* > >
1723 typedef _Member _Class::* _Functor;
1724 typedef _Simple_type_wrapper<_Functor> _Wrapper;
1725 typedef _Function_base::_Base_manager<_Wrapper> _Base;
1729 _M_manager(_Any_data& __dest,
const _Any_data& __source,
1730 _Manager_operation __op)
1735 case __get_type_info:
1736 __dest._M_access<
const type_info*>() = &
typeid(_Functor);
1739 case __get_functor_ptr:
1740 __dest._M_access<_Functor*>() =
1741 &_Base::_M_get_pointer(__source)->__value;
1745 _Base::_M_manager(__dest, __source, __op);
1751 _M_invoke(
const _Any_data& __functor, _ArgTypes... __args)
1754 mem_fn(_Base::_M_get_pointer(__functor)->__value)(__args...);
1759 template<
typename _Res,
typename... _ArgTypes>
1760 class function<_Res(_ArgTypes...)>
1767 _Hidden_type* _M_bool;
1771 typedef _Hidden_type* _Hidden_type::* _Safe_bool;
1773 typedef _Res _Signature_type(_ArgTypes...);
1775 struct _Useless { };
1778 typedef _Res result_type;
1802 function(
const function& __x);
1820 template<
typename _Functor>
1821 function(_Functor __f,
1822 typename __gnu_cxx::__enable_if<
1841 function(__x).swap(*
this);
1857 _M_manager(_M_functor, _M_functor, __destroy_functor);
1880 template<
typename _Functor>
1881 typename __gnu_cxx::__enable_if<!is_integral<_Functor>::value,
1885 function(__f).swap(*
this);
1900 _Any_data __old_functor = _M_functor;
1901 _M_functor = __x._M_functor;
1902 __x._M_functor = __old_functor;
1903 _Manager_type __old_manager = _M_manager;
1904 _M_manager = __x._M_manager;
1905 __x._M_manager = __old_manager;
1906 _Invoker_type __old_invoker = _M_invoker;
1907 _M_invoker = __x._M_invoker;
1908 __x._M_invoker = __old_invoker;
1921 operator _Safe_bool()
const
1926 return &_Hidden_type::_M_bool;
1939 _Res operator()(_ArgTypes... __args)
const;
1963 template<
typename _Functor> _Functor* target();
1966 template<
typename _Functor>
const _Functor* target()
const;
1971 template<
typename _Function>
1972 void operator==(
const function<_Function>&)
const;
1973 template<
typename _Function>
1974 void operator!=(
const function<_Function>&)
const;
1976 typedef _Res (*_Invoker_type)(
const _Any_data&, _ArgTypes...);
1977 _Invoker_type _M_invoker;
1980 template<
typename _Res,
typename... _ArgTypes>
1981 function<_Res(_ArgTypes...)>::
1982 function(
const function& __x)
1987 _M_invoker = __x._M_invoker;
1988 _M_manager = __x._M_manager;
1989 __x._M_manager(_M_functor, __x._M_functor, __clone_functor);
1993 template<
typename _Res,
typename... _ArgTypes>
1994 template<
typename _Functor>
1995 function<_Res(_ArgTypes...)>::
1996 function(_Functor __f,
1997 typename __gnu_cxx::__enable_if<
2001 typedef _Function_handler<_Signature_type, _Functor> _My_handler;
2003 if (_My_handler::_M_not_empty_function(__f))
2005 _M_invoker = &_My_handler::_M_invoke;
2006 _M_manager = &_My_handler::_M_manager;
2007 _My_handler::_M_init_functor(_M_functor, __f);
2011 template<
typename _Res,
typename... _ArgTypes>
2013 function<_Res(_ArgTypes...)>::
2014 operator()(_ArgTypes... __args)
const
2024 return _M_invoker(_M_functor, __args...);
2028 template<
typename _Res,
typename... _ArgTypes>
2030 function<_Res(_ArgTypes...)>::
2035 _Any_data __typeinfo_result;
2036 _M_manager(__typeinfo_result, _M_functor, __get_type_info);
2037 return *__typeinfo_result._M_access<
const type_info*>();
2040 return typeid(void);
2043 template<
typename _Res,
typename... _ArgTypes>
2044 template<
typename _Functor>
2046 function<_Res(_ArgTypes...)>::
2049 if (
typeid(_Functor) == target_type() && _M_manager)
2052 if (_M_manager(__ptr, _M_functor, __get_functor_ptr)
2053 && !is_const<_Functor>::value)
2056 return __ptr._M_access<_Functor*>();
2062 template<
typename _Res,
typename... _ArgTypes>
2063 template<
typename _Functor>
2065 function<_Res(_ArgTypes...)>::
2068 if (
typeid(_Functor) == target_type() && _M_manager)
2071 _M_manager(__ptr, _M_functor, __get_functor_ptr);
2072 return __ptr._M_access<
const _Functor*>();
2088 template<
typename _Signature>
2094 template<
typename _Signature>
2106 template<
typename _Signature>
2112 template<
typename _Signature>
2124 template<
typename _Signature>
2126 swap(function<_Signature>& __x, function<_Signature>& __y)
2129 _GLIBCXX_END_NAMESPACE_TR1
bool operator!=(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return false if x is equal to y.
bool operator==(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return true if x is equal to y.
Determines if the given type _Tp is a placeholder in a bind() expression and, if so, which placeholder it is. [TR1 3.6.2].
function & operator=(const function &__x)
Function assignment operator.
Type of the function object returned from bind<R>().
__gnu_cxx::__enable_if<!is_integral< _Functor >::value, function & >::__type operator=(_Functor __f)
Function assignment to a new target.
Gives the type of the ith element of a given tuple type.
__gnu_cxx::__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)
Turns a function type into a function pointer type.
Builds an _Index_tuple<0, 1, 2, ..., _Num-1>.
_Bind< typename _Maybe_wrap_member_pointer< _Functor >::type(_ArgTypes...)> bind(_Functor __f, _ArgTypes...__args)
bind
Determines if the type _Tp derives from unary_function.
_Mem_fn< _Tp _Class::* > mem_fn(_Tp _Class::*__pm)
Returns a function object that forwards to the member pointer pm.
Exception class thrown when class template function's operator() is called with an empty target...
Type of the function object returned from bind().
The type of placeholder objects defined by libstdc++.
Determines if the type _Tp derives from binary_function.
Base class of all polymorphic function object wrappers.
function & operator=(_M_clear_type *)
Function assignment to zero.
Base class for all library exceptions.
void swap(function &__x)
Swap the targets of two function objects.
Determines if the given type _Tp is a function object should be treated as a subexpression when evalu...
If we have found a result_type, extract it.