libstdc++
|
00001 // Functor implementations -*- C++ -*- 00002 00003 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 00004 // Free Software Foundation, Inc. 00005 // 00006 // This file is part of the GNU ISO C++ Library. This library is free 00007 // software; you can redistribute it and/or modify it under the 00008 // terms of the GNU General Public License as published by the 00009 // Free Software Foundation; either version 3, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 00017 // Under Section 7 of GPL version 3, you are granted additional 00018 // permissions described in the GCC Runtime Library Exception, version 00019 // 3.1, as published by the Free Software Foundation. 00020 00021 // You should have received a copy of the GNU General Public License and 00022 // a copy of the GCC Runtime Library Exception along with this program; 00023 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00024 // <http://www.gnu.org/licenses/>. 00025 00026 /* 00027 * 00028 * Copyright (c) 1994 00029 * Hewlett-Packard Company 00030 * 00031 * Permission to use, copy, modify, distribute and sell this software 00032 * and its documentation for any purpose is hereby granted without fee, 00033 * provided that the above copyright notice appear in all copies and 00034 * that both that copyright notice and this permission notice appear 00035 * in supporting documentation. Hewlett-Packard Company makes no 00036 * representations about the suitability of this software for any 00037 * purpose. It is provided "as is" without express or implied warranty. 00038 * 00039 * 00040 * Copyright (c) 1996-1998 00041 * Silicon Graphics Computer Systems, Inc. 00042 * 00043 * Permission to use, copy, modify, distribute and sell this software 00044 * and its documentation for any purpose is hereby granted without fee, 00045 * provided that the above copyright notice appear in all copies and 00046 * that both that copyright notice and this permission notice appear 00047 * in supporting documentation. Silicon Graphics makes no 00048 * representations about the suitability of this software for any 00049 * purpose. It is provided "as is" without express or implied warranty. 00050 */ 00051 00052 /** @file bits/stl_function.h 00053 * This is an internal header file, included by other library headers. 00054 * Do not attempt to use it directly. @headername{functional} 00055 */ 00056 00057 #ifndef _STL_FUNCTION_H 00058 #define _STL_FUNCTION_H 1 00059 00060 namespace std _GLIBCXX_VISIBILITY(default) 00061 { 00062 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00063 00064 // 20.3.1 base classes 00065 /** @defgroup functors Function Objects 00066 * @ingroup utilities 00067 * 00068 * Function objects, or @e functors, are objects with an @c operator() 00069 * defined and accessible. They can be passed as arguments to algorithm 00070 * templates and used in place of a function pointer. Not only is the 00071 * resulting expressiveness of the library increased, but the generated 00072 * code can be more efficient than what you might write by hand. When we 00073 * refer to @a functors, then, generally we include function pointers in 00074 * the description as well. 00075 * 00076 * Often, functors are only created as temporaries passed to algorithm 00077 * calls, rather than being created as named variables. 00078 * 00079 * Two examples taken from the standard itself follow. To perform a 00080 * by-element addition of two vectors @c a and @c b containing @c double, 00081 * and put the result in @c a, use 00082 * \code 00083 * transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>()); 00084 * \endcode 00085 * To negate every element in @c a, use 00086 * \code 00087 * transform(a.begin(), a.end(), a.begin(), negate<double>()); 00088 * \endcode 00089 * The addition and negation functions will be inlined directly. 00090 * 00091 * The standard functors are derived from structs named @c unary_function 00092 * and @c binary_function. These two classes contain nothing but typedefs, 00093 * to aid in generic (template) programming. If you write your own 00094 * functors, you might consider doing the same. 00095 * 00096 * @{ 00097 */ 00098 /** 00099 * This is one of the @link functors functor base classes@endlink. 00100 */ 00101 template<typename _Arg, typename _Result> 00102 struct unary_function 00103 { 00104 /// @c argument_type is the type of the argument 00105 typedef _Arg argument_type; 00106 00107 /// @c result_type is the return type 00108 typedef _Result result_type; 00109 }; 00110 00111 /** 00112 * This is one of the @link functors functor base classes@endlink. 00113 */ 00114 template<typename _Arg1, typename _Arg2, typename _Result> 00115 struct binary_function 00116 { 00117 /// @c first_argument_type is the type of the first argument 00118 typedef _Arg1 first_argument_type; 00119 00120 /// @c second_argument_type is the type of the second argument 00121 typedef _Arg2 second_argument_type; 00122 00123 /// @c result_type is the return type 00124 typedef _Result result_type; 00125 }; 00126 /** @} */ 00127 00128 // 20.3.2 arithmetic 00129 /** @defgroup arithmetic_functors Arithmetic Classes 00130 * @ingroup functors 00131 * 00132 * Because basic math often needs to be done during an algorithm, 00133 * the library provides functors for those operations. See the 00134 * documentation for @link functors the base classes@endlink 00135 * for examples of their use. 00136 * 00137 * @{ 00138 */ 00139 /// One of the @link arithmetic_functors math functors@endlink. 00140 template<typename _Tp> 00141 struct plus : public binary_function<_Tp, _Tp, _Tp> 00142 { 00143 _Tp 00144 operator()(const _Tp& __x, const _Tp& __y) const 00145 { return __x + __y; } 00146 }; 00147 00148 /// One of the @link arithmetic_functors math functors@endlink. 00149 template<typename _Tp> 00150 struct minus : public binary_function<_Tp, _Tp, _Tp> 00151 { 00152 _Tp 00153 operator()(const _Tp& __x, const _Tp& __y) const 00154 { return __x - __y; } 00155 }; 00156 00157 /// One of the @link arithmetic_functors math functors@endlink. 00158 template<typename _Tp> 00159 struct multiplies : public binary_function<_Tp, _Tp, _Tp> 00160 { 00161 _Tp 00162 operator()(const _Tp& __x, const _Tp& __y) const 00163 { return __x * __y; } 00164 }; 00165 00166 /// One of the @link arithmetic_functors math functors@endlink. 00167 template<typename _Tp> 00168 struct divides : public binary_function<_Tp, _Tp, _Tp> 00169 { 00170 _Tp 00171 operator()(const _Tp& __x, const _Tp& __y) const 00172 { return __x / __y; } 00173 }; 00174 00175 /// One of the @link arithmetic_functors math functors@endlink. 00176 template<typename _Tp> 00177 struct modulus : public binary_function<_Tp, _Tp, _Tp> 00178 { 00179 _Tp 00180 operator()(const _Tp& __x, const _Tp& __y) const 00181 { return __x % __y; } 00182 }; 00183 00184 /// One of the @link arithmetic_functors math functors@endlink. 00185 template<typename _Tp> 00186 struct negate : public unary_function<_Tp, _Tp> 00187 { 00188 _Tp 00189 operator()(const _Tp& __x) const 00190 { return -__x; } 00191 }; 00192 /** @} */ 00193 00194 // 20.3.3 comparisons 00195 /** @defgroup comparison_functors Comparison Classes 00196 * @ingroup functors 00197 * 00198 * The library provides six wrapper functors for all the basic comparisons 00199 * in C++, like @c <. 00200 * 00201 * @{ 00202 */ 00203 /// One of the @link comparison_functors comparison functors@endlink. 00204 template<typename _Tp> 00205 struct equal_to : public binary_function<_Tp, _Tp, bool> 00206 { 00207 bool 00208 operator()(const _Tp& __x, const _Tp& __y) const 00209 { return __x == __y; } 00210 }; 00211 00212 /// One of the @link comparison_functors comparison functors@endlink. 00213 template<typename _Tp> 00214 struct not_equal_to : public binary_function<_Tp, _Tp, bool> 00215 { 00216 bool 00217 operator()(const _Tp& __x, const _Tp& __y) const 00218 { return __x != __y; } 00219 }; 00220 00221 /// One of the @link comparison_functors comparison functors@endlink. 00222 template<typename _Tp> 00223 struct greater : public binary_function<_Tp, _Tp, bool> 00224 { 00225 bool 00226 operator()(const _Tp& __x, const _Tp& __y) const 00227 { return __x > __y; } 00228 }; 00229 00230 /// One of the @link comparison_functors comparison functors@endlink. 00231 template<typename _Tp> 00232 struct less : public binary_function<_Tp, _Tp, bool> 00233 { 00234 bool 00235 operator()(const _Tp& __x, const _Tp& __y) const 00236 { return __x < __y; } 00237 }; 00238 00239 /// One of the @link comparison_functors comparison functors@endlink. 00240 template<typename _Tp> 00241 struct greater_equal : public binary_function<_Tp, _Tp, bool> 00242 { 00243 bool 00244 operator()(const _Tp& __x, const _Tp& __y) const 00245 { return __x >= __y; } 00246 }; 00247 00248 /// One of the @link comparison_functors comparison functors@endlink. 00249 template<typename _Tp> 00250 struct less_equal : public binary_function<_Tp, _Tp, bool> 00251 { 00252 bool 00253 operator()(const _Tp& __x, const _Tp& __y) const 00254 { return __x <= __y; } 00255 }; 00256 /** @} */ 00257 00258 // 20.3.4 logical operations 00259 /** @defgroup logical_functors Boolean Operations Classes 00260 * @ingroup functors 00261 * 00262 * Here are wrapper functors for Boolean operations: @c &&, @c ||, 00263 * and @c !. 00264 * 00265 * @{ 00266 */ 00267 /// One of the @link logical_functors Boolean operations functors@endlink. 00268 template<typename _Tp> 00269 struct logical_and : public binary_function<_Tp, _Tp, bool> 00270 { 00271 bool 00272 operator()(const _Tp& __x, const _Tp& __y) const 00273 { return __x && __y; } 00274 }; 00275 00276 /// One of the @link logical_functors Boolean operations functors@endlink. 00277 template<typename _Tp> 00278 struct logical_or : public binary_function<_Tp, _Tp, bool> 00279 { 00280 bool 00281 operator()(const _Tp& __x, const _Tp& __y) const 00282 { return __x || __y; } 00283 }; 00284 00285 /// One of the @link logical_functors Boolean operations functors@endlink. 00286 template<typename _Tp> 00287 struct logical_not : public unary_function<_Tp, bool> 00288 { 00289 bool 00290 operator()(const _Tp& __x) const 00291 { return !__x; } 00292 }; 00293 /** @} */ 00294 00295 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00296 // DR 660. Missing Bitwise Operations. 00297 template<typename _Tp> 00298 struct bit_and : public binary_function<_Tp, _Tp, _Tp> 00299 { 00300 _Tp 00301 operator()(const _Tp& __x, const _Tp& __y) const 00302 { return __x & __y; } 00303 }; 00304 00305 template<typename _Tp> 00306 struct bit_or : public binary_function<_Tp, _Tp, _Tp> 00307 { 00308 _Tp 00309 operator()(const _Tp& __x, const _Tp& __y) const 00310 { return __x | __y; } 00311 }; 00312 00313 template<typename _Tp> 00314 struct bit_xor : public binary_function<_Tp, _Tp, _Tp> 00315 { 00316 _Tp 00317 operator()(const _Tp& __x, const _Tp& __y) const 00318 { return __x ^ __y; } 00319 }; 00320 00321 // 20.3.5 negators 00322 /** @defgroup negators Negators 00323 * @ingroup functors 00324 * 00325 * The functions @c not1 and @c not2 each take a predicate functor 00326 * and return an instance of @c unary_negate or 00327 * @c binary_negate, respectively. These classes are functors whose 00328 * @c operator() performs the stored predicate function and then returns 00329 * the negation of the result. 00330 * 00331 * For example, given a vector of integers and a trivial predicate, 00332 * \code 00333 * struct IntGreaterThanThree 00334 * : public std::unary_function<int, bool> 00335 * { 00336 * bool operator() (int x) { return x > 3; } 00337 * }; 00338 * 00339 * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree())); 00340 * \endcode 00341 * The call to @c find_if will locate the first index (i) of @c v for which 00342 * <code>!(v[i] > 3)</code> is true. 00343 * 00344 * The not1/unary_negate combination works on predicates taking a single 00345 * argument. The not2/binary_negate combination works on predicates which 00346 * take two arguments. 00347 * 00348 * @{ 00349 */ 00350 /// One of the @link negators negation functors@endlink. 00351 template<typename _Predicate> 00352 class unary_negate 00353 : public unary_function<typename _Predicate::argument_type, bool> 00354 { 00355 protected: 00356 _Predicate _M_pred; 00357 00358 public: 00359 explicit 00360 unary_negate(const _Predicate& __x) : _M_pred(__x) { } 00361 00362 bool 00363 operator()(const typename _Predicate::argument_type& __x) const 00364 { return !_M_pred(__x); } 00365 }; 00366 00367 /// One of the @link negators negation functors@endlink. 00368 template<typename _Predicate> 00369 inline unary_negate<_Predicate> 00370 not1(const _Predicate& __pred) 00371 { return unary_negate<_Predicate>(__pred); } 00372 00373 /// One of the @link negators negation functors@endlink. 00374 template<typename _Predicate> 00375 class binary_negate 00376 : public binary_function<typename _Predicate::first_argument_type, 00377 typename _Predicate::second_argument_type, bool> 00378 { 00379 protected: 00380 _Predicate _M_pred; 00381 00382 public: 00383 explicit 00384 binary_negate(const _Predicate& __x) : _M_pred(__x) { } 00385 00386 bool 00387 operator()(const typename _Predicate::first_argument_type& __x, 00388 const typename _Predicate::second_argument_type& __y) const 00389 { return !_M_pred(__x, __y); } 00390 }; 00391 00392 /// One of the @link negators negation functors@endlink. 00393 template<typename _Predicate> 00394 inline binary_negate<_Predicate> 00395 not2(const _Predicate& __pred) 00396 { return binary_negate<_Predicate>(__pred); } 00397 /** @} */ 00398 00399 // 20.3.7 adaptors pointers functions 00400 /** @defgroup pointer_adaptors Adaptors for pointers to functions 00401 * @ingroup functors 00402 * 00403 * The advantage of function objects over pointers to functions is that 00404 * the objects in the standard library declare nested typedefs describing 00405 * their argument and result types with uniform names (e.g., @c result_type 00406 * from the base classes @c unary_function and @c binary_function). 00407 * Sometimes those typedefs are required, not just optional. 00408 * 00409 * Adaptors are provided to turn pointers to unary (single-argument) and 00410 * binary (double-argument) functions into function objects. The 00411 * long-winded functor @c pointer_to_unary_function is constructed with a 00412 * function pointer @c f, and its @c operator() called with argument @c x 00413 * returns @c f(x). The functor @c pointer_to_binary_function does the same 00414 * thing, but with a double-argument @c f and @c operator(). 00415 * 00416 * The function @c ptr_fun takes a pointer-to-function @c f and constructs 00417 * an instance of the appropriate functor. 00418 * 00419 * @{ 00420 */ 00421 /// One of the @link pointer_adaptors adaptors for function pointers@endlink. 00422 template<typename _Arg, typename _Result> 00423 class pointer_to_unary_function : public unary_function<_Arg, _Result> 00424 { 00425 protected: 00426 _Result (*_M_ptr)(_Arg); 00427 00428 public: 00429 pointer_to_unary_function() { } 00430 00431 explicit 00432 pointer_to_unary_function(_Result (*__x)(_Arg)) 00433 : _M_ptr(__x) { } 00434 00435 _Result 00436 operator()(_Arg __x) const 00437 { return _M_ptr(__x); } 00438 }; 00439 00440 /// One of the @link pointer_adaptors adaptors for function pointers@endlink. 00441 template<typename _Arg, typename _Result> 00442 inline pointer_to_unary_function<_Arg, _Result> 00443 ptr_fun(_Result (*__x)(_Arg)) 00444 { return pointer_to_unary_function<_Arg, _Result>(__x); } 00445 00446 /// One of the @link pointer_adaptors adaptors for function pointers@endlink. 00447 template<typename _Arg1, typename _Arg2, typename _Result> 00448 class pointer_to_binary_function 00449 : public binary_function<_Arg1, _Arg2, _Result> 00450 { 00451 protected: 00452 _Result (*_M_ptr)(_Arg1, _Arg2); 00453 00454 public: 00455 pointer_to_binary_function() { } 00456 00457 explicit 00458 pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) 00459 : _M_ptr(__x) { } 00460 00461 _Result 00462 operator()(_Arg1 __x, _Arg2 __y) const 00463 { return _M_ptr(__x, __y); } 00464 }; 00465 00466 /// One of the @link pointer_adaptors adaptors for function pointers@endlink. 00467 template<typename _Arg1, typename _Arg2, typename _Result> 00468 inline pointer_to_binary_function<_Arg1, _Arg2, _Result> 00469 ptr_fun(_Result (*__x)(_Arg1, _Arg2)) 00470 { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); } 00471 /** @} */ 00472 00473 template<typename _Tp> 00474 struct _Identity : public unary_function<_Tp,_Tp> 00475 { 00476 _Tp& 00477 operator()(_Tp& __x) const 00478 { return __x; } 00479 00480 const _Tp& 00481 operator()(const _Tp& __x) const 00482 { return __x; } 00483 }; 00484 00485 template<typename _Pair> 00486 struct _Select1st : public unary_function<_Pair, 00487 typename _Pair::first_type> 00488 { 00489 typename _Pair::first_type& 00490 operator()(_Pair& __x) const 00491 { return __x.first; } 00492 00493 const typename _Pair::first_type& 00494 operator()(const _Pair& __x) const 00495 { return __x.first; } 00496 00497 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 00498 template<typename _Pair2> 00499 typename _Pair2::first_type& 00500 operator()(_Pair2& __x) const 00501 { return __x.first; } 00502 00503 template<typename _Pair2> 00504 const typename _Pair2::first_type& 00505 operator()(const _Pair2& __x) const 00506 { return __x.first; } 00507 #endif 00508 }; 00509 00510 template<typename _Pair> 00511 struct _Select2nd : public unary_function<_Pair, 00512 typename _Pair::second_type> 00513 { 00514 typename _Pair::second_type& 00515 operator()(_Pair& __x) const 00516 { return __x.second; } 00517 00518 const typename _Pair::second_type& 00519 operator()(const _Pair& __x) const 00520 { return __x.second; } 00521 }; 00522 00523 // 20.3.8 adaptors pointers members 00524 /** @defgroup memory_adaptors Adaptors for pointers to members 00525 * @ingroup functors 00526 * 00527 * There are a total of 8 = 2^3 function objects in this family. 00528 * (1) Member functions taking no arguments vs member functions taking 00529 * one argument. 00530 * (2) Call through pointer vs call through reference. 00531 * (3) Const vs non-const member function. 00532 * 00533 * All of this complexity is in the function objects themselves. You can 00534 * ignore it by using the helper function mem_fun and mem_fun_ref, 00535 * which create whichever type of adaptor is appropriate. 00536 * 00537 * @{ 00538 */ 00539 /// One of the @link memory_adaptors adaptors for member 00540 /// pointers@endlink. 00541 template<typename _Ret, typename _Tp> 00542 class mem_fun_t : public unary_function<_Tp*, _Ret> 00543 { 00544 public: 00545 explicit 00546 mem_fun_t(_Ret (_Tp::*__pf)()) 00547 : _M_f(__pf) { } 00548 00549 _Ret 00550 operator()(_Tp* __p) const 00551 { return (__p->*_M_f)(); } 00552 00553 private: 00554 _Ret (_Tp::*_M_f)(); 00555 }; 00556 00557 /// One of the @link memory_adaptors adaptors for member 00558 /// pointers@endlink. 00559 template<typename _Ret, typename _Tp> 00560 class const_mem_fun_t : public unary_function<const _Tp*, _Ret> 00561 { 00562 public: 00563 explicit 00564 const_mem_fun_t(_Ret (_Tp::*__pf)() const) 00565 : _M_f(__pf) { } 00566 00567 _Ret 00568 operator()(const _Tp* __p) const 00569 { return (__p->*_M_f)(); } 00570 00571 private: 00572 _Ret (_Tp::*_M_f)() const; 00573 }; 00574 00575 /// One of the @link memory_adaptors adaptors for member 00576 /// pointers@endlink. 00577 template<typename _Ret, typename _Tp> 00578 class mem_fun_ref_t : public unary_function<_Tp, _Ret> 00579 { 00580 public: 00581 explicit 00582 mem_fun_ref_t(_Ret (_Tp::*__pf)()) 00583 : _M_f(__pf) { } 00584 00585 _Ret 00586 operator()(_Tp& __r) const 00587 { return (__r.*_M_f)(); } 00588 00589 private: 00590 _Ret (_Tp::*_M_f)(); 00591 }; 00592 00593 /// One of the @link memory_adaptors adaptors for member 00594 /// pointers@endlink. 00595 template<typename _Ret, typename _Tp> 00596 class const_mem_fun_ref_t : public unary_function<_Tp, _Ret> 00597 { 00598 public: 00599 explicit 00600 const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) 00601 : _M_f(__pf) { } 00602 00603 _Ret 00604 operator()(const _Tp& __r) const 00605 { return (__r.*_M_f)(); } 00606 00607 private: 00608 _Ret (_Tp::*_M_f)() const; 00609 }; 00610 00611 /// One of the @link memory_adaptors adaptors for member 00612 /// pointers@endlink. 00613 template<typename _Ret, typename _Tp, typename _Arg> 00614 class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret> 00615 { 00616 public: 00617 explicit 00618 mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) 00619 : _M_f(__pf) { } 00620 00621 _Ret 00622 operator()(_Tp* __p, _Arg __x) const 00623 { return (__p->*_M_f)(__x); } 00624 00625 private: 00626 _Ret (_Tp::*_M_f)(_Arg); 00627 }; 00628 00629 /// One of the @link memory_adaptors adaptors for member 00630 /// pointers@endlink. 00631 template<typename _Ret, typename _Tp, typename _Arg> 00632 class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret> 00633 { 00634 public: 00635 explicit 00636 const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) 00637 : _M_f(__pf) { } 00638 00639 _Ret 00640 operator()(const _Tp* __p, _Arg __x) const 00641 { return (__p->*_M_f)(__x); } 00642 00643 private: 00644 _Ret (_Tp::*_M_f)(_Arg) const; 00645 }; 00646 00647 /// One of the @link memory_adaptors adaptors for member 00648 /// pointers@endlink. 00649 template<typename _Ret, typename _Tp, typename _Arg> 00650 class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> 00651 { 00652 public: 00653 explicit 00654 mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) 00655 : _M_f(__pf) { } 00656 00657 _Ret 00658 operator()(_Tp& __r, _Arg __x) const 00659 { return (__r.*_M_f)(__x); } 00660 00661 private: 00662 _Ret (_Tp::*_M_f)(_Arg); 00663 }; 00664 00665 /// One of the @link memory_adaptors adaptors for member 00666 /// pointers@endlink. 00667 template<typename _Ret, typename _Tp, typename _Arg> 00668 class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> 00669 { 00670 public: 00671 explicit 00672 const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) 00673 : _M_f(__pf) { } 00674 00675 _Ret 00676 operator()(const _Tp& __r, _Arg __x) const 00677 { return (__r.*_M_f)(__x); } 00678 00679 private: 00680 _Ret (_Tp::*_M_f)(_Arg) const; 00681 }; 00682 00683 // Mem_fun adaptor helper functions. There are only two: 00684 // mem_fun and mem_fun_ref. 00685 template<typename _Ret, typename _Tp> 00686 inline mem_fun_t<_Ret, _Tp> 00687 mem_fun(_Ret (_Tp::*__f)()) 00688 { return mem_fun_t<_Ret, _Tp>(__f); } 00689 00690 template<typename _Ret, typename _Tp> 00691 inline const_mem_fun_t<_Ret, _Tp> 00692 mem_fun(_Ret (_Tp::*__f)() const) 00693 { return const_mem_fun_t<_Ret, _Tp>(__f); } 00694 00695 template<typename _Ret, typename _Tp> 00696 inline mem_fun_ref_t<_Ret, _Tp> 00697 mem_fun_ref(_Ret (_Tp::*__f)()) 00698 { return mem_fun_ref_t<_Ret, _Tp>(__f); } 00699 00700 template<typename _Ret, typename _Tp> 00701 inline const_mem_fun_ref_t<_Ret, _Tp> 00702 mem_fun_ref(_Ret (_Tp::*__f)() const) 00703 { return const_mem_fun_ref_t<_Ret, _Tp>(__f); } 00704 00705 template<typename _Ret, typename _Tp, typename _Arg> 00706 inline mem_fun1_t<_Ret, _Tp, _Arg> 00707 mem_fun(_Ret (_Tp::*__f)(_Arg)) 00708 { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); } 00709 00710 template<typename _Ret, typename _Tp, typename _Arg> 00711 inline const_mem_fun1_t<_Ret, _Tp, _Arg> 00712 mem_fun(_Ret (_Tp::*__f)(_Arg) const) 00713 { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); } 00714 00715 template<typename _Ret, typename _Tp, typename _Arg> 00716 inline mem_fun1_ref_t<_Ret, _Tp, _Arg> 00717 mem_fun_ref(_Ret (_Tp::*__f)(_Arg)) 00718 { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } 00719 00720 template<typename _Ret, typename _Tp, typename _Arg> 00721 inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg> 00722 mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const) 00723 { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } 00724 00725 /** @} */ 00726 00727 _GLIBCXX_END_NAMESPACE_VERSION 00728 } // namespace 00729 00730 #if !defined(__GXX_EXPERIMENTAL_CXX0X__) || _GLIBCXX_USE_DEPRECATED 00731 # include <backward/binders.h> 00732 #endif 00733 00734 #endif /* _STL_FUNCTION_H */