1 // Functor implementations -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
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)
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
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.
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.
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
83 * transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
85 * To negate every element in @c a, use
87 * transform(a.begin(), a.end(), a.begin(), negate<double>());
89 * The addition and negation functions will be inlined directly.
91 * The standard functiors 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.
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
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.
132 /// One of the @link s20_3_2_arithmetic math functors@endlink.
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.
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.
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.
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.
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.
179 struct negate
: public unary_function
<_Tp
, _Tp
>
182 operator()(const _Tp
& __x
) const
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
194 /// One of the @link s20_3_3_comparisons comparison functors@endlink.
196 struct equal_to
: public binary_function
<_Tp
, _Tp
, 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.
205 struct not_equal_to
: public binary_function
<_Tp
, _Tp
, 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.
214 struct greater
: public binary_function
<_Tp
, _Tp
, 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.
223 struct less
: public binary_function
<_Tp
, _Tp
, 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.
232 struct greater_equal
: public binary_function
<_Tp
, _Tp
, 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.
241 struct less_equal
: public binary_function
<_Tp
, _Tp
, bool>
244 operator()(const _Tp
& __x
, const _Tp
& __y
) const
245 { return __x
<= __y
; }
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 !.
255 /// One of the @link s20_3_4_logical Boolean operations functors@endlink.
257 struct logical_and
: public binary_function
<_Tp
, _Tp
, 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.
266 struct logical_or
: public binary_function
<_Tp
, _Tp
, 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.
275 struct logical_not
: public unary_function
<_Tp
, bool>
278 operator()(const _Tp
& __x
) const
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,
293 * struct IntGreaterThanThree
294 * : public std::unary_function<int, bool>
296 * bool operator() (int x) { return x > 3; }
299 * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
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.
310 /// One of the @link s20_3_5_negators negation functors@endlink.
311 template <class _Predicate
>
313 : public unary_function
<typename
_Predicate::argument_type
, bool>
319 unary_negate(const _Predicate
& __x
) : _M_pred(__x
) {}
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
>
335 : public binary_function
<typename
_Predicate::first_argument_type
,
336 typename
_Predicate::second_argument_type
,
343 binary_negate(const _Predicate
& __x
)
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
); }
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, an 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
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.
390 /// One of the @link s20_3_6_binder binder functors@endlink.
391 template <class _Operation
>
393 : public unary_function
<typename
_Operation::second_argument_type
,
394 typename
_Operation::result_type
>
398 typename
_Operation::first_argument_type value
;
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
>
427 : public unary_function
<typename
_Operation::first_argument_type
,
428 typename
_Operation::result_type
>
432 typename
_Operation::second_argument_type value
;
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
));
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.
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
>
484 _Result (*_M_ptr
)(_Arg
);
486 pointer_to_unary_function() {}
489 pointer_to_unary_function(_Result (*__x
)(_Arg
))
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
>
509 _Result (*_M_ptr
)(_Arg1
, _Arg2
);
511 pointer_to_binary_function() {}
514 pointer_to_binary_function(_Result (*__x
)(_Arg1
, _Arg2
))
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
); }
530 struct _Identity
: public unary_function
<_Tp
,_Tp
>
533 operator()(_Tp
& __x
) const
537 operator()(const _Tp
& __x
) const
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 16 = 2^4 function objects in this family.
570 * (1) Member functions taking no arguments vs member functions taking
572 * (2) Call through pointer vs call through reference.
573 * (3) Member function with void return type vs member function with
574 * non-void return type.
575 * (4) Const vs non-const member function.
577 * Note that choice (3) is nothing more than a workaround: according
578 * to the draft, compilers should handle void and non-void the same way.
579 * This feature is not yet widely implemented, though. You can only use
580 * member functions returning void if your compiler supports partial
583 * All of this complexity is in the function objects themselves. You can
584 * ignore it by using the helper function mem_fun and mem_fun_ref,
585 * which create whichever type of adaptor is appropriate.
589 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
590 template <class _Ret
, class _Tp
>
591 class mem_fun_t
: public unary_function
<_Tp
*, _Ret
>
595 mem_fun_t(_Ret (_Tp::*__pf
)())
599 operator()(_Tp
* __p
) const
600 { return (__p
->*_M_f
)(); }
605 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
606 template <class _Ret
, class _Tp
>
607 class const_mem_fun_t
: public unary_function
<const _Tp
*, _Ret
>
611 const_mem_fun_t(_Ret (_Tp::*__pf
)() const)
615 operator()(const _Tp
* __p
) const
616 { return (__p
->*_M_f
)(); }
618 _Ret (_Tp::*_M_f
)() const;
621 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
622 template <class _Ret
, class _Tp
>
623 class mem_fun_ref_t
: public unary_function
<_Tp
, _Ret
>
627 mem_fun_ref_t(_Ret (_Tp::*__pf
)())
631 operator()(_Tp
& __r
) const
632 { return (__r
.*_M_f
)(); }
637 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
638 template <class _Ret
, class _Tp
>
639 class const_mem_fun_ref_t
: public unary_function
<_Tp
, _Ret
>
643 const_mem_fun_ref_t(_Ret (_Tp::*__pf
)() const)
647 operator()(const _Tp
& __r
) const
648 { return (__r
.*_M_f
)(); }
650 _Ret (_Tp::*_M_f
)() const;
653 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
654 template <class _Ret
, class _Tp
, class _Arg
>
655 class mem_fun1_t
: public binary_function
<_Tp
*, _Arg
, _Ret
>
659 mem_fun1_t(_Ret (_Tp::*__pf
)(_Arg
))
663 operator()(_Tp
* __p
, _Arg __x
) const
664 { return (__p
->*_M_f
)(__x
); }
666 _Ret (_Tp::*_M_f
)(_Arg
);
669 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
670 template <class _Ret
, class _Tp
, class _Arg
>
671 class const_mem_fun1_t
: public binary_function
<const _Tp
*, _Arg
, _Ret
>
675 const_mem_fun1_t(_Ret (_Tp::*__pf
)(_Arg
) const)
679 operator()(const _Tp
* __p
, _Arg __x
) const
680 { return (__p
->*_M_f
)(__x
); }
682 _Ret (_Tp::*_M_f
)(_Arg
) const;
685 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
686 template <class _Ret
, class _Tp
, class _Arg
>
687 class mem_fun1_ref_t
: public binary_function
<_Tp
, _Arg
, _Ret
>
691 mem_fun1_ref_t(_Ret (_Tp::*__pf
)(_Arg
))
695 operator()(_Tp
& __r
, _Arg __x
) const
696 { return (__r
.*_M_f
)(__x
); }
698 _Ret (_Tp::*_M_f
)(_Arg
);
701 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
702 template <class _Ret
, class _Tp
, class _Arg
>
703 class const_mem_fun1_ref_t
: public binary_function
<_Tp
, _Arg
, _Ret
>
707 const_mem_fun1_ref_t(_Ret (_Tp::*__pf
)(_Arg
) const)
711 operator()(const _Tp
& __r
, _Arg __x
) const
712 { return (__r
.*_M_f
)(__x
); }
714 _Ret (_Tp::*_M_f
)(_Arg
) const;
717 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
719 class mem_fun_t
<void, _Tp
> : public unary_function
<_Tp
*, void>
723 mem_fun_t(void (_Tp::*__pf
)())
727 operator()(_Tp
* __p
) const
733 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
735 class const_mem_fun_t
<void, _Tp
> : public unary_function
<const _Tp
*, void>
739 const_mem_fun_t(void (_Tp::*__pf
)() const)
743 operator()(const _Tp
* __p
) const
746 void (_Tp::*_M_f
)() const;
749 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
751 class mem_fun_ref_t
<void, _Tp
> : public unary_function
<_Tp
, void>
755 mem_fun_ref_t(void (_Tp::*__pf
)())
759 operator()(_Tp
& __r
) const
765 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
767 class const_mem_fun_ref_t
<void, _Tp
> : public unary_function
<_Tp
, void>
771 const_mem_fun_ref_t(void (_Tp::*__pf
)() const)
775 operator()(const _Tp
& __r
) const
778 void (_Tp::*_M_f
)() const;
781 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
782 template <class _Tp
, class _Arg
>
783 class mem_fun1_t
<void, _Tp
, _Arg
> : public binary_function
<_Tp
*, _Arg
, void>
787 mem_fun1_t(void (_Tp::*__pf
)(_Arg
))
791 operator()(_Tp
* __p
, _Arg __x
) const
792 { (__p
->*_M_f
)(__x
); }
794 void (_Tp::*_M_f
)(_Arg
);
797 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
798 template <class _Tp
, class _Arg
>
799 class const_mem_fun1_t
<void, _Tp
, _Arg
>
800 : public binary_function
<const _Tp
*, _Arg
, void>
804 const_mem_fun1_t(void (_Tp::*__pf
)(_Arg
) const)
808 operator()(const _Tp
* __p
, _Arg __x
) const
809 { (__p
->*_M_f
)(__x
); }
811 void (_Tp::*_M_f
)(_Arg
) const;
814 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
815 template <class _Tp
, class _Arg
>
816 class mem_fun1_ref_t
<void, _Tp
, _Arg
>
817 : public binary_function
<_Tp
, _Arg
, void>
821 mem_fun1_ref_t(void (_Tp::*__pf
)(_Arg
))
825 operator()(_Tp
& __r
, _Arg __x
) const
826 { (__r
.*_M_f
)(__x
); }
828 void (_Tp::*_M_f
)(_Arg
);
831 /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink.
832 template <class _Tp
, class _Arg
>
833 class const_mem_fun1_ref_t
<void, _Tp
, _Arg
>
834 : public binary_function
<_Tp
, _Arg
, void>
838 const_mem_fun1_ref_t(void (_Tp::*__pf
)(_Arg
) const)
842 operator()(const _Tp
& __r
, _Arg __x
) const
843 { (__r
.*_M_f
)(__x
); }
845 void (_Tp::*_M_f
)(_Arg
) const;
848 // Mem_fun adaptor helper functions. There are only two:
849 // mem_fun and mem_fun_ref.
850 template <class _Ret
, class _Tp
>
851 inline mem_fun_t
<_Ret
, _Tp
>
852 mem_fun(_Ret (_Tp::*__f
)())
853 { return mem_fun_t
<_Ret
, _Tp
>(__f
); }
855 template <class _Ret
, class _Tp
>
856 inline const_mem_fun_t
<_Ret
, _Tp
>
857 mem_fun(_Ret (_Tp::*__f
)() const)
858 { return const_mem_fun_t
<_Ret
, _Tp
>(__f
); }
860 template <class _Ret
, class _Tp
>
861 inline mem_fun_ref_t
<_Ret
, _Tp
>
862 mem_fun_ref(_Ret (_Tp::*__f
)())
863 { return mem_fun_ref_t
<_Ret
, _Tp
>(__f
); }
865 template <class _Ret
, class _Tp
>
866 inline const_mem_fun_ref_t
<_Ret
, _Tp
>
867 mem_fun_ref(_Ret (_Tp::*__f
)() const)
868 { return const_mem_fun_ref_t
<_Ret
, _Tp
>(__f
); }
870 template <class _Ret
, class _Tp
, class _Arg
>
871 inline mem_fun1_t
<_Ret
, _Tp
, _Arg
>
872 mem_fun(_Ret (_Tp::*__f
)(_Arg
))
873 { return mem_fun1_t
<_Ret
, _Tp
, _Arg
>(__f
); }
875 template <class _Ret
, class _Tp
, class _Arg
>
876 inline const_mem_fun1_t
<_Ret
, _Tp
, _Arg
>
877 mem_fun(_Ret (_Tp::*__f
)(_Arg
) const)
878 { return const_mem_fun1_t
<_Ret
, _Tp
, _Arg
>(__f
); }
880 template <class _Ret
, class _Tp
, class _Arg
>
881 inline mem_fun1_ref_t
<_Ret
, _Tp
, _Arg
>
882 mem_fun_ref(_Ret (_Tp::*__f
)(_Arg
))
883 { return mem_fun1_ref_t
<_Ret
, _Tp
, _Arg
>(__f
); }
885 template <class _Ret
, class _Tp
, class _Arg
>
886 inline const_mem_fun1_ref_t
<_Ret
, _Tp
, _Arg
>
887 mem_fun_ref(_Ret (_Tp::*__f
)(_Arg
) const)
888 { return const_mem_fun1_ref_t
<_Ret
, _Tp
, _Arg
>(__f
); }
894 #endif /* _FUNCTION_H */