Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_function_adaptors.h
Go 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<_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<_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 /* Specializations for void return type */ 00226 template<class _Tp> 00227 class _Void_mem_fun0_ptr : public unary_function<_Tp*,void> { 00228 protected: 00229 typedef void (_Tp::*__fun_type) (); 00230 explicit _Void_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} 00231 00232 public: 00233 void operator ()(_Tp* __p) const { (__p->*_M_f)(); } 00234 00235 private: 00236 __fun_type _M_f; 00237 }; 00238 00239 template<class _Tp, class _Arg> 00240 class _Void_mem_fun1_ptr : public binary_function<_Tp*,_Arg,void> { 00241 protected: 00242 typedef void (_Tp::*__fun_type) (_Arg); 00243 explicit _Void_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} 00244 00245 public: 00246 void operator ()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } 00247 00248 private: 00249 __fun_type _M_f; 00250 }; 00251 00252 template<class _Tp> 00253 class _Void_const_mem_fun0_ptr : public unary_function<const _Tp*,void> { 00254 protected: 00255 typedef void (_Tp::*__fun_type) () const; 00256 explicit _Void_const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} 00257 00258 public: 00259 void operator ()(const _Tp* __p) const { (__p->*_M_f)(); } 00260 00261 private: 00262 __fun_type _M_f; 00263 }; 00264 00265 template<class _Tp, class _Arg> 00266 class _Void_const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,void> { 00267 protected: 00268 typedef void (_Tp::*__fun_type) (_Arg) const; 00269 explicit _Void_const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} 00270 00271 public: 00272 void operator ()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } 00273 00274 private: 00275 __fun_type _M_f; 00276 }; 00277 00278 template<class _Tp> 00279 class _Void_mem_fun0_ref : public unary_function<_Tp,void> { 00280 protected: 00281 typedef void (_Tp::*__fun_type) (); 00282 explicit _Void_mem_fun0_ref(__fun_type __f) : _M_f(__f) {} 00283 00284 public: 00285 void operator ()(_Tp& __p) const { (__p.*_M_f)(); } 00286 00287 private: 00288 __fun_type _M_f; 00289 }; 00290 00291 template<class _Tp, class _Arg> 00292 class _Void_mem_fun1_ref : public binary_function<_Tp,_Arg,void> { 00293 protected: 00294 typedef void (_Tp::*__fun_type) (_Arg); 00295 explicit _Void_mem_fun1_ref(__fun_type __f) : _M_f(__f) {} 00296 00297 public: 00298 void operator ()(_Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); } 00299 00300 private: 00301 __fun_type _M_f; 00302 }; 00303 00304 template<class _Tp> 00305 class _Void_const_mem_fun0_ref : public unary_function<_Tp,void> { 00306 protected: 00307 typedef void (_Tp::*__fun_type) () const; 00308 explicit _Void_const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {} 00309 00310 public: 00311 void operator ()(const _Tp& __p) const { (__p.*_M_f)(); } 00312 00313 private: 00314 __fun_type _M_f; 00315 }; 00316 00317 template<class _Tp, class _Arg> 00318 class _Void_const_mem_fun1_ref : public binary_function<_Tp,_Arg,void> { 00319 protected: 00320 typedef void (_Tp::*__fun_type) (_Arg) const; 00321 explicit _Void_const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {} 00322 00323 public: 00324 void operator ()(const _Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); } 00325 00326 private: 00327 __fun_type _M_f; 00328 }; 00329 00330 _STLP_TEMPLATE_NULL 00331 struct _Mem_fun_traits<void> { 00332 template<class _Tp> struct _Args0 { 00333 typedef _Void_mem_fun0_ptr<_Tp> _Ptr; 00334 typedef _Void_const_mem_fun0_ptr<_Tp> _Ptr_const; 00335 typedef _Void_mem_fun0_ref<_Tp> _Ref; 00336 typedef _Void_const_mem_fun0_ref<_Tp> _Ref_const; 00337 }; 00338 00339 template<class _Tp, class _Arg> struct _Args1 { 00340 typedef _Void_mem_fun1_ptr<_Tp,_Arg> _Ptr; 00341 typedef _Void_const_mem_fun1_ptr<_Tp,_Arg> _Ptr_const; 00342 typedef _Void_mem_fun1_ref<_Tp,_Arg> _Ref; 00343 typedef _Void_const_mem_fun1_ref<_Tp,_Arg> _Ref_const; 00344 }; 00345 }; 00346 00347 template<class _Arg> 00348 class _Ptr_void_fun1_base : public unary_function<_Arg, void> { 00349 protected: 00350 typedef void (*__fun_type) (_Arg); 00351 explicit _Ptr_void_fun1_base(__fun_type __f) : _M_f(__f) {} 00352 00353 public: 00354 void operator()(_Arg __x) const { _M_f(__x); } 00355 00356 private: 00357 __fun_type _M_f; 00358 }; 00359 00360 template <class _Arg1, class _Arg2> 00361 class _Ptr_void_fun2_base : public binary_function<_Arg1,_Arg2,void> { 00362 protected: 00363 typedef void (*__fun_type) (_Arg1, _Arg2); 00364 explicit _Ptr_void_fun2_base(__fun_type __f) : _M_f(__f) {} 00365 00366 public: 00367 void operator()(_Arg1 __x, _Arg2 __y) const { _M_f(__x, __y); } 00368 00369 private: 00370 __fun_type _M_f; 00371 }; 00372 00373 _STLP_TEMPLATE_NULL 00374 struct _Ptr_fun_traits<void> { 00375 template<class _Arg> struct _Args1 { 00376 typedef _Ptr_void_fun1_base<_Arg> _Fun; 00377 }; 00378 00379 template<class _Arg1, class _Arg2> struct _Args2 { 00380 typedef _Ptr_void_fun2_base<_Arg1,_Arg2> _Fun; 00381 }; 00382 }; 00383 00384 // pavel: need extra level of inheritance here since MSVC++ does not 00385 // accept traits-based fake partial specialization for template 00386 // arguments other than first 00387 00388 template<class _Result, class _Arg> 00389 class _Ptr_fun1 : 00390 public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun { 00391 protected: 00392 typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun _Base; 00393 explicit _Ptr_fun1(typename _Base::__fun_type __f) : _Base(__f) {} 00394 }; 00395 00396 template<class _Result, class _Arg1, class _Arg2> 00397 class _Ptr_fun2 : 00398 public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun { 00399 protected: 00400 typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun _Base; 00401 explicit _Ptr_fun2(typename _Base::__fun_type __f) : _Base(__f) {} 00402 }; 00403 00404 template <class _Result, class _Tp> 00405 class mem_fun_t : 00406 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr { 00407 typedef typename 00408 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr _Base; 00409 public: 00410 explicit mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {} 00411 }; 00412 00413 template <class _Result, class _Tp> 00414 class const_mem_fun_t : 00415 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const { 00416 typedef typename 00417 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const _Base; 00418 public: 00419 explicit const_mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {} 00420 }; 00421 00422 template <class _Result, class _Tp> 00423 class mem_fun_ref_t : 00424 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref { 00425 typedef typename 00426 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref _Base; 00427 public: 00428 explicit mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} 00429 }; 00430 00431 template <class _Result, class _Tp> 00432 class const_mem_fun_ref_t : 00433 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const { 00434 typedef typename 00435 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const _Base; 00436 public: 00437 explicit const_mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} 00438 }; 00439 00440 template <class _Result, class _Tp, class _Arg> 00441 class mem_fun1_t : 00442 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr { 00443 typedef typename 00444 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr _Base; 00445 public: 00446 explicit mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {} 00447 }; 00448 00449 template <class _Result, class _Tp, class _Arg> 00450 class const_mem_fun1_t : 00451 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const { 00452 typedef typename 00453 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const _Base; 00454 public: 00455 explicit const_mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {} 00456 }; 00457 00458 template <class _Result, class _Tp, class _Arg> 00459 class mem_fun1_ref_t : 00460 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref { 00461 typedef typename 00462 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref _Base; 00463 public: 00464 explicit mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} 00465 }; 00466 00467 template <class _Result, class _Tp, class _Arg> 00468 class const_mem_fun1_ref_t : 00469 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const { 00470 typedef typename 00471 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const _Base; 00472 public: 00473 explicit const_mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} 00474 }; 00475 00476 template <class _Arg, class _Result> 00477 class pointer_to_unary_function : 00478 public _Ptr_fun1<_Result,_Arg> { 00479 typedef typename 00480 _Ptr_fun1<_Result,_Arg>::__fun_type __fun_type; 00481 public: 00482 explicit pointer_to_unary_function(__fun_type __f) 00483 : _Ptr_fun1<_Result,_Arg>(__f) {} 00484 }; 00485 00486 template <class _Arg1, class _Arg2, class _Result> 00487 class pointer_to_binary_function : 00488 public _Ptr_fun2<_Result,_Arg1,_Arg2> { 00489 typedef typename 00490 _Ptr_fun2<_Result,_Arg1,_Arg2>::__fun_type __fun_type; 00491 public: 00492 explicit pointer_to_binary_function(__fun_type __f) 00493 : _Ptr_fun2<_Result,_Arg1,_Arg2>(__f) {} 00494 }; 00495 00496 #else 00497 00498 template <class _Ret, class _Tp> 00499 class mem_fun_t : public unary_function<_Tp*,_Ret> { 00500 typedef _Ret (_Tp::*__fun_type)(void); 00501 public: 00502 explicit mem_fun_t(__fun_type __pf) : _M_f(__pf) {} 00503 _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); } 00504 private: 00505 __fun_type _M_f; 00506 }; 00507 00508 template <class _Ret, class _Tp> 00509 class const_mem_fun_t : public unary_function<const _Tp*,_Ret> { 00510 typedef _Ret (_Tp::*__fun_type)(void) const; 00511 public: 00512 explicit const_mem_fun_t(__fun_type __pf) : _M_f(__pf) {} 00513 _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); } 00514 private: 00515 __fun_type _M_f; 00516 }; 00517 00518 template <class _Ret, class _Tp> 00519 class mem_fun_ref_t : public unary_function<_Tp,_Ret> { 00520 typedef _Ret (_Tp::*__fun_type)(void); 00521 public: 00522 explicit mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {} 00523 _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); } 00524 private: 00525 __fun_type _M_f; 00526 }; 00527 00528 template <class _Ret, class _Tp> 00529 class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> { 00530 typedef _Ret (_Tp::*__fun_type)(void) const; 00531 public: 00532 explicit const_mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {} 00533 _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); } 00534 private: 00535 __fun_type _M_f; 00536 }; 00537 00538 template <class _Ret, class _Tp, class _Arg> 00539 class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> { 00540 typedef _Ret (_Tp::*__fun_type)(_Arg); 00541 public: 00542 explicit mem_fun1_t(__fun_type __pf) : _M_f(__pf) {} 00543 _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } 00544 private: 00545 __fun_type _M_f; 00546 }; 00547 00548 template <class _Ret, class _Tp, class _Arg> 00549 class const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> { 00550 typedef _Ret (_Tp::*__fun_type)(_Arg) const; 00551 public: 00552 explicit const_mem_fun1_t(__fun_type __pf) : _M_f(__pf) {} 00553 _Ret operator()(const _Tp* __p, _Arg __x) const 00554 { return (__p->*_M_f)(__x); } 00555 private: 00556 __fun_type _M_f; 00557 }; 00558 00559 template <class _Ret, class _Tp, class _Arg> 00560 class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { 00561 typedef _Ret (_Tp::*__fun_type)(_Arg); 00562 public: 00563 explicit mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {} 00564 _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } 00565 private: 00566 __fun_type _M_f; 00567 }; 00568 00569 template <class _Ret, class _Tp, class _Arg> 00570 class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { 00571 typedef _Ret (_Tp::*__fun_type)(_Arg) const; 00572 public: 00573 explicit const_mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {} 00574 _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } 00575 private: 00576 __fun_type _M_f; 00577 }; 00578 00579 template <class _Arg, class _Result> 00580 class pointer_to_unary_function : public unary_function<_Arg, _Result> { 00581 protected: 00582 _Result (*_M_ptr)(_Arg); 00583 public: 00584 pointer_to_unary_function() {} 00585 explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {} 00586 _Result operator()(_Arg __x) const { return _M_ptr(__x); } 00587 }; 00588 00589 template <class _Arg1, class _Arg2, class _Result> 00590 class pointer_to_binary_function : 00591 public binary_function<_Arg1,_Arg2,_Result> { 00592 protected: 00593 _Result (*_M_ptr)(_Arg1, _Arg2); 00594 public: 00595 pointer_to_binary_function() {} 00596 explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) 00597 : _M_ptr(__x) {} 00598 _Result operator()(_Arg1 __x, _Arg2 __y) const { 00599 return _M_ptr(__x, __y); 00600 } 00601 }; 00602 00603 # if defined (_STLP_DONT_RETURN_VOID) && !defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) 00604 //Partial specializations for the void type 00605 template <class _Tp> 00606 class mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> { 00607 typedef void (_Tp::*__fun_type)(void); 00608 public: 00609 explicit mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} 00610 void operator()(_Tp* __p) const { (__p->*_M_f)(); } 00611 private: 00612 __fun_type _M_f; 00613 }; 00614 00615 template <class _Tp> 00616 class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> { 00617 typedef void (_Tp::*__fun_type)(void) const; 00618 public: 00619 explicit const_mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} 00620 void operator()(const _Tp* __p) const { (__p->*_M_f)(); } 00621 private: 00622 __fun_type _M_f; 00623 }; 00624 00625 template <class _Tp> 00626 class mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> { 00627 typedef void (_Tp::*__fun_type)(void); 00628 public: 00629 explicit mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} 00630 void operator()(_Tp& __r) const { (__r.*_M_f)(); } 00631 private: 00632 __fun_type _M_f; 00633 }; 00634 00635 template <class _Tp> 00636 class const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> { 00637 typedef void (_Tp::*__fun_type)(void) const; 00638 public: 00639 explicit const_mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} 00640 void operator()(const _Tp& __r) const { (__r.*_M_f)(); } 00641 private: 00642 __fun_type _M_f; 00643 }; 00644 00645 template <class _Tp, class _Arg> 00646 class mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> { 00647 typedef void (_Tp::*__fun_type)(_Arg); 00648 public: 00649 explicit mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} 00650 void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } 00651 private: 00652 __fun_type _M_f; 00653 }; 00654 00655 template <class _Tp, class _Arg> 00656 class const_mem_fun1_t<void, _Tp, _Arg> 00657 : public binary_function<const _Tp*,_Arg,void> { 00658 typedef void (_Tp::*__fun_type)(_Arg) const; 00659 public: 00660 explicit const_mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} 00661 void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } 00662 private: 00663 __fun_type _M_f; 00664 }; 00665 00666 template <class _Tp, class _Arg> 00667 class mem_fun1_ref_t<void, _Tp, _Arg> 00668 : public binary_function<_Tp,_Arg,void> { 00669 typedef void (_Tp::*__fun_type)(_Arg); 00670 public: 00671 explicit mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} 00672 void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } 00673 private: 00674 __fun_type _M_f; 00675 }; 00676 00677 template <class _Tp, class _Arg> 00678 class const_mem_fun1_ref_t<void, _Tp, _Arg> 00679 : public binary_function<_Tp,_Arg,void> { 00680 typedef void (_Tp::*__fun_type)(_Arg) const; 00681 public: 00682 explicit const_mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} 00683 void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } 00684 private: 00685 __fun_type _M_f; 00686 }; 00687 00688 template <class _Arg> 00689 class pointer_to_unary_function<_Arg, void> : public unary_function<_Arg, void> { 00690 typedef void (*__fun_type)(_Arg); 00691 __fun_type _M_ptr; 00692 public: 00693 pointer_to_unary_function() {} 00694 explicit pointer_to_unary_function(__fun_type __x) : _M_ptr(__x) {} 00695 void operator()(_Arg __x) const { _M_ptr(__x); } 00696 }; 00697 00698 template <class _Arg1, class _Arg2> 00699 class pointer_to_binary_function<_Arg1, _Arg2, void> : public binary_function<_Arg1,_Arg2,void> { 00700 typedef void (*__fun_type)(_Arg1, _Arg2); 00701 __fun_type _M_ptr; 00702 public: 00703 pointer_to_binary_function() {} 00704 explicit pointer_to_binary_function(__fun_type __x) : _M_ptr(__x) {} 00705 void operator()(_Arg1 __x, _Arg2 __y) const { _M_ptr(__x, __y); } 00706 }; 00707 00708 # endif 00709 00710 #endif 00711 00712 #if !defined (_STLP_MEMBER_POINTER_PARAM_BUG) 00713 // Mem_fun adaptor helper functions. There are only two: 00714 // mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref 00715 // are provided for backward compatibility, but they are no longer 00716 // part of the C++ standard.) 00717 00718 template <class _Result, class _Tp> 00719 inline mem_fun_t<_Result,_Tp> 00720 mem_fun(_Result (_Tp::*__f)()) { return mem_fun_t<_Result,_Tp>(__f); } 00721 00722 template <class _Result, class _Tp> 00723 inline const_mem_fun_t<_Result,_Tp> 00724 mem_fun(_Result (_Tp::*__f)() const) { return const_mem_fun_t<_Result,_Tp>(__f); } 00725 00726 template <class _Result, class _Tp> 00727 inline mem_fun_ref_t<_Result,_Tp> 00728 mem_fun_ref(_Result (_Tp::*__f)()) { return mem_fun_ref_t<_Result,_Tp>(__f); } 00729 00730 template <class _Result, class _Tp> 00731 inline const_mem_fun_ref_t<_Result,_Tp> 00732 mem_fun_ref(_Result (_Tp::*__f)() const) { return const_mem_fun_ref_t<_Result,_Tp>(__f); } 00733 00734 template <class _Result, class _Tp, class _Arg> 00735 inline mem_fun1_t<_Result,_Tp,_Arg> 00736 mem_fun(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); } 00737 00738 template <class _Result, class _Tp, class _Arg> 00739 inline const_mem_fun1_t<_Result,_Tp,_Arg> 00740 mem_fun(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); } 00741 00742 template <class _Result, class _Tp, class _Arg> 00743 inline mem_fun1_ref_t<_Result,_Tp,_Arg> 00744 mem_fun_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } 00745 00746 template <class _Result, class _Tp, class _Arg> 00747 inline const_mem_fun1_ref_t<_Result,_Tp,_Arg> 00748 mem_fun_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } 00749 00750 # if !(defined (_STLP_NO_EXTENSIONS) || defined (_STLP_NO_ANACHRONISMS)) 00751 // mem_fun1 and mem_fun1_ref are no longer part of the C++ standard, 00752 // but they are provided for backward compatibility. 00753 template <class _Result, class _Tp, class _Arg> 00754 inline mem_fun1_t<_Result,_Tp,_Arg> 00755 mem_fun1(_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_fun1(_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_fun1_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_fun1_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } 00768 00769 # endif 00770 00771 #endif 00772 00773 template <class _Arg, class _Result> 00774 inline pointer_to_unary_function<_Arg, _Result> 00775 ptr_fun(_Result (*__f)(_Arg)) 00776 { return pointer_to_unary_function<_Arg, _Result>(__f); } 00777 00778 template <class _Arg1, class _Arg2, class _Result> 00779 inline pointer_to_binary_function<_Arg1,_Arg2,_Result> 00780 ptr_fun(_Result (*__f)(_Arg1, _Arg2)) 00781 { return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f); } 00782 00783 _STLP_END_NAMESPACE Generated on Sat May 26 2012 04:27:37 for ReactOS by
1.7.6.1
|