2005-12-18 Benjamin Kosnik <bkoz@redhat.com>
[official-gcc.git] / libstdc++-v3 / include / bits / stl_function.h
blobdb213dc0a925996e28dea009909d357554230f48
1 // Functor implementations -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
32 * Copyright (c) 1994
33 * Hewlett-Packard Company
35 * Permission to use, copy, modify, distribute and sell this software
36 * and its documentation for any purpose is hereby granted without fee,
37 * provided that the above copyright notice appear in all copies and
38 * that both that copyright notice and this permission notice appear
39 * in supporting documentation. Hewlett-Packard Company makes no
40 * representations about the suitability of this software for any
41 * purpose. It is provided "as is" without express or implied warranty.
44 * Copyright (c) 1996-1998
45 * Silicon Graphics Computer Systems, Inc.
47 * Permission to use, copy, modify, distribute and sell this software
48 * and its documentation for any purpose is hereby granted without fee,
49 * provided that the above copyright notice appear in all copies and
50 * that both that copyright notice and this permission notice appear
51 * in supporting documentation. Silicon Graphics makes no
52 * representations about the suitability of this software for any
53 * purpose. It is provided "as is" without express or implied warranty.
56 /** @file stl_function.h
57 * This is an internal header file, included by other library headers.
58 * You should not attempt to use it directly.
61 #ifndef _FUNCTION_H
62 #define _FUNCTION_H 1
64 _GLIBCXX_BEGIN_NAMESPACE(std)
66 // 20.3.1 base classes
67 /** @defgroup s20_3_1_base Functor Base Classes
68 * Function objects, or @e functors, are objects with an @c operator()
69 * defined and accessible. They can be passed as arguments to algorithm
70 * templates and used in place of a function pointer. Not only is the
71 * resulting expressiveness of the library increased, but the generated
72 * code can be more efficient than what you might write by hand. When we
73 * refer to "functors," then, generally we include function pointers in
74 * the description as well.
76 * Often, functors are only created as temporaries passed to algorithm
77 * calls, rather than being created as named variables.
79 * Two examples taken from the standard itself follow. To perform a
80 * by-element addition of two vectors @c a and @c b containing @c double,
81 * and put the result in @c a, use
82 * \code
83 * transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
84 * \endcode
85 * To negate every element in @c a, use
86 * \code
87 * transform(a.begin(), a.end(), a.begin(), negate<double>());
88 * \endcode
89 * The addition and negation functions will be inlined directly.
91 * The standard functors are derived from structs named @c unary_function
92 * and @c binary_function. These two classes contain nothing but typedefs,
93 * to aid in generic (template) programming. If you write your own
94 * functors, you might consider doing the same.
96 * @{
98 /**
99 * This is one of the @link s20_3_1_base functor base classes@endlink.
101 template <class _Arg, class _Result>
102 struct unary_function
104 typedef _Arg argument_type; ///< @c argument_type is the type of the
105 /// argument (no surprises here)
107 typedef _Result result_type; ///< @c result_type is the return type
111 * This is one of the @link s20_3_1_base functor base classes@endlink.
113 template <class _Arg1, class _Arg2, class _Result>
114 struct binary_function
116 typedef _Arg1 first_argument_type; ///< the type of the first argument
117 /// (no surprises here)
119 typedef _Arg2 second_argument_type; ///< the type of the second argument
120 typedef _Result result_type; ///< type of the return type
122 /** @} */
124 // 20.3.2 arithmetic
125 /** @defgroup s20_3_2_arithmetic Arithmetic Classes
126 * Because basic math often needs to be done during an algorithm, the library
127 * provides functors for those operations. See the documentation for
128 * @link s20_3_1_base the base classes@endlink for examples of their use.
130 * @{
132 /// One of the @link s20_3_2_arithmetic math functors@endlink.
133 template <class _Tp>
134 struct plus : public binary_function<_Tp, _Tp, _Tp>
137 operator()(const _Tp& __x, const _Tp& __y) const
138 { return __x + __y; }
141 /// One of the @link s20_3_2_arithmetic math functors@endlink.
142 template <class _Tp>
143 struct minus : public binary_function<_Tp, _Tp, _Tp>
146 operator()(const _Tp& __x, const _Tp& __y) const
147 { return __x - __y; }
150 /// One of the @link s20_3_2_arithmetic math functors@endlink.
151 template <class _Tp>
152 struct multiplies : public binary_function<_Tp, _Tp, _Tp>
155 operator()(const _Tp& __x, const _Tp& __y) const
156 { return __x * __y; }
159 /// One of the @link s20_3_2_arithmetic math functors@endlink.
160 template <class _Tp>
161 struct divides : public binary_function<_Tp, _Tp, _Tp>
164 operator()(const _Tp& __x, const _Tp& __y) const
165 { return __x / __y; }
168 /// One of the @link s20_3_2_arithmetic math functors@endlink.
169 template <class _Tp>
170 struct modulus : public binary_function<_Tp, _Tp, _Tp>
173 operator()(const _Tp& __x, const _Tp& __y) const
174 { return __x % __y; }
177 /// One of the @link s20_3_2_arithmetic math functors@endlink.
178 template <class _Tp>
179 struct negate : public unary_function<_Tp, _Tp>
182 operator()(const _Tp& __x) const
183 { return -__x; }
185 /** @} */
187 // 20.3.3 comparisons
188 /** @defgroup s20_3_3_comparisons Comparison Classes
189 * The library provides six wrapper functors for all the basic comparisons
190 * in C++, like @c <.
192 * @{
194 /// One of the @link s20_3_3_comparisons comparison functors@endlink.
195 template <class _Tp>
196 struct equal_to : public binary_function<_Tp, _Tp, bool>
198 bool
199 operator()(const _Tp& __x, const _Tp& __y) const
200 { return __x == __y; }
203 /// One of the @link s20_3_3_comparisons comparison functors@endlink.
204 template <class _Tp>
205 struct not_equal_to : public binary_function<_Tp, _Tp, bool>
207 bool
208 operator()(const _Tp& __x, const _Tp& __y) const
209 { return __x != __y; }
212 /// One of the @link s20_3_3_comparisons comparison functors@endlink.
213 template <class _Tp>
214 struct greater : public binary_function<_Tp, _Tp, bool>
216 bool
217 operator()(const _Tp& __x, const _Tp& __y) const
218 { return __x > __y; }
221 /// One of the @link s20_3_3_comparisons comparison functors@endlink.
222 template <class _Tp>
223 struct less : public binary_function<_Tp, _Tp, bool>
225 bool
226 operator()(const _Tp& __x, const _Tp& __y) const
227 { return __x < __y; }
230 /// One of the @link s20_3_3_comparisons comparison functors@endlink.
231 template <class _Tp>
232 struct greater_equal : public binary_function<_Tp, _Tp, bool>
234 bool
235 operator()(const _Tp& __x, const _Tp& __y) const
236 { return __x >= __y; }
239 /// One of the @link s20_3_3_comparisons comparison functors@endlink.
240 template <class _Tp>
241 struct less_equal : public binary_function<_Tp, _Tp, bool>
243 bool
244 operator()(const _Tp& __x, const _Tp& __y) const
245 { return __x <= __y; }
247 /** @} */
249 // 20.3.4 logical operations
250 /** @defgroup s20_3_4_logical Boolean Operations Classes
251 * Here are wrapper functors for Boolean operations: @c &&, @c ||, and @c !.
253 * @{
255 /// One of the @link s20_3_4_logical Boolean operations functors@endlink.
256 template <class _Tp>
257 struct logical_and : public binary_function<_Tp, _Tp, bool>
259 bool
260 operator()(const _Tp& __x, const _Tp& __y) const
261 { return __x && __y; }
264 /// One of the @link s20_3_4_logical Boolean operations functors@endlink.
265 template <class _Tp>
266 struct logical_or : public binary_function<_Tp, _Tp, bool>
268 bool
269 operator()(const _Tp& __x, const _Tp& __y) const
270 { return __x || __y; }
273 /// One of the @link s20_3_4_logical Boolean operations functors@endlink.
274 template <class _Tp>
275 struct logical_not : public unary_function<_Tp, bool>
277 bool
278 operator()(const _Tp& __x) const
279 { return !__x; }
281 /** @} */
283 // 20.3.5 negators
284 /** @defgroup s20_3_5_negators Negators
285 * The functions @c not1 and @c not2 each take a predicate functor
286 * and return an instance of @c unary_negate or
287 * @c binary_negate, respectively. These classes are functors whose
288 * @c operator() performs the stored predicate function and then returns
289 * the negation of the result.
291 * For example, given a vector of integers and a trivial predicate,
292 * \code
293 * struct IntGreaterThanThree
294 * : public std::unary_function<int, bool>
296 * bool operator() (int x) { return x > 3; }
297 * };
299 * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
300 * \endcode
301 * The call to @c find_if will locate the first index (i) of @c v for which
302 * "!(v[i] > 3)" is true.
304 * The not1/unary_negate combination works on predicates taking a single
305 * argument. The not2/binary_negate combination works on predicates which
306 * take two arguments.
308 * @{
310 /// One of the @link s20_3_5_negators negation functors@endlink.
311 template <class _Predicate>
312 class unary_negate
313 : public unary_function<typename _Predicate::argument_type, bool>
315 protected:
316 _Predicate _M_pred;
317 public:
318 explicit
319 unary_negate(const _Predicate& __x) : _M_pred(__x) {}
321 bool
322 operator()(const typename _Predicate::argument_type& __x) const
323 { return !_M_pred(__x); }
326 /// One of the @link s20_3_5_negators negation functors@endlink.
327 template <class _Predicate>
328 inline unary_negate<_Predicate>
329 not1(const _Predicate& __pred)
330 { return unary_negate<_Predicate>(__pred); }
332 /// One of the @link s20_3_5_negators negation functors@endlink.
333 template <class _Predicate>
334 class binary_negate
335 : public binary_function<typename _Predicate::first_argument_type,
336 typename _Predicate::second_argument_type,
337 bool>
339 protected:
340 _Predicate _M_pred;
341 public:
342 explicit
343 binary_negate(const _Predicate& __x)
344 : _M_pred(__x) { }
346 bool
347 operator()(const typename _Predicate::first_argument_type& __x,
348 const typename _Predicate::second_argument_type& __y) const
349 { return !_M_pred(__x, __y); }
352 /// One of the @link s20_3_5_negators negation functors@endlink.
353 template <class _Predicate>
354 inline binary_negate<_Predicate>
355 not2(const _Predicate& __pred)
356 { return binary_negate<_Predicate>(__pred); }
357 /** @} */
359 // 20.3.6 binders
360 /** @defgroup s20_3_6_binder Binder Classes
361 * Binders turn functions/functors with two arguments into functors with
362 * a single argument, storing an argument to be applied later. For
363 * example, a variable @c B of type @c binder1st is constructed from a
364 * functor @c f and an argument @c x. Later, B's @c operator() is called
365 * with a single argument @c y. The return value is the value of @c f(x,y).
366 * @c B can be "called" with various arguments (y1, y2, ...) and will in
367 * turn call @c f(x,y1), @c f(x,y2), ...
369 * The function @c bind1st is provided to save some typing. It takes the
370 * function and an argument as parameters, and returns an instance of
371 * @c binder1st.
373 * The type @c binder2nd and its creator function @c bind2nd do the same
374 * thing, but the stored argument is passed as the second parameter instead
375 * of the first, e.g., @c bind2nd(std::minus<float>,1.3) will create a
376 * functor whose @c operator() accepts a floating-point number, subtracts
377 * 1.3 from it, and returns the result. (If @c bind1st had been used,
378 * the functor would perform "1.3 - x" instead.
380 * Creator-wrapper functions like @c bind1st are intended to be used in
381 * calling algorithms. Their return values will be temporary objects.
382 * (The goal is to not require you to type names like
383 * @c std::binder1st<std::plus<int>> for declaring a variable to hold the
384 * return value from @c bind1st(std::plus<int>,5).
386 * These become more useful when combined with the composition functions.
388 * @{
390 /// One of the @link s20_3_6_binder binder functors@endlink.
391 template <class _Operation>
392 class binder1st
393 : public unary_function<typename _Operation::second_argument_type,
394 typename _Operation::result_type>
396 protected:
397 _Operation op;
398 typename _Operation::first_argument_type value;
399 public:
400 binder1st(const _Operation& __x,
401 const typename _Operation::first_argument_type& __y)
402 : op(__x), value(__y) {}
404 typename _Operation::result_type
405 operator()(const typename _Operation::second_argument_type& __x) const
406 { return op(value, __x); }
408 // _GLIBCXX_RESOLVE_LIB_DEFECTS
409 // 109. Missing binders for non-const sequence elements
410 typename _Operation::result_type
411 operator()(typename _Operation::second_argument_type& __x) const
412 { return op(value, __x); }
415 /// One of the @link s20_3_6_binder binder functors@endlink.
416 template <class _Operation, class _Tp>
417 inline binder1st<_Operation>
418 bind1st(const _Operation& __fn, const _Tp& __x)
420 typedef typename _Operation::first_argument_type _Arg1_type;
421 return binder1st<_Operation>(__fn, _Arg1_type(__x));
424 /// One of the @link s20_3_6_binder binder functors@endlink.
425 template <class _Operation>
426 class binder2nd
427 : public unary_function<typename _Operation::first_argument_type,
428 typename _Operation::result_type>
430 protected:
431 _Operation op;
432 typename _Operation::second_argument_type value;
433 public:
434 binder2nd(const _Operation& __x,
435 const typename _Operation::second_argument_type& __y)
436 : op(__x), value(__y) {}
438 typename _Operation::result_type
439 operator()(const typename _Operation::first_argument_type& __x) const
440 { return op(__x, value); }
442 // _GLIBCXX_RESOLVE_LIB_DEFECTS
443 // 109. Missing binders for non-const sequence elements
444 typename _Operation::result_type
445 operator()(typename _Operation::first_argument_type& __x) const
446 { return op(__x, value); }
449 /// One of the @link s20_3_6_binder binder functors@endlink.
450 template <class _Operation, class _Tp>
451 inline binder2nd<_Operation>
452 bind2nd(const _Operation& __fn, const _Tp& __x)
454 typedef typename _Operation::second_argument_type _Arg2_type;
455 return binder2nd<_Operation>(__fn, _Arg2_type(__x));
457 /** @} */
459 // 20.3.7 adaptors pointers functions
460 /** @defgroup s20_3_7_adaptors Adaptors for pointers to functions
461 * The advantage of function objects over pointers to functions is that
462 * the objects in the standard library declare nested typedefs describing
463 * their argument and result types with uniform names (e.g., @c result_type
464 * from the base classes @c unary_function and @c binary_function).
465 * Sometimes those typedefs are required, not just optional.
467 * Adaptors are provided to turn pointers to unary (single-argument) and
468 * binary (double-argument) functions into function objects. The
469 * long-winded functor @c pointer_to_unary_function is constructed with a
470 * function pointer @c f, and its @c operator() called with argument @c x
471 * returns @c f(x). The functor @c pointer_to_binary_function does the same
472 * thing, but with a double-argument @c f and @c operator().
474 * The function @c ptr_fun takes a pointer-to-function @c f and constructs
475 * an instance of the appropriate functor.
477 * @{
479 /// One of the @link s20_3_7_adaptors adaptors for function pointers@endlink.
480 template <class _Arg, class _Result>
481 class pointer_to_unary_function : public unary_function<_Arg, _Result>
483 protected:
484 _Result (*_M_ptr)(_Arg);
485 public:
486 pointer_to_unary_function() {}
488 explicit
489 pointer_to_unary_function(_Result (*__x)(_Arg))
490 : _M_ptr(__x) {}
492 _Result
493 operator()(_Arg __x) const
494 { return _M_ptr(__x); }
497 /// One of the @link s20_3_7_adaptors adaptors for function pointers@endlink.
498 template <class _Arg, class _Result>
499 inline pointer_to_unary_function<_Arg, _Result>
500 ptr_fun(_Result (*__x)(_Arg))
501 { return pointer_to_unary_function<_Arg, _Result>(__x); }
503 /// One of the @link s20_3_7_adaptors adaptors for function pointers@endlink.
504 template <class _Arg1, class _Arg2, class _Result>
505 class pointer_to_binary_function
506 : public binary_function<_Arg1, _Arg2, _Result>
508 protected:
509 _Result (*_M_ptr)(_Arg1, _Arg2);
510 public:
511 pointer_to_binary_function() {}
513 explicit
514 pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
515 : _M_ptr(__x) {}
517 _Result
518 operator()(_Arg1 __x, _Arg2 __y) const
519 { return _M_ptr(__x, __y); }
522 /// One of the @link s20_3_7_adaptors adaptors for function pointers@endlink.
523 template <class _Arg1, class _Arg2, class _Result>
524 inline pointer_to_binary_function<_Arg1, _Arg2, _Result>
525 ptr_fun(_Result (*__x)(_Arg1, _Arg2))
526 { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); }
527 /** @} */
529 template <class _Tp>
530 struct _Identity : public unary_function<_Tp,_Tp>
532 _Tp&
533 operator()(_Tp& __x) const
534 { return __x; }
536 const _Tp&
537 operator()(const _Tp& __x) const
538 { return __x; }
541 template <class _Pair>
542 struct _Select1st : public unary_function<_Pair,
543 typename _Pair::first_type>
545 typename _Pair::first_type&
546 operator()(_Pair& __x) const
547 { return __x.first; }
549 const typename _Pair::first_type&
550 operator()(const _Pair& __x) const
551 { return __x.first; }
554 template <class _Pair>
555 struct _Select2nd : public unary_function<_Pair,
556 typename _Pair::second_type>
558 typename _Pair::second_type&
559 operator()(_Pair& __x) const
560 { return __x.second; }
562 const typename _Pair::second_type&
563 operator()(const _Pair& __x) const
564 { return __x.second; }
567 // 20.3.8 adaptors pointers members
568 /** @defgroup s20_3_8_memadaptors Adaptors for pointers to members
569 * There are a total of 8 = 2^3 function objects in this family.
570 * (1) Member functions taking no arguments vs member functions taking
571 * one argument.
572 * (2) Call through pointer vs call through reference.
573 * (3) Const vs non-const member function.
575 * All of this complexity is in the function objects themselves. You can
576 * ignore it by using the helper function mem_fun and mem_fun_ref,
577 * which create whichever type of adaptor is appropriate.
579 * @{
581 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
582 template <class _Ret, class _Tp>
583 class mem_fun_t : public unary_function<_Tp*, _Ret>
585 public:
586 explicit
587 mem_fun_t(_Ret (_Tp::*__pf)())
588 : _M_f(__pf) {}
590 _Ret
591 operator()(_Tp* __p) const
592 { return (__p->*_M_f)(); }
593 private:
594 _Ret (_Tp::*_M_f)();
597 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
598 template <class _Ret, class _Tp>
599 class const_mem_fun_t : public unary_function<const _Tp*, _Ret>
601 public:
602 explicit
603 const_mem_fun_t(_Ret (_Tp::*__pf)() const)
604 : _M_f(__pf) {}
606 _Ret
607 operator()(const _Tp* __p) const
608 { return (__p->*_M_f)(); }
609 private:
610 _Ret (_Tp::*_M_f)() const;
613 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
614 template <class _Ret, class _Tp>
615 class mem_fun_ref_t : public unary_function<_Tp, _Ret>
617 public:
618 explicit
619 mem_fun_ref_t(_Ret (_Tp::*__pf)())
620 : _M_f(__pf) {}
622 _Ret
623 operator()(_Tp& __r) const
624 { return (__r.*_M_f)(); }
625 private:
626 _Ret (_Tp::*_M_f)();
629 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
630 template <class _Ret, class _Tp>
631 class const_mem_fun_ref_t : public unary_function<_Tp, _Ret>
633 public:
634 explicit
635 const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
636 : _M_f(__pf) {}
638 _Ret
639 operator()(const _Tp& __r) const
640 { return (__r.*_M_f)(); }
641 private:
642 _Ret (_Tp::*_M_f)() const;
645 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
646 template <class _Ret, class _Tp, class _Arg>
647 class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret>
649 public:
650 explicit
651 mem_fun1_t(_Ret (_Tp::*__pf)(_Arg))
652 : _M_f(__pf) {}
654 _Ret
655 operator()(_Tp* __p, _Arg __x) const
656 { return (__p->*_M_f)(__x); }
657 private:
658 _Ret (_Tp::*_M_f)(_Arg);
661 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
662 template <class _Ret, class _Tp, class _Arg>
663 class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret>
665 public:
666 explicit
667 const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
668 : _M_f(__pf) {}
670 _Ret
671 operator()(const _Tp* __p, _Arg __x) const
672 { return (__p->*_M_f)(__x); }
673 private:
674 _Ret (_Tp::*_M_f)(_Arg) const;
677 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
678 template <class _Ret, class _Tp, class _Arg>
679 class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
681 public:
682 explicit
683 mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg))
684 : _M_f(__pf) {}
686 _Ret
687 operator()(_Tp& __r, _Arg __x) const
688 { return (__r.*_M_f)(__x); }
689 private:
690 _Ret (_Tp::*_M_f)(_Arg);
693 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
694 template <class _Ret, class _Tp, class _Arg>
695 class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
697 public:
698 explicit
699 const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
700 : _M_f(__pf) {}
702 _Ret
703 operator()(const _Tp& __r, _Arg __x) const
704 { return (__r.*_M_f)(__x); }
705 private:
706 _Ret (_Tp::*_M_f)(_Arg) const;
709 // Mem_fun adaptor helper functions. There are only two:
710 // mem_fun and mem_fun_ref.
711 template <class _Ret, class _Tp>
712 inline mem_fun_t<_Ret, _Tp>
713 mem_fun(_Ret (_Tp::*__f)())
714 { return mem_fun_t<_Ret, _Tp>(__f); }
716 template <class _Ret, class _Tp>
717 inline const_mem_fun_t<_Ret, _Tp>
718 mem_fun(_Ret (_Tp::*__f)() const)
719 { return const_mem_fun_t<_Ret, _Tp>(__f); }
721 template <class _Ret, class _Tp>
722 inline mem_fun_ref_t<_Ret, _Tp>
723 mem_fun_ref(_Ret (_Tp::*__f)())
724 { return mem_fun_ref_t<_Ret, _Tp>(__f); }
726 template <class _Ret, class _Tp>
727 inline const_mem_fun_ref_t<_Ret, _Tp>
728 mem_fun_ref(_Ret (_Tp::*__f)() const)
729 { return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
731 template <class _Ret, class _Tp, class _Arg>
732 inline mem_fun1_t<_Ret, _Tp, _Arg>
733 mem_fun(_Ret (_Tp::*__f)(_Arg))
734 { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
736 template <class _Ret, class _Tp, class _Arg>
737 inline const_mem_fun1_t<_Ret, _Tp, _Arg>
738 mem_fun(_Ret (_Tp::*__f)(_Arg) const)
739 { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
741 template <class _Ret, class _Tp, class _Arg>
742 inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
743 mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
744 { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
746 template <class _Ret, class _Tp, class _Arg>
747 inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
748 mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
749 { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
751 /** @} */
753 _GLIBCXX_END_NAMESPACE
755 #endif /* _FUNCTION_H */