/home/ntakagi/work/STLport-5.1.5/stlport/stl/_function_adaptors.hGo to the documentation of this file.00001 /* 00002 * 00003 * Copyright (c) 1994 00004 * Hewlett-Packard Company 00005 * 00006 * Copyright (c) 1996-1998 00007 * Silicon Graphics Computer Systems, Inc. 00008 * 00009 * Copyright (c) 1997 00010 * Moscow Center for SPARC Technology 00011 * 00012 * Copyright (c) 1999 00013 * Boris Fomitchev 00014 * 00015 * Copyright (c) 2000 00016 * Pavel Kuznetsov 00017 * 00018 * Copyright (c) 2001 00019 * Meridian'93 00020 * 00021 * This material is provided "as is", with absolutely no warranty expressed 00022 * or implied. Any use is at your own risk. 00023 * 00024 * Permission to use or copy this software for any purpose is hereby granted 00025 * without fee, provided the above notices are retained on all copies. 00026 * Permission to modify the code and to distribute modified code is granted, 00027 * provided the above notices are retained, and a notice that the code was 00028 * modified is included with the above copyright notice. 00029 * 00030 */ 00031 00032 /* NOTE: This is an internal header file, included by other STL headers. 00033 * You should not attempt to use it directly. 00034 */ 00035 00036 // This file has noo macro protection as it is meant to be included several times 00037 // from other header. 00038 // Adaptor function objects: pointers to member functions. 00039 00040 // There are a total of 16 = 2^4 function objects in this family. 00041 // (1) Member functions taking no arguments vs member functions taking 00042 // one argument. 00043 // (2) Call through pointer vs call through reference. 00044 // (3) Member function with void return type vs member function with 00045 // non-void return type. 00046 // (4) Const vs non-const member function. 00047 00048 // Note that choice (3) is nothing more than a workaround: according 00049 // to the draft, compilers should handle void and non-void the same way. 00050 // This feature is not yet widely implemented, though. You can only use 00051 // member functions returning void if your compiler supports partial 00052 // specialization. 00053 00054 // All of this complexity is in the function objects themselves. You can 00055 // ignore it by using the helper function mem_fun and mem_fun_ref, 00056 // which create whichever type of adaptor is appropriate. 00057 00058 _STLP_BEGIN_NAMESPACE 00059 00060 //This implementation will only be used if needed, that is to say when there is the return void bug 00061 //and when there is no partial template specialization 00062 #if defined(_STLP_DONT_RETURN_VOID) && defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && defined(_STLP_MEMBER_TEMPLATE_CLASSES) 00063 00064 template<class _Result, class _Tp> 00065 class _Mem_fun0_ptr : public unary_function<_Tp*, _Result> { 00066 protected: 00067 typedef _Result (_Tp::*__fun_type) (); 00068 explicit _Mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} 00069 00070 public: 00071 _Result operator ()(_Tp* __p) const { return (__p->*_M_f)(); } 00072 00073 private: 00074 __fun_type _M_f; 00075 }; 00076 00077 template<class _Result, class _Tp, class _Arg> 00078 class _Mem_fun1_ptr : public binary_function<_Tp*,_Arg,_Result> { 00079 protected: 00080 typedef _Result (_Tp::*__fun_type) (_Arg); 00081 explicit _Mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} 00082 00083 public: 00084 _Result operator ()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } 00085 00086 private: 00087 __fun_type _M_f; 00088 }; 00089 00090 template<class _Result, class _Tp> 00091 class _Const_mem_fun0_ptr : public unary_function<const _Tp*,_Result> { 00092 protected: 00093 typedef _Result (_Tp::*__fun_type) () const; 00094 explicit _Const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} 00095 00096 public: 00097 _Result operator ()(const _Tp* __p) const { return (__p->*_M_f)(); } 00098 00099 private: 00100 __fun_type _M_f; 00101 }; 00102 00103 template<class _Result, class _Tp, class _Arg> 00104 class _Const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,_Result> { 00105 protected: 00106 typedef _Result (_Tp::*__fun_type) (_Arg) const; 00107 explicit _Const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} 00108 00109 public: 00110 _Result operator ()(const _Tp* __p, _Arg __x) const { 00111 return (__p->*_M_f)(__x); } 00112 00113 private: 00114 __fun_type _M_f; 00115 }; 00116 00117 template<class _Result, class _Tp> 00118 class _Mem_fun0_ref : public unary_function<_Tp&,_Result> { 00119 protected: 00120 typedef _Result (_Tp::*__fun_type) (); 00121 explicit _Mem_fun0_ref(__fun_type __f) : _M_f(__f) {} 00122 00123 public: 00124 _Result operator ()(_Tp& __p) const { return (__p.*_M_f)(); } 00125 00126 private: 00127 __fun_type _M_f; 00128 }; 00129 00130 template<class _Result, class _Tp, class _Arg> 00131 class _Mem_fun1_ref : public binary_function<_Tp&,_Arg,_Result> { 00132 protected: 00133 typedef _Result (_Tp::*__fun_type) (_Arg); 00134 explicit _Mem_fun1_ref(__fun_type __f) : _M_f(__f) {} 00135 00136 public: 00137 _Result operator ()(_Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); } 00138 00139 private: 00140 __fun_type _M_f; 00141 }; 00142 00143 template<class _Result, class _Tp> 00144 class _Const_mem_fun0_ref : public unary_function<const _Tp&,_Result> { 00145 protected: 00146 typedef _Result (_Tp::*__fun_type) () const; 00147 explicit _Const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {} 00148 00149 public: 00150 _Result operator ()(const _Tp& __p) const { return (__p.*_M_f)(); } 00151 00152 private: 00153 __fun_type _M_f; 00154 }; 00155 00156 template<class _Result, class _Tp, class _Arg> 00157 class _Const_mem_fun1_ref : public binary_function<const _Tp&,_Arg,_Result> { 00158 protected: 00159 typedef _Result (_Tp::*__fun_type) (_Arg) const; 00160 explicit _Const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {} 00161 00162 public: 00163 _Result operator ()(const _Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); } 00164 00165 private: 00166 __fun_type _M_f; 00167 }; 00168 00169 template<class _Result> 00170 struct _Mem_fun_traits { 00171 template<class _Tp> 00172 struct _Args0 { 00173 typedef _Mem_fun0_ptr<_Result,_Tp> _Ptr; 00174 typedef _Const_mem_fun0_ptr<_Result,_Tp> _Ptr_const; 00175 typedef _Mem_fun0_ref<_Result,_Tp> _Ref; 00176 typedef _Const_mem_fun0_ref<_Result,_Tp> _Ref_const; 00177 }; 00178 00179 template<class _Tp, class _Arg> 00180 struct _Args1 { 00181 typedef _Mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr; 00182 typedef _Const_mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr_const; 00183 typedef _Mem_fun1_ref<_Result,_Tp,_Arg> _Ref; 00184 typedef _Const_mem_fun1_ref<_Result,_Tp,_Arg> _Ref_const; 00185 }; 00186 }; 00187 00188 template<class _Arg, class _Result> 00189 class _Ptr_fun1_base : public unary_function<_Arg, _Result> { 00190 protected: 00191 typedef _Result (*__fun_type) (_Arg); 00192 explicit _Ptr_fun1_base(__fun_type __f) : _M_f(__f) {} 00193 00194 public: 00195 _Result operator()(_Arg __x) const { return _M_f(__x); } 00196 00197 private: 00198 __fun_type _M_f; 00199 }; 00200 00201 template <class _Arg1, class _Arg2, class _Result> 00202 class _Ptr_fun2_base : public binary_function<_Arg1,_Arg2,_Result> { 00203 protected: 00204 typedef _Result (*__fun_type) (_Arg1, _Arg2); 00205 explicit _Ptr_fun2_base(__fun_type __f) : _M_f(__f) {} 00206 00207 public: 00208 _Result operator()(_Arg1 __x, _Arg2 __y) const { return _M_f(__x, __y); } 00209 00210 private: 00211 __fun_type _M_f; 00212 }; 00213 00214 template<class _Result> 00215 struct _Ptr_fun_traits { 00216 template<class _Arg> struct _Args1 { 00217 typedef _Ptr_fun1_base<_Arg,_Result> _Fun; 00218 }; 00219 00220 template<class _Arg1, class _Arg2> struct _Args2 { 00221 typedef _Ptr_fun2_base<_Arg1,_Arg2,_Result> _Fun; 00222 }; 00223 }; 00224 00225 /*Specialization for void return type 00226 */ 00227 template<class _Tp> 00228 class _Void_mem_fun0_ptr : public unary_function<_Tp*,void> { 00229 protected: 00230 typedef void (_Tp::*__fun_type) (); 00231 explicit _Void_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} 00232 00233 public: 00234 void operator ()(_Tp* __p) const { (__p->*_M_f)(); } 00235 00236 private: 00237 __fun_type _M_f; 00238 }; 00239 00240 template<class _Tp, class _Arg> 00241 class _Void_mem_fun1_ptr : public binary_function<_Tp*,_Arg,void> { 00242 protected: 00243 typedef void (_Tp::*__fun_type) (_Arg); 00244 explicit _Void_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} 00245 00246 public: 00247 void operator ()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } 00248 00249 private: 00250 __fun_type _M_f; 00251 }; 00252 00253 template<class _Tp> 00254 class _Void_const_mem_fun0_ptr : public unary_function<const _Tp*,void> { 00255 protected: 00256 typedef void (_Tp::*__fun_type) () const; 00257 explicit _Void_const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} 00258 00259 public: 00260 void operator ()(const _Tp* __p) const { (__p->*_M_f)(); } 00261 00262 private: 00263 __fun_type _M_f; 00264 }; 00265 00266 template<class _Tp, class _Arg> 00267 class _Void_const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,void> { 00268 protected: 00269 typedef void (_Tp::*__fun_type) (_Arg) const; 00270 explicit _Void_const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} 00271 00272 public: 00273 void operator ()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } 00274 00275 private: 00276 __fun_type _M_f; 00277 }; 00278 00279 template<class _Tp> 00280 class _Void_mem_fun0_ref : public unary_function<_Tp&,void> { 00281 protected: 00282 typedef void (_Tp::*__fun_type) (); 00283 explicit _Void_mem_fun0_ref(__fun_type __f) : _M_f(__f) {} 00284 00285 public: 00286 void operator ()(_Tp& __p) const { (__p.*_M_f)(); } 00287 00288 private: 00289 __fun_type _M_f; 00290 }; 00291 00292 template<class _Tp, class _Arg> 00293 class _Void_mem_fun1_ref : public binary_function<_Tp&,_Arg,void> { 00294 protected: 00295 typedef void (_Tp::*__fun_type) (_Arg); 00296 explicit _Void_mem_fun1_ref(__fun_type __f) : _M_f(__f) {} 00297 00298 public: 00299 void operator ()(_Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); } 00300 00301 private: 00302 __fun_type _M_f; 00303 }; 00304 00305 template<class _Tp> 00306 class _Void_const_mem_fun0_ref : public unary_function<const _Tp&,void> { 00307 protected: 00308 typedef void (_Tp::*__fun_type) () const; 00309 explicit _Void_const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {} 00310 00311 public: 00312 void operator ()(const _Tp& __p) const { (__p.*_M_f)(); } 00313 00314 private: 00315 __fun_type _M_f; 00316 }; 00317 00318 template<class _Tp, class _Arg> 00319 class _Void_const_mem_fun1_ref : public binary_function<const _Tp&,_Arg,void> { 00320 protected: 00321 typedef void (_Tp::*__fun_type) (_Arg) const; 00322 explicit _Void_const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {} 00323 00324 public: 00325 void operator ()(const _Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); } 00326 00327 private: 00328 __fun_type _M_f; 00329 }; 00330 00331 _STLP_TEMPLATE_NULL 00332 struct _Mem_fun_traits<void> { 00333 template<class _Tp> struct _Args0 { 00334 typedef _Void_mem_fun0_ptr<_Tp> _Ptr; 00335 typedef _Void_const_mem_fun0_ptr<_Tp> _Ptr_const; 00336 typedef _Void_mem_fun0_ref<_Tp> _Ref; 00337 typedef _Void_const_mem_fun0_ref<_Tp> _Ref_const; 00338 }; 00339 00340 template<class _Tp, class _Arg> struct _Args1 { 00341 typedef _Void_mem_fun1_ptr<_Tp,_Arg> _Ptr; 00342 typedef _Void_const_mem_fun1_ptr<_Tp,_Arg> _Ptr_const; 00343 typedef _Void_mem_fun1_ref<_Tp,_Arg> _Ref; 00344 typedef _Void_const_mem_fun1_ref<_Tp,_Arg> _Ref_const; 00345 }; 00346 }; 00347 00348 template<class _Arg> 00349 class _Ptr_void_fun1_base : public unary_function<_Arg, void> { 00350 protected: 00351 typedef void (*__fun_type) (_Arg); 00352 explicit _Ptr_void_fun1_base(__fun_type __f) : _M_f(__f) {} 00353 00354 public: 00355 void operator()(_Arg __x) const { _M_f(__x); } 00356 00357 private: 00358 __fun_type _M_f; 00359 }; 00360 00361 template <class _Arg1, class _Arg2> 00362 class _Ptr_void_fun2_base : public binary_function<_Arg1,_Arg2,void> { 00363 protected: 00364 typedef void (*__fun_type) (_Arg1, _Arg2); 00365 explicit _Ptr_void_fun2_base(__fun_type __f) : _M_f(__f) {} 00366 00367 public: 00368 void operator()(_Arg1 __x, _Arg2 __y) const { _M_f(__x, __y); } 00369 00370 private: 00371 __fun_type _M_f; 00372 }; 00373 00374 _STLP_TEMPLATE_NULL 00375 struct _Ptr_fun_traits<void> { 00376 template<class _Arg> struct _Args1 { 00377 typedef _Ptr_void_fun1_base<_Arg> _Fun; 00378 }; 00379 00380 template<class _Arg1, class _Arg2> struct _Args2 { 00381 typedef _Ptr_void_fun2_base<_Arg1,_Arg2> _Fun; 00382 }; 00383 }; 00384 00385 // pavel: need extra level of inheritance here since MSVC++ does not 00386 // accept traits-based fake partial specialization for template 00387 // arguments other than first 00388 00389 template<class _Result, class _Arg> 00390 class _Ptr_fun1 : 00391 public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun { 00392 protected: 00393 typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun _Base; 00394 explicit _Ptr_fun1(typename _Base::__fun_type __f) : _Base(__f) {} 00395 }; 00396 00397 template<class _Result, class _Arg1, class _Arg2> 00398 class _Ptr_fun2 : 00399 public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun { 00400 protected: 00401 typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun _Base; 00402 explicit _Ptr_fun2(typename _Base::__fun_type __f) : _Base(__f) {} 00403 }; 00404 00405 00406 #endif /*_STLP_DONT_RETURN_VOID && _STLP_NO_CLASS_PARTIAL_SPECIALIZATION && _STLP_MEMBER_TEMPLATE_CLASSES*/ 00407 00408 00409 #if !defined(_STLP_DONT_RETURN_VOID) || !defined(_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) || !defined (_STLP_MEMBER_TEMPLATE_CLASSES) 00410 00411 template <class _Ret, class _Tp> 00412 class mem_fun_t : public unary_function<_Tp*,_Ret> { 00413 typedef _Ret (_Tp::*__fun_type)(void); 00414 public: 00415 explicit mem_fun_t(__fun_type __pf) : _M_f(__pf) {} 00416 _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); } 00417 private: 00418 __fun_type _M_f; 00419 }; 00420 00421 template <class _Ret, class _Tp> 00422 class const_mem_fun_t : public unary_function<const _Tp*,_Ret> { 00423 typedef _Ret (_Tp::*__fun_type)(void) const; 00424 public: 00425 explicit const_mem_fun_t(__fun_type __pf) : _M_f(__pf) {} 00426 _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); } 00427 private: 00428 __fun_type _M_f; 00429 }; 00430 00431 00432 template <class _Ret, class _Tp> 00433 class mem_fun_ref_t : public unary_function<_Tp,_Ret> { 00434 typedef _Ret (_Tp::*__fun_type)(void); 00435 public: 00436 explicit mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {} 00437 _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); } 00438 private: 00439 __fun_type _M_f; 00440 }; 00441 00442 template <class _Ret, class _Tp> 00443 class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> { 00444 typedef _Ret (_Tp::*__fun_type)(void) const; 00445 public: 00446 explicit const_mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {} 00447 _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); } 00448 private: 00449 __fun_type _M_f; 00450 }; 00451 00452 template <class _Ret, class _Tp, class _Arg> 00453 class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> { 00454 typedef _Ret (_Tp::*__fun_type)(_Arg); 00455 public: 00456 explicit mem_fun1_t(__fun_type __pf) : _M_f(__pf) {} 00457 _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } 00458 private: 00459 __fun_type _M_f; 00460 }; 00461 00462 template <class _Ret, class _Tp, class _Arg> 00463 class const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> { 00464 typedef _Ret (_Tp::*__fun_type)(_Arg) const; 00465 public: 00466 explicit const_mem_fun1_t(__fun_type __pf) : _M_f(__pf) {} 00467 _Ret operator()(const _Tp* __p, _Arg __x) const 00468 { return (__p->*_M_f)(__x); } 00469 private: 00470 __fun_type _M_f; 00471 }; 00472 00473 template <class _Ret, class _Tp, class _Arg> 00474 class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { 00475 typedef _Ret (_Tp::*__fun_type)(_Arg); 00476 public: 00477 explicit mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {} 00478 _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } 00479 private: 00480 __fun_type _M_f; 00481 }; 00482 00483 template <class _Ret, class _Tp, class _Arg> 00484 class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { 00485 typedef _Ret (_Tp::*__fun_type)(_Arg) const; 00486 public: 00487 explicit const_mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {} 00488 _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } 00489 private: 00490 __fun_type _M_f; 00491 }; 00492 00493 template <class _Arg, class _Result> 00494 class pointer_to_unary_function : public unary_function<_Arg, _Result> { 00495 protected: 00496 _Result (*_M_ptr)(_Arg); 00497 public: 00498 pointer_to_unary_function() {} 00499 explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {} 00500 _Result operator()(_Arg __x) const { return _M_ptr(__x); } 00501 }; 00502 00503 template <class _Arg1, class _Arg2, class _Result> 00504 class pointer_to_binary_function : 00505 public binary_function<_Arg1,_Arg2,_Result> { 00506 protected: 00507 _Result (*_M_ptr)(_Arg1, _Arg2); 00508 public: 00509 pointer_to_binary_function() {} 00510 explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) 00511 : _M_ptr(__x) {} 00512 _Result operator()(_Arg1 __x, _Arg2 __y) const { 00513 return _M_ptr(__x, __y); 00514 } 00515 }; 00516 00517 00518 #if defined(_STLP_DONT_RETURN_VOID) && !defined(_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) 00519 //Partial specialization for the void type 00520 template <class _Tp> 00521 class mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> { 00522 typedef void (_Tp::*__fun_type)(void); 00523 public: 00524 explicit mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} 00525 void operator()(_Tp* __p) const { (__p->*_M_f)(); } 00526 private: 00527 __fun_type _M_f; 00528 }; 00529 00530 template <class _Tp> 00531 class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> { 00532 typedef void (_Tp::*__fun_type)(void) const; 00533 public: 00534 explicit const_mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} 00535 void operator()(const _Tp* __p) const { (__p->*_M_f)(); } 00536 private: 00537 __fun_type _M_f; 00538 }; 00539 00540 template <class _Tp> 00541 class mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> { 00542 typedef void (_Tp::*__fun_type)(void); 00543 public: 00544 explicit mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} 00545 void operator()(_Tp& __r) const { (__r.*_M_f)(); } 00546 private: 00547 __fun_type _M_f; 00548 }; 00549 00550 template <class _Tp> 00551 class const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> { 00552 typedef void (_Tp::*__fun_type)(void) const; 00553 public: 00554 explicit const_mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} 00555 void operator()(const _Tp& __r) const { (__r.*_M_f)(); } 00556 private: 00557 __fun_type _M_f; 00558 }; 00559 00560 template <class _Tp, class _Arg> 00561 class mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> { 00562 typedef void (_Tp::*__fun_type)(_Arg); 00563 public: 00564 explicit mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} 00565 void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } 00566 private: 00567 __fun_type _M_f; 00568 }; 00569 00570 template <class _Tp, class _Arg> 00571 class const_mem_fun1_t<void, _Tp, _Arg> 00572 : public binary_function<const _Tp*,_Arg,void> { 00573 typedef void (_Tp::*__fun_type)(_Arg) const; 00574 public: 00575 explicit const_mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} 00576 void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } 00577 private: 00578 __fun_type _M_f; 00579 }; 00580 00581 template <class _Tp, class _Arg> 00582 class mem_fun1_ref_t<void, _Tp, _Arg> 00583 : public binary_function<_Tp,_Arg,void> { 00584 typedef void (_Tp::*__fun_type)(_Arg); 00585 public: 00586 explicit mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} 00587 void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } 00588 private: 00589 __fun_type _M_f; 00590 }; 00591 00592 template <class _Tp, class _Arg> 00593 class const_mem_fun1_ref_t<void, _Tp, _Arg> 00594 : public binary_function<_Tp,_Arg,void> { 00595 typedef void (_Tp::*__fun_type)(_Arg) const; 00596 public: 00597 explicit const_mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} 00598 void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } 00599 private: 00600 __fun_type _M_f; 00601 }; 00602 00603 template <class _Arg> 00604 class pointer_to_unary_function<_Arg, void> : public unary_function<_Arg, void> { 00605 typedef void (*__fun_type)(_Arg); 00606 __fun_type _M_ptr; 00607 public: 00608 pointer_to_unary_function() {} 00609 explicit pointer_to_unary_function(__fun_type __x) : _M_ptr(__x) {} 00610 void operator()(_Arg __x) const { _M_ptr(__x); } 00611 }; 00612 00613 template <class _Arg1, class _Arg2> 00614 class pointer_to_binary_function<_Arg1, _Arg2, void> : public binary_function<_Arg1,_Arg2,void> { 00615 typedef void (*__fun_type)(_Arg1, _Arg2); 00616 __fun_type _M_ptr; 00617 public: 00618 pointer_to_binary_function() {} 00619 explicit pointer_to_binary_function(__fun_type __x) : _M_ptr(__x) {} 00620 void operator()(_Arg1 __x, _Arg2 __y) const { _M_ptr(__x, __y); } 00621 }; 00622 00623 #endif /*_STLP_DONT_RETURN_VOID && !_STLP_NO_CLASS_PARTIAL_SPECIALIZATION*/ 00624 00625 #else 00627 //mem_fun_t 00628 template <class _Result, class _Tp> 00629 class mem_fun_t : 00630 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr { 00631 typedef typename 00632 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr _Base; 00633 public: 00634 explicit mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {} 00635 }; 00636 00637 //const_mem_fun_t 00638 template <class _Result, class _Tp> 00639 class const_mem_fun_t : 00640 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const { 00641 typedef typename 00642 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const _Base; 00643 public: 00644 explicit const_mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {} 00645 }; 00646 00647 //mem_fun_ref_t 00648 template <class _Result, class _Tp> 00649 class mem_fun_ref_t : 00650 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref { 00651 typedef typename 00652 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref _Base; 00653 public: 00654 explicit mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} 00655 }; 00656 00657 //const_mem_fun_ref_t 00658 template <class _Result, class _Tp> 00659 class const_mem_fun_ref_t : 00660 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const { 00661 typedef typename 00662 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const _Base; 00663 public: 00664 explicit const_mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} 00665 }; 00666 00667 //mem_fun1_t 00668 template <class _Result, class _Tp, class _Arg> 00669 class mem_fun1_t : 00670 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr { 00671 typedef typename 00672 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr _Base; 00673 public: 00674 explicit mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {} 00675 }; 00676 00677 //const_mem_fun1_t 00678 template <class _Result, class _Tp, class _Arg> 00679 class const_mem_fun1_t : 00680 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const { 00681 typedef typename 00682 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const _Base; 00683 public: 00684 explicit const_mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {} 00685 }; 00686 00687 //mem_fun1_ref_t 00688 template <class _Result, class _Tp, class _Arg> 00689 class mem_fun1_ref_t : 00690 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref { 00691 typedef typename 00692 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref _Base; 00693 public: 00694 explicit mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} 00695 }; 00696 00697 //const_mem_fun1_t 00698 template <class _Result, class _Tp, class _Arg> 00699 class const_mem_fun1_ref_t : 00700 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const { 00701 typedef typename 00702 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const _Base; 00703 public: 00704 explicit const_mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} 00705 }; 00706 00707 00708 template <class _Arg, class _Result> 00709 class pointer_to_unary_function : 00710 public _Ptr_fun1<_Result,_Arg> { 00711 typedef typename 00712 _Ptr_fun1<_Result,_Arg>::__fun_type __fun_type; 00713 public: 00714 explicit pointer_to_unary_function(__fun_type __f) 00715 : _Ptr_fun1<_Result,_Arg>(__f) {} 00716 }; 00717 00718 template <class _Arg1, class _Arg2, class _Result> 00719 class pointer_to_binary_function : 00720 public _Ptr_fun2<_Result,_Arg1,_Arg2> { 00721 typedef typename 00722 _Ptr_fun2<_Result,_Arg1,_Arg2>::__fun_type __fun_type; 00723 public: 00724 explicit pointer_to_binary_function(__fun_type __f) 00725 : _Ptr_fun2<_Result,_Arg1,_Arg2>(__f) {} 00726 }; 00727 00728 #endif 00731 # if !defined (_STLP_MEMBER_POINTER_PARAM_BUG) 00732 // Mem_fun adaptor helper functions. There are only two: 00733 // mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref 00734 // are provided for backward compatibility, but they are no longer 00735 // part of the C++ standard.) 00736 00737 template <class _Result, class _Tp> 00738 inline mem_fun_t<_Result,_Tp> 00739 mem_fun(_Result (_Tp::*__f)()) { return mem_fun_t<_Result,_Tp>(__f); } 00740 00741 template <class _Result, class _Tp> 00742 inline const_mem_fun_t<_Result,_Tp> 00743 mem_fun(_Result (_Tp::*__f)() const) { return const_mem_fun_t<_Result,_Tp>(__f); } 00744 00745 template <class _Result, class _Tp> 00746 inline mem_fun_ref_t<_Result,_Tp> 00747 mem_fun_ref(_Result (_Tp::*__f)()) { return mem_fun_ref_t<_Result,_Tp>(__f); } 00748 00749 template <class _Result, class _Tp> 00750 inline const_mem_fun_ref_t<_Result,_Tp> 00751 mem_fun_ref(_Result (_Tp::*__f)() const) { return const_mem_fun_ref_t<_Result,_Tp>(__f); } 00752 00753 template <class _Result, class _Tp, class _Arg> 00754 inline mem_fun1_t<_Result,_Tp,_Arg> 00755 mem_fun(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); } 00756 00757 template <class _Result, class _Tp, class _Arg> 00758 inline const_mem_fun1_t<_Result,_Tp,_Arg> 00759 mem_fun(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); } 00760 00761 template <class _Result, class _Tp, class _Arg> 00762 inline mem_fun1_ref_t<_Result,_Tp,_Arg> 00763 mem_fun_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } 00764 00765 template <class _Result, class _Tp, class _Arg> 00766 inline const_mem_fun1_ref_t<_Result,_Tp,_Arg> 00767 mem_fun_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } 00768 00769 # if !(defined (_STLP_NO_EXTENSIONS) || defined (_STLP_NO_ANACHRONISMS)) 00770 // mem_fun1 and mem_fun1_ref are no longer part of the C++ standard, 00771 // but they are provided for backward compatibility. 00772 template <class _Result, class _Tp, class _Arg> 00773 inline mem_fun1_t<_Result,_Tp,_Arg> 00774 mem_fun1(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); } 00775 00776 template <class _Result, class _Tp, class _Arg> 00777 inline const_mem_fun1_t<_Result,_Tp,_Arg> 00778 mem_fun1(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); } 00779 00780 template <class _Result, class _Tp, class _Arg> 00781 inline mem_fun1_ref_t<_Result,_Tp,_Arg> 00782 mem_fun1_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } 00783 00784 template <class _Result, class _Tp, class _Arg> 00785 inline const_mem_fun1_ref_t<_Result,_Tp,_Arg> 00786 mem_fun1_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } 00787 00788 # endif /* _STLP_NO_EXTENSIONS */ 00789 00790 # endif /* _STLP_MEMBER_POINTER_PARAM_BUG */ 00791 00792 template <class _Arg, class _Result> 00793 inline pointer_to_unary_function<_Arg, _Result> 00794 ptr_fun(_Result (*__f)(_Arg)) 00795 { return pointer_to_unary_function<_Arg, _Result>(__f); } 00796 00797 template <class _Arg1, class _Arg2, class _Result> 00798 inline pointer_to_binary_function<_Arg1,_Arg2,_Result> 00799 ptr_fun(_Result (*__f)(_Arg1, _Arg2)) 00800 { return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f); } 00801 00802 _STLP_END_NAMESPACE
Generated on Mon Mar 10 15:32:23 2008 by ![]() |