libstdc++
|
00001 // Functor implementations -*- C++ -*- 00002 00003 // Copyright (C) 2001-2013 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /* 00026 * 00027 * Copyright (c) 1994 00028 * Hewlett-Packard Company 00029 * 00030 * Permission to use, copy, modify, distribute and sell this software 00031 * and its documentation for any purpose is hereby granted without fee, 00032 * provided that the above copyright notice appear in all copies and 00033 * that both that copyright notice and this permission notice appear 00034 * in supporting documentation. Hewlett-Packard Company makes no 00035 * representations about the suitability of this software for any 00036 * purpose. It is provided "as is" without express or implied warranty. 00037 * 00038 * 00039 * Copyright (c) 1996-1998 00040 * Silicon Graphics Computer Systems, Inc. 00041 * 00042 * Permission to use, copy, modify, distribute and sell this software 00043 * and its documentation for any purpose is hereby granted without fee, 00044 * provided that the above copyright notice appear in all copies and 00045 * that both that copyright notice and this permission notice appear 00046 * in supporting documentation. Silicon Graphics makes no 00047 * representations about the suitability of this software for any 00048 * purpose. It is provided "as is" without express or implied warranty. 00049 */ 00050 00051 /** @file bits/stl_function.h 00052 * This is an internal header file, included by other library headers. 00053 * Do not attempt to use it directly. @headername{functional} 00054 */ 00055 00056 #ifndef _STL_FUNCTION_H 00057 #define _STL_FUNCTION_H 1 00058 00059 namespace std _GLIBCXX_VISIBILITY(default) 00060 { 00061 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00062 00063 // 20.3.1 base classes 00064 /** @defgroup functors Function Objects 00065 * @ingroup utilities 00066 * 00067 * Function objects, or @e functors, are objects with an @c operator() 00068 * defined and accessible. They can be passed as arguments to algorithm 00069 * templates and used in place of a function pointer. Not only is the 00070 * resulting expressiveness of the library increased, but the generated 00071 * code can be more efficient than what you might write by hand. When we 00072 * refer to @a functors, then, generally we include function pointers in 00073 * the description as well. 00074 * 00075 * Often, functors are only created as temporaries passed to algorithm 00076 * calls, rather than being created as named variables. 00077 * 00078 * Two examples taken from the standard itself follow. To perform a 00079 * by-element addition of two vectors @c a and @c b containing @c double, 00080 * and put the result in @c a, use 00081 * \code 00082 * transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>()); 00083 * \endcode 00084 * To negate every element in @c a, use 00085 * \code 00086 * transform(a.begin(), a.end(), a.begin(), negate<double>()); 00087 * \endcode 00088 * The addition and negation functions will be inlined directly. 00089 * 00090 * The standard functors are derived from structs named @c unary_function 00091 * and @c binary_function. These two classes contain nothing but typedefs, 00092 * to aid in generic (template) programming. If you write your own 00093 * functors, you might consider doing the same. 00094 * 00095 * @{ 00096 */ 00097 /** 00098 * This is one of the @link functors functor base classes@endlink. 00099 */ 00100 template<typename _Arg, typename _Result> 00101 struct unary_function 00102 { 00103 /// @c argument_type is the type of the argument 00104 typedef _Arg argument_type; 00105 00106 /// @c result_type is the return type 00107 typedef _Result result_type; 00108 }; 00109 00110 /** 00111 * This is one of the @link functors functor base classes@endlink. 00112 */ 00113 template<typename _Arg1, typename _Arg2, typename _Result> 00114 struct binary_function 00115 { 00116 /// @c first_argument_type is the type of the first argument 00117 typedef _Arg1 first_argument_type; 00118 00119 /// @c second_argument_type is the type of the second argument 00120 typedef _Arg2 second_argument_type; 00121 00122 /// @c result_type is the return type 00123 typedef _Result result_type; 00124 }; 00125 /** @} */ 00126 00127 // 20.3.2 arithmetic 00128 /** @defgroup arithmetic_functors Arithmetic Classes 00129 * @ingroup functors 00130 * 00131 * Because basic math often needs to be done during an algorithm, 00132 * the library provides functors for those operations. See the 00133 * documentation for @link functors the base classes@endlink 00134 * for examples of their use. 00135 * 00136 * @{ 00137 */ 00138 /// One of the @link arithmetic_functors math functors@endlink. 00139 template<typename _Tp> 00140 struct plus : public binary_function<_Tp, _Tp, _Tp> 00141 { 00142 _Tp 00143 operator()(const _Tp& __x, const _Tp& __y) const 00144 { return __x + __y; } 00145 }; 00146 00147 /// One of the @link arithmetic_functors math functors@endlink. 00148 template<typename _Tp> 00149 struct minus : public binary_function<_Tp, _Tp, _Tp> 00150 { 00151 _Tp 00152 operator()(const _Tp& __x, const _Tp& __y) const 00153 { return __x - __y; } 00154 }; 00155 00156 /// One of the @link arithmetic_functors math functors@endlink. 00157 template<typename _Tp> 00158 struct multiplies : public binary_function<_Tp, _Tp, _Tp> 00159 { 00160 _Tp 00161 operator()(const _Tp& __x, const _Tp& __y) const 00162 { return __x * __y; } 00163 }; 00164 00165 /// One of the @link arithmetic_functors math functors@endlink. 00166 template<typename _Tp> 00167 struct divides : public binary_function<_Tp, _Tp, _Tp> 00168 { 00169 _Tp 00170 operator()(const _Tp& __x, const _Tp& __y) const 00171 { return __x / __y; } 00172 }; 00173 00174 /// One of the @link arithmetic_functors math functors@endlink. 00175 template<typename _Tp> 00176 struct modulus : public binary_function<_Tp, _Tp, _Tp> 00177 { 00178 _Tp 00179 operator()(const _Tp& __x, const _Tp& __y) const 00180 { return __x % __y; } 00181 }; 00182 00183 /// One of the @link arithmetic_functors math functors@endlink. 00184 template<typename _Tp> 00185 struct negate : public unary_function<_Tp, _Tp> 00186 { 00187 _Tp 00188 operator()(const _Tp& __x) const 00189 { return -__x; } 00190 }; 00191 /** @} */ 00192 00193 // 20.3.3 comparisons 00194 /** @defgroup comparison_functors Comparison Classes 00195 * @ingroup functors 00196 * 00197 * The library provides six wrapper functors for all the basic comparisons 00198 * in C++, like @c <. 00199 * 00200 * @{ 00201 */ 00202 /// One of the @link comparison_functors comparison functors@endlink. 00203 template<typename _Tp> 00204 struct equal_to : public binary_function<_Tp, _Tp, bool> 00205 { 00206 bool 00207 operator()(const _Tp& __x, const _Tp& __y) const 00208 { return __x == __y; } 00209 }; 00210 00211 /// One of the @link comparison_functors comparison functors@endlink. 00212 template<typename _Tp> 00213 struct not_equal_to : public binary_function<_Tp, _Tp, bool> 00214 { 00215 bool 00216 operator()(const _Tp& __x, const _Tp& __y) const 00217 { return __x != __y; } 00218 }; 00219 00220 /// One of the @link comparison_functors comparison functors@endlink. 00221 template<typename _Tp> 00222 struct greater : public binary_function<_Tp, _Tp, bool> 00223 { 00224 bool 00225 operator()(const _Tp& __x, const _Tp& __y) const 00226 { return __x > __y; } 00227 }; 00228 00229 /// One of the @link comparison_functors comparison functors@endlink. 00230 template<typename _Tp> 00231 struct less : public binary_function<_Tp, _Tp, bool> 00232 { 00233 bool 00234 operator()(const _Tp& __x, const _Tp& __y) const 00235 { return __x < __y; } 00236 }; 00237 00238 /// One of the @link comparison_functors comparison functors@endlink. 00239 template<typename _Tp> 00240 struct greater_equal : public binary_function<_Tp, _Tp, bool> 00241 { 00242 bool 00243 operator()(const _Tp& __x, const _Tp& __y) const 00244 { return __x >= __y; } 00245 }; 00246 00247 /// One of the @link comparison_functors comparison functors@endlink. 00248 template<typename _Tp> 00249 struct less_equal : public binary_function<_Tp, _Tp, bool> 00250 { 00251 bool 00252 operator()(const _Tp& __x, const _Tp& __y) const 00253 { return __x <= __y; } 00254 }; 00255 /** @} */ 00256 00257 // 20.3.4 logical operations 00258 /** @defgroup logical_functors Boolean Operations Classes 00259 * @ingroup functors 00260 * 00261 * Here are wrapper functors for Boolean operations: @c &&, @c ||, 00262 * and @c !. 00263 * 00264 * @{ 00265 */ 00266 /// One of the @link logical_functors Boolean operations functors@endlink. 00267 template<typename _Tp> 00268 struct logical_and : public binary_function<_Tp, _Tp, bool> 00269 { 00270 bool 00271 operator()(const _Tp& __x, const _Tp& __y) const 00272 { return __x && __y; } 00273 }; 00274 00275 /// One of the @link logical_functors Boolean operations functors@endlink. 00276 template<typename _Tp> 00277 struct logical_or : public binary_function<_Tp, _Tp, bool> 00278 { 00279 bool 00280 operator()(const _Tp& __x, const _Tp& __y) const 00281 { return __x || __y; } 00282 }; 00283 00284 /// One of the @link logical_functors Boolean operations functors@endlink. 00285 template<typename _Tp> 00286 struct logical_not : public unary_function<_Tp, bool> 00287 { 00288 bool 00289 operator()(const _Tp& __x) const 00290 { return !__x; } 00291 }; 00292 /** @} */ 00293 00294 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00295 // DR 660. Missing Bitwise Operations. 00296 template<typename _Tp> 00297 struct bit_and : public binary_function<_Tp, _Tp, _Tp> 00298 { 00299 _Tp 00300 operator()(const _Tp& __x, const _Tp& __y) const 00301 { return __x & __y; } 00302 }; 00303 00304 template<typename _Tp> 00305 struct bit_or : public binary_function<_Tp, _Tp, _Tp> 00306 { 00307 _Tp 00308 operator()(const _Tp& __x, const _Tp& __y) const 00309 { return __x | __y; } 00310 }; 00311 00312 template<typename _Tp> 00313 struct bit_xor : public binary_function<_Tp, _Tp, _Tp> 00314 { 00315 _Tp 00316 operator()(const _Tp& __x, const _Tp& __y) const 00317 { return __x ^ __y; } 00318 }; 00319 00320 // 20.3.5 negators 00321 /** @defgroup negators Negators 00322 * @ingroup functors 00323 * 00324 * The functions @c not1 and @c not2 each take a predicate functor 00325 * and return an instance of @c unary_negate or 00326 * @c binary_negate, respectively. These classes are functors whose 00327 * @c operator() performs the stored predicate function and then returns 00328 * the negation of the result. 00329 * 00330 * For example, given a vector of integers and a trivial predicate, 00331 * \code 00332 * struct IntGreaterThanThree 00333 * : public std::unary_function<int, bool> 00334 * { 00335 * bool operator() (int x) { return x > 3; } 00336 * }; 00337 * 00338 * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree())); 00339 * \endcode 00340 * The call to @c find_if will locate the first index (i) of @c v for which 00341 * <code>!(v[i] > 3)</code> is true. 00342 * 00343 * The not1/unary_negate combination works on predicates taking a single 00344 * argument. The not2/binary_negate combination works on predicates which 00345 * take two arguments. 00346 * 00347 * @{ 00348 */ 00349 /// One of the @link negators negation functors@endlink. 00350 template<typename _Predicate> 00351 class unary_negate 00352 : public unary_function<typename _Predicate::argument_type, bool> 00353 { 00354 protected: 00355 _Predicate _M_pred; 00356 00357 public: 00358 explicit 00359 unary_negate(const _Predicate& __x) : _M_pred(__x) { } 00360 00361 bool 00362 operator()(const typename _Predicate::argument_type& __x) const 00363 { return !_M_pred(__x); } 00364 }; 00365 00366 /// One of the @link negators negation functors@endlink. 00367 template<typename _Predicate> 00368 inline unary_negate<_Predicate> 00369 not1(const _Predicate& __pred) 00370 { return unary_negate<_Predicate>(__pred); } 00371 00372 /// One of the @link negators negation functors@endlink. 00373 template<typename _Predicate> 00374 class binary_negate 00375 : public binary_function<typename _Predicate::first_argument_type, 00376 typename _Predicate::second_argument_type, bool> 00377 { 00378 protected: 00379 _Predicate _M_pred; 00380 00381 public: 00382 explicit 00383 binary_negate(const _Predicate& __x) : _M_pred(__x) { } 00384 00385 bool 00386 operator()(const typename _Predicate::first_argument_type& __x, 00387 const typename _Predicate::second_argument_type& __y) const 00388 { return !_M_pred(__x, __y); } 00389 }; 00390 00391 /// One of the @link negators negation functors@endlink. 00392 template<typename _Predicate> 00393 inline binary_negate<_Predicate> 00394 not2(const _Predicate& __pred) 00395 { return binary_negate<_Predicate>(__pred); } 00396 /** @} */ 00397 00398 // 20.3.7 adaptors pointers functions 00399 /** @defgroup pointer_adaptors Adaptors for pointers to functions 00400 * @ingroup functors 00401 * 00402 * The advantage of function objects over pointers to functions is that 00403 * the objects in the standard library declare nested typedefs describing 00404 * their argument and result types with uniform names (e.g., @c result_type 00405 * from the base classes @c unary_function and @c binary_function). 00406 * Sometimes those typedefs are required, not just optional. 00407 * 00408 * Adaptors are provided to turn pointers to unary (single-argument) and 00409 * binary (double-argument) functions into function objects. The 00410 * long-winded functor @c pointer_to_unary_function is constructed with a 00411 * function pointer @c f, and its @c operator() called with argument @c x 00412 * returns @c f(x). The functor @c pointer_to_binary_function does the same 00413 * thing, but with a double-argument @c f and @c operator(). 00414 * 00415 * The function @c ptr_fun takes a pointer-to-function @c f and constructs 00416 * an instance of the appropriate functor. 00417 * 00418 * @{ 00419 */ 00420 /// One of the @link pointer_adaptors adaptors for function pointers@endlink. 00421 template<typename _Arg, typename _Result> 00422 class pointer_to_unary_function : public unary_function<_Arg, _Result> 00423 { 00424 protected: 00425 _Result (*_M_ptr)(_Arg); 00426 00427 public: 00428 pointer_to_unary_function() { } 00429 00430 explicit 00431 pointer_to_unary_function(_Result (*__x)(_Arg)) 00432 : _M_ptr(__x) { } 00433 00434 _Result 00435 operator()(_Arg __x) const 00436 { return _M_ptr(__x); } 00437 }; 00438 00439 /// One of the @link pointer_adaptors adaptors for function pointers@endlink. 00440 template<typename _Arg, typename _Result> 00441 inline pointer_to_unary_function<_Arg, _Result> 00442 ptr_fun(_Result (*__x)(_Arg)) 00443 { return pointer_to_unary_function<_Arg, _Result>(__x); } 00444 00445 /// One of the @link pointer_adaptors adaptors for function pointers@endlink. 00446 template<typename _Arg1, typename _Arg2, typename _Result> 00447 class pointer_to_binary_function 00448 : public binary_function<_Arg1, _Arg2, _Result> 00449 { 00450 protected: 00451 _Result (*_M_ptr)(_Arg1, _Arg2); 00452 00453 public: 00454 pointer_to_binary_function() { } 00455 00456 explicit 00457 pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) 00458 : _M_ptr(__x) { } 00459 00460 _Result 00461 operator()(_Arg1 __x, _Arg2 __y) const 00462 { return _M_ptr(__x, __y); } 00463 }; 00464 00465 /// One of the @link pointer_adaptors adaptors for function pointers@endlink. 00466 template<typename _Arg1, typename _Arg2, typename _Result> 00467 inline pointer_to_binary_function<_Arg1, _Arg2, _Result> 00468 ptr_fun(_Result (*__x)(_Arg1, _Arg2)) 00469 { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); } 00470 /** @} */ 00471 00472 template<typename _Tp> 00473 struct _Identity 00474 : 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 00487 : public unary_function<_Pair, 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 #if __cplusplus >= 201103L 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 00512 : public unary_function<_Pair, 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 (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED 00731 # include <backward/binders.h> 00732 #endif 00733 00734 #endif /* _STL_FUNCTION_H */