123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783 |
- /*
- *
- * Copyright (c) 1994
- * Hewlett-Packard Company
- *
- * Copyright (c) 1996-1998
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1997
- * Moscow Center for SPARC Technology
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * Copyright (c) 2000
- * Pavel Kuznetsov
- *
- * Copyright (c) 2001
- * Meridian'93
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
- /* NOTE: This is an internal header file, included by other STL headers.
- * You should not attempt to use it directly.
- */
- // This file has noo macro protection as it is meant to be included several times
- // from other header.
- // Adaptor function objects: pointers to member functions.
- // There are a total of 16 = 2^4 function objects in this family.
- // (1) Member functions taking no arguments vs member functions taking
- // one argument.
- // (2) Call through pointer vs call through reference.
- // (3) Member function with void return type vs member function with
- // non-void return type.
- // (4) Const vs non-const member function.
- // Note that choice (3) is nothing more than a workaround: according
- // to the draft, compilers should handle void and non-void the same way.
- // This feature is not yet widely implemented, though. You can only use
- // member functions returning void if your compiler supports partial
- // specialization.
- // All of this complexity is in the function objects themselves. You can
- // ignore it by using the helper function mem_fun and mem_fun_ref,
- // which create whichever type of adaptor is appropriate.
- _STLP_BEGIN_NAMESPACE
- //This implementation will only be used if needed, that is to say when there is the return void bug
- //and when there is no partial template specialization
- #if defined (_STLP_DONT_RETURN_VOID) && defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && defined (_STLP_MEMBER_TEMPLATE_CLASSES)
- template<class _Result, class _Tp>
- class _Mem_fun0_ptr : public unary_function<_Tp*, _Result> {
- protected:
- typedef _Result (_Tp::*__fun_type) ();
- explicit _Mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator ()(_Tp* __p) const { return (__p->*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template<class _Result, class _Tp, class _Arg>
- class _Mem_fun1_ptr : public binary_function<_Tp*,_Arg,_Result> {
- protected:
- typedef _Result (_Tp::*__fun_type) (_Arg);
- explicit _Mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator ()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template<class _Result, class _Tp>
- class _Const_mem_fun0_ptr : public unary_function<const _Tp*,_Result> {
- protected:
- typedef _Result (_Tp::*__fun_type) () const;
- explicit _Const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator ()(const _Tp* __p) const { return (__p->*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template<class _Result, class _Tp, class _Arg>
- class _Const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,_Result> {
- protected:
- typedef _Result (_Tp::*__fun_type) (_Arg) const;
- explicit _Const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator ()(const _Tp* __p, _Arg __x) const {
- return (__p->*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template<class _Result, class _Tp>
- class _Mem_fun0_ref : public unary_function<_Tp,_Result> {
- protected:
- typedef _Result (_Tp::*__fun_type) ();
- explicit _Mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator ()(_Tp& __p) const { return (__p.*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template<class _Result, class _Tp, class _Arg>
- class _Mem_fun1_ref : public binary_function<_Tp,_Arg,_Result> {
- protected:
- typedef _Result (_Tp::*__fun_type) (_Arg);
- explicit _Mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator ()(_Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template<class _Result, class _Tp>
- class _Const_mem_fun0_ref : public unary_function<_Tp,_Result> {
- protected:
- typedef _Result (_Tp::*__fun_type) () const;
- explicit _Const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator ()(const _Tp& __p) const { return (__p.*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template<class _Result, class _Tp, class _Arg>
- class _Const_mem_fun1_ref : public binary_function<_Tp,_Arg,_Result> {
- protected:
- typedef _Result (_Tp::*__fun_type) (_Arg) const;
- explicit _Const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator ()(const _Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template<class _Result>
- struct _Mem_fun_traits {
- template<class _Tp>
- struct _Args0 {
- typedef _Mem_fun0_ptr<_Result,_Tp> _Ptr;
- typedef _Const_mem_fun0_ptr<_Result,_Tp> _Ptr_const;
- typedef _Mem_fun0_ref<_Result,_Tp> _Ref;
- typedef _Const_mem_fun0_ref<_Result,_Tp> _Ref_const;
- };
- template<class _Tp, class _Arg>
- struct _Args1 {
- typedef _Mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr;
- typedef _Const_mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr_const;
- typedef _Mem_fun1_ref<_Result,_Tp,_Arg> _Ref;
- typedef _Const_mem_fun1_ref<_Result,_Tp,_Arg> _Ref_const;
- };
- };
- template<class _Arg, class _Result>
- class _Ptr_fun1_base : public unary_function<_Arg, _Result> {
- protected:
- typedef _Result (*__fun_type) (_Arg);
- explicit _Ptr_fun1_base(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator()(_Arg __x) const { return _M_f(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Arg1, class _Arg2, class _Result>
- class _Ptr_fun2_base : public binary_function<_Arg1,_Arg2,_Result> {
- protected:
- typedef _Result (*__fun_type) (_Arg1, _Arg2);
- explicit _Ptr_fun2_base(__fun_type __f) : _M_f(__f) {}
- public:
- _Result operator()(_Arg1 __x, _Arg2 __y) const { return _M_f(__x, __y); }
- private:
- __fun_type _M_f;
- };
- template<class _Result>
- struct _Ptr_fun_traits {
- template<class _Arg> struct _Args1 {
- typedef _Ptr_fun1_base<_Arg,_Result> _Fun;
- };
- template<class _Arg1, class _Arg2> struct _Args2 {
- typedef _Ptr_fun2_base<_Arg1,_Arg2,_Result> _Fun;
- };
- };
- /* Specializations for void return type */
- template<class _Tp>
- class _Void_mem_fun0_ptr : public unary_function<_Tp*,void> {
- protected:
- typedef void (_Tp::*__fun_type) ();
- explicit _Void_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
- public:
- void operator ()(_Tp* __p) const { (__p->*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template<class _Tp, class _Arg>
- class _Void_mem_fun1_ptr : public binary_function<_Tp*,_Arg,void> {
- protected:
- typedef void (_Tp::*__fun_type) (_Arg);
- explicit _Void_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
- public:
- void operator ()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template<class _Tp>
- class _Void_const_mem_fun0_ptr : public unary_function<const _Tp*,void> {
- protected:
- typedef void (_Tp::*__fun_type) () const;
- explicit _Void_const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
- public:
- void operator ()(const _Tp* __p) const { (__p->*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template<class _Tp, class _Arg>
- class _Void_const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,void> {
- protected:
- typedef void (_Tp::*__fun_type) (_Arg) const;
- explicit _Void_const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
- public:
- void operator ()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template<class _Tp>
- class _Void_mem_fun0_ref : public unary_function<_Tp,void> {
- protected:
- typedef void (_Tp::*__fun_type) ();
- explicit _Void_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
- public:
- void operator ()(_Tp& __p) const { (__p.*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template<class _Tp, class _Arg>
- class _Void_mem_fun1_ref : public binary_function<_Tp,_Arg,void> {
- protected:
- typedef void (_Tp::*__fun_type) (_Arg);
- explicit _Void_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
- public:
- void operator ()(_Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template<class _Tp>
- class _Void_const_mem_fun0_ref : public unary_function<_Tp,void> {
- protected:
- typedef void (_Tp::*__fun_type) () const;
- explicit _Void_const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
- public:
- void operator ()(const _Tp& __p) const { (__p.*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template<class _Tp, class _Arg>
- class _Void_const_mem_fun1_ref : public binary_function<_Tp,_Arg,void> {
- protected:
- typedef void (_Tp::*__fun_type) (_Arg) const;
- explicit _Void_const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
- public:
- void operator ()(const _Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- _STLP_TEMPLATE_NULL
- struct _Mem_fun_traits<void> {
- template<class _Tp> struct _Args0 {
- typedef _Void_mem_fun0_ptr<_Tp> _Ptr;
- typedef _Void_const_mem_fun0_ptr<_Tp> _Ptr_const;
- typedef _Void_mem_fun0_ref<_Tp> _Ref;
- typedef _Void_const_mem_fun0_ref<_Tp> _Ref_const;
- };
- template<class _Tp, class _Arg> struct _Args1 {
- typedef _Void_mem_fun1_ptr<_Tp,_Arg> _Ptr;
- typedef _Void_const_mem_fun1_ptr<_Tp,_Arg> _Ptr_const;
- typedef _Void_mem_fun1_ref<_Tp,_Arg> _Ref;
- typedef _Void_const_mem_fun1_ref<_Tp,_Arg> _Ref_const;
- };
- };
- template<class _Arg>
- class _Ptr_void_fun1_base : public unary_function<_Arg, void> {
- protected:
- typedef void (*__fun_type) (_Arg);
- explicit _Ptr_void_fun1_base(__fun_type __f) : _M_f(__f) {}
- public:
- void operator()(_Arg __x) const { _M_f(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Arg1, class _Arg2>
- class _Ptr_void_fun2_base : public binary_function<_Arg1,_Arg2,void> {
- protected:
- typedef void (*__fun_type) (_Arg1, _Arg2);
- explicit _Ptr_void_fun2_base(__fun_type __f) : _M_f(__f) {}
- public:
- void operator()(_Arg1 __x, _Arg2 __y) const { _M_f(__x, __y); }
- private:
- __fun_type _M_f;
- };
- _STLP_TEMPLATE_NULL
- struct _Ptr_fun_traits<void> {
- template<class _Arg> struct _Args1 {
- typedef _Ptr_void_fun1_base<_Arg> _Fun;
- };
- template<class _Arg1, class _Arg2> struct _Args2 {
- typedef _Ptr_void_fun2_base<_Arg1,_Arg2> _Fun;
- };
- };
- // pavel: need extra level of inheritance here since MSVC++ does not
- // accept traits-based fake partial specialization for template
- // arguments other than first
- template<class _Result, class _Arg>
- class _Ptr_fun1 :
- public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun {
- protected:
- typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun _Base;
- explicit _Ptr_fun1(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template<class _Result, class _Arg1, class _Arg2>
- class _Ptr_fun2 :
- public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun {
- protected:
- typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun _Base;
- explicit _Ptr_fun2(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Result, class _Tp>
- class mem_fun_t :
- public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr {
- typedef typename
- _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr _Base;
- public:
- explicit mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Result, class _Tp>
- class const_mem_fun_t :
- public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const {
- typedef typename
- _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const _Base;
- public:
- explicit const_mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Result, class _Tp>
- class mem_fun_ref_t :
- public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref {
- typedef typename
- _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref _Base;
- public:
- explicit mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Result, class _Tp>
- class const_mem_fun_ref_t :
- public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const {
- typedef typename
- _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const _Base;
- public:
- explicit const_mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Result, class _Tp, class _Arg>
- class mem_fun1_t :
- public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr {
- typedef typename
- _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr _Base;
- public:
- explicit mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Result, class _Tp, class _Arg>
- class const_mem_fun1_t :
- public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const {
- typedef typename
- _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const _Base;
- public:
- explicit const_mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Result, class _Tp, class _Arg>
- class mem_fun1_ref_t :
- public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref {
- typedef typename
- _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref _Base;
- public:
- explicit mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Result, class _Tp, class _Arg>
- class const_mem_fun1_ref_t :
- public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const {
- typedef typename
- _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const _Base;
- public:
- explicit const_mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
- };
- template <class _Arg, class _Result>
- class pointer_to_unary_function :
- public _Ptr_fun1<_Result,_Arg> {
- typedef typename
- _Ptr_fun1<_Result,_Arg>::__fun_type __fun_type;
- public:
- explicit pointer_to_unary_function(__fun_type __f)
- : _Ptr_fun1<_Result,_Arg>(__f) {}
- };
- template <class _Arg1, class _Arg2, class _Result>
- class pointer_to_binary_function :
- public _Ptr_fun2<_Result,_Arg1,_Arg2> {
- typedef typename
- _Ptr_fun2<_Result,_Arg1,_Arg2>::__fun_type __fun_type;
- public:
- explicit pointer_to_binary_function(__fun_type __f)
- : _Ptr_fun2<_Result,_Arg1,_Arg2>(__f) {}
- };
- #else
- template <class _Ret, class _Tp>
- class mem_fun_t : public unary_function<_Tp*,_Ret> {
- typedef _Ret (_Tp::*__fun_type)(void);
- public:
- explicit mem_fun_t(__fun_type __pf) : _M_f(__pf) {}
- _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template <class _Ret, class _Tp>
- class const_mem_fun_t : public unary_function<const _Tp*,_Ret> {
- typedef _Ret (_Tp::*__fun_type)(void) const;
- public:
- explicit const_mem_fun_t(__fun_type __pf) : _M_f(__pf) {}
- _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template <class _Ret, class _Tp>
- class mem_fun_ref_t : public unary_function<_Tp,_Ret> {
- typedef _Ret (_Tp::*__fun_type)(void);
- public:
- explicit mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {}
- _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template <class _Ret, class _Tp>
- class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> {
- typedef _Ret (_Tp::*__fun_type)(void) const;
- public:
- explicit const_mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {}
- _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template <class _Ret, class _Tp, class _Arg>
- class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> {
- typedef _Ret (_Tp::*__fun_type)(_Arg);
- public:
- explicit mem_fun1_t(__fun_type __pf) : _M_f(__pf) {}
- _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Ret, class _Tp, class _Arg>
- class const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> {
- typedef _Ret (_Tp::*__fun_type)(_Arg) const;
- public:
- explicit const_mem_fun1_t(__fun_type __pf) : _M_f(__pf) {}
- _Ret operator()(const _Tp* __p, _Arg __x) const
- { return (__p->*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Ret, class _Tp, class _Arg>
- class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
- typedef _Ret (_Tp::*__fun_type)(_Arg);
- public:
- explicit mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {}
- _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Ret, class _Tp, class _Arg>
- class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
- typedef _Ret (_Tp::*__fun_type)(_Arg) const;
- public:
- explicit const_mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {}
- _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Arg, class _Result>
- class pointer_to_unary_function : public unary_function<_Arg, _Result> {
- protected:
- _Result (*_M_ptr)(_Arg);
- public:
- pointer_to_unary_function() {}
- explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {}
- _Result operator()(_Arg __x) const { return _M_ptr(__x); }
- };
- template <class _Arg1, class _Arg2, class _Result>
- class pointer_to_binary_function :
- public binary_function<_Arg1,_Arg2,_Result> {
- protected:
- _Result (*_M_ptr)(_Arg1, _Arg2);
- public:
- pointer_to_binary_function() {}
- explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
- : _M_ptr(__x) {}
- _Result operator()(_Arg1 __x, _Arg2 __y) const {
- return _M_ptr(__x, __y);
- }
- };
- # if defined (_STLP_DONT_RETURN_VOID) && !defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION)
- //Partial specializations for the void type
- template <class _Tp>
- class mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> {
- typedef void (_Tp::*__fun_type)(void);
- public:
- explicit mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
- void operator()(_Tp* __p) const { (__p->*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template <class _Tp>
- class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> {
- typedef void (_Tp::*__fun_type)(void) const;
- public:
- explicit const_mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
- void operator()(const _Tp* __p) const { (__p->*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template <class _Tp>
- class mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
- typedef void (_Tp::*__fun_type)(void);
- public:
- explicit mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
- void operator()(_Tp& __r) const { (__r.*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template <class _Tp>
- class const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
- typedef void (_Tp::*__fun_type)(void) const;
- public:
- explicit const_mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
- void operator()(const _Tp& __r) const { (__r.*_M_f)(); }
- private:
- __fun_type _M_f;
- };
- template <class _Tp, class _Arg>
- class mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> {
- typedef void (_Tp::*__fun_type)(_Arg);
- public:
- explicit mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
- void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Tp, class _Arg>
- class const_mem_fun1_t<void, _Tp, _Arg>
- : public binary_function<const _Tp*,_Arg,void> {
- typedef void (_Tp::*__fun_type)(_Arg) const;
- public:
- explicit const_mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
- void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Tp, class _Arg>
- class mem_fun1_ref_t<void, _Tp, _Arg>
- : public binary_function<_Tp,_Arg,void> {
- typedef void (_Tp::*__fun_type)(_Arg);
- public:
- explicit mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
- void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Tp, class _Arg>
- class const_mem_fun1_ref_t<void, _Tp, _Arg>
- : public binary_function<_Tp,_Arg,void> {
- typedef void (_Tp::*__fun_type)(_Arg) const;
- public:
- explicit const_mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
- void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
- private:
- __fun_type _M_f;
- };
- template <class _Arg>
- class pointer_to_unary_function<_Arg, void> : public unary_function<_Arg, void> {
- typedef void (*__fun_type)(_Arg);
- __fun_type _M_ptr;
- public:
- pointer_to_unary_function() {}
- explicit pointer_to_unary_function(__fun_type __x) : _M_ptr(__x) {}
- void operator()(_Arg __x) const { _M_ptr(__x); }
- };
- template <class _Arg1, class _Arg2>
- class pointer_to_binary_function<_Arg1, _Arg2, void> : public binary_function<_Arg1,_Arg2,void> {
- typedef void (*__fun_type)(_Arg1, _Arg2);
- __fun_type _M_ptr;
- public:
- pointer_to_binary_function() {}
- explicit pointer_to_binary_function(__fun_type __x) : _M_ptr(__x) {}
- void operator()(_Arg1 __x, _Arg2 __y) const { _M_ptr(__x, __y); }
- };
- # endif
- #endif
- #if !defined (_STLP_MEMBER_POINTER_PARAM_BUG)
- // Mem_fun adaptor helper functions. There are only two:
- // mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref
- // are provided for backward compatibility, but they are no longer
- // part of the C++ standard.)
- template <class _Result, class _Tp>
- inline mem_fun_t<_Result,_Tp>
- mem_fun(_Result (_Tp::*__f)()) { return mem_fun_t<_Result,_Tp>(__f); }
- template <class _Result, class _Tp>
- inline const_mem_fun_t<_Result,_Tp>
- mem_fun(_Result (_Tp::*__f)() const) { return const_mem_fun_t<_Result,_Tp>(__f); }
- template <class _Result, class _Tp>
- inline mem_fun_ref_t<_Result,_Tp>
- mem_fun_ref(_Result (_Tp::*__f)()) { return mem_fun_ref_t<_Result,_Tp>(__f); }
- template <class _Result, class _Tp>
- inline const_mem_fun_ref_t<_Result,_Tp>
- mem_fun_ref(_Result (_Tp::*__f)() const) { return const_mem_fun_ref_t<_Result,_Tp>(__f); }
- template <class _Result, class _Tp, class _Arg>
- inline mem_fun1_t<_Result,_Tp,_Arg>
- mem_fun(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); }
- template <class _Result, class _Tp, class _Arg>
- inline const_mem_fun1_t<_Result,_Tp,_Arg>
- mem_fun(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); }
- template <class _Result, class _Tp, class _Arg>
- inline mem_fun1_ref_t<_Result,_Tp,_Arg>
- mem_fun_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
- template <class _Result, class _Tp, class _Arg>
- inline const_mem_fun1_ref_t<_Result,_Tp,_Arg>
- mem_fun_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
- # if !(defined (_STLP_NO_EXTENSIONS) || defined (_STLP_NO_ANACHRONISMS))
- // mem_fun1 and mem_fun1_ref are no longer part of the C++ standard,
- // but they are provided for backward compatibility.
- template <class _Result, class _Tp, class _Arg>
- inline mem_fun1_t<_Result,_Tp,_Arg>
- mem_fun1(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); }
- template <class _Result, class _Tp, class _Arg>
- inline const_mem_fun1_t<_Result,_Tp,_Arg>
- mem_fun1(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); }
- template <class _Result, class _Tp, class _Arg>
- inline mem_fun1_ref_t<_Result,_Tp,_Arg>
- mem_fun1_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
- template <class _Result, class _Tp, class _Arg>
- inline const_mem_fun1_ref_t<_Result,_Tp,_Arg>
- mem_fun1_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
- # endif
- #endif
- template <class _Arg, class _Result>
- inline pointer_to_unary_function<_Arg, _Result>
- ptr_fun(_Result (*__f)(_Arg))
- { return pointer_to_unary_function<_Arg, _Result>(__f); }
- template <class _Arg1, class _Arg2, class _Result>
- inline pointer_to_binary_function<_Arg1,_Arg2,_Result>
- ptr_fun(_Result (*__f)(_Arg1, _Arg2))
- { return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f); }
- _STLP_END_NAMESPACE
|