1/*
2 *
3 * Copyright (c) 1994
4 * Hewlett-Packard Company
5 *
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation.  Hewlett-Packard Company makes no
11 * representations about the suitability of this software for any
12 * purpose.  It is provided "as is" without express or implied warranty.
13 *
14 *
15 * Copyright (c) 1996-1998
16 * Silicon Graphics Computer Systems, Inc.
17 *
18 * Permission to use, copy, modify, distribute and sell this software
19 * and its documentation for any purpose is hereby granted without fee,
20 * provided that the above copyright notice appear in all copies and
21 * that both that copyright notice and this permission notice appear
22 * in supporting documentation.  Silicon Graphics makes no
23 * representations about the suitability of this software for any
24 * purpose.  It is provided "as is" without express or implied warranty.
25 */
26
27/* NOTE: This is an internal header file, included by other STL headers.
28 *   You should not attempt to use it directly.
29 */
30
31#ifndef __SGI_STL_INTERNAL_FUNCTION_H
32#define __SGI_STL_INTERNAL_FUNCTION_H
33
34__STL_BEGIN_NAMESPACE
35
36template <class _Arg, class _Result>
37struct unary_function {
38  typedef _Arg argument_type;
39  typedef _Result result_type;
40};
41
42template <class _Arg1, class _Arg2, class _Result>
43struct binary_function {
44  typedef _Arg1 first_argument_type;
45  typedef _Arg2 second_argument_type;
46  typedef _Result result_type;
47};
48
49template <class _Tp>
50struct plus : public binary_function<_Tp,_Tp,_Tp> {
51  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
52};
53
54template <class _Tp>
55struct minus : public binary_function<_Tp,_Tp,_Tp> {
56  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }
57};
58
59template <class _Tp>
60struct multiplies : public binary_function<_Tp,_Tp,_Tp> {
61  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }
62};
63
64template <class _Tp>
65struct divides : public binary_function<_Tp,_Tp,_Tp> {
66  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; }
67};
68
69// identity_element (not part of the C++ standard).
70
71template <class _Tp> inline _Tp identity_element(plus<_Tp>) {
72  return _Tp(0);
73}
74template <class _Tp> inline _Tp identity_element(multiplies<_Tp>) {
75  return _Tp(1);
76}
77
78template <class _Tp>
79struct modulus : public binary_function<_Tp,_Tp,_Tp>
80{
81  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; }
82};
83
84template <class _Tp>
85struct negate : public unary_function<_Tp,_Tp>
86{
87  _Tp operator()(const _Tp& __x) const { return -__x; }
88};
89
90template <class _Tp>
91struct equal_to : public binary_function<_Tp,_Tp,bool>
92{
93  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
94};
95
96template <class _Tp>
97struct not_equal_to : public binary_function<_Tp,_Tp,bool>
98{
99  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; }
100};
101
102template <class _Tp>
103struct greater : public binary_function<_Tp,_Tp,bool>
104{
105  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; }
106};
107
108template <class _Tp>
109struct less : public binary_function<_Tp,_Tp,bool>
110{
111  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
112};
113
114template <class _Tp>
115struct greater_equal : public binary_function<_Tp,_Tp,bool>
116{
117  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; }
118};
119
120template <class _Tp>
121struct less_equal : public binary_function<_Tp,_Tp,bool>
122{
123  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; }
124};
125
126template <class _Tp>
127struct logical_and : public binary_function<_Tp,_Tp,bool>
128{
129  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; }
130};
131
132template <class _Tp>
133struct logical_or : public binary_function<_Tp,_Tp,bool>
134{
135  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; }
136};
137
138template <class _Tp>
139struct logical_not : public unary_function<_Tp,bool>
140{
141  bool operator()(const _Tp& __x) const { return !__x; }
142};
143
144template <class _Predicate>
145class unary_negate
146  : public unary_function<typename _Predicate::argument_type, bool> {
147protected:
148  _Predicate _M_pred;
149public:
150  explicit unary_negate(const _Predicate& __x) : _M_pred(__x) {}
151  bool operator()(const typename _Predicate::argument_type& __x) const {
152    return !_M_pred(__x);
153  }
154};
155
156template <class _Predicate>
157inline unary_negate<_Predicate>
158not1(const _Predicate& __pred)
159{
160  return unary_negate<_Predicate>(__pred);
161}
162
163template <class _Predicate>
164class binary_negate
165  : public binary_function<typename _Predicate::first_argument_type,
166                           typename _Predicate::second_argument_type,
167                           bool> {
168protected:
169  _Predicate _M_pred;
170public:
171  explicit binary_negate(const _Predicate& __x) : _M_pred(__x) {}
172  bool operator()(const typename _Predicate::first_argument_type& __x,
173                  const typename _Predicate::second_argument_type& __y) const
174  {
175    return !_M_pred(__x, __y);
176  }
177};
178
179template <class _Predicate>
180inline binary_negate<_Predicate>
181not2(const _Predicate& __pred)
182{
183  return binary_negate<_Predicate>(__pred);
184}
185
186template <class _Operation>
187class binder1st
188  : public unary_function<typename _Operation::second_argument_type,
189                          typename _Operation::result_type> {
190protected:
191  _Operation op;
192  typename _Operation::first_argument_type value;
193public:
194  binder1st(const _Operation& __x,
195            const typename _Operation::first_argument_type& __y)
196      : op(__x), value(__y) {}
197  typename _Operation::result_type
198  operator()(const typename _Operation::second_argument_type& __x) const {
199    return op(value, __x);
200  }
201};
202
203template <class _Operation, class _Tp>
204inline binder1st<_Operation>
205bind1st(const _Operation& __oper, const _Tp& __x)
206{
207  typedef typename _Operation::first_argument_type _Arg1_type;
208  return binder1st<_Operation>(__oper, _Arg1_type(__x));
209}
210
211template <class _Operation>
212class binder2nd
213  : public unary_function<typename _Operation::first_argument_type,
214                          typename _Operation::result_type> {
215protected:
216  _Operation op;
217  typename _Operation::second_argument_type value;
218public:
219  binder2nd(const _Operation& __x,
220            const typename _Operation::second_argument_type& __y)
221      : op(__x), value(__y) {}
222  typename _Operation::result_type
223  operator()(const typename _Operation::first_argument_type& __x) const {
224    return op(__x, value);
225  }
226};
227
228template <class _Operation, class _Tp>
229inline binder2nd<_Operation>
230bind2nd(const _Operation& __oper, const _Tp& __x)
231{
232  typedef typename _Operation::second_argument_type _Arg2_type;
233  return binder2nd<_Operation>(__oper, _Arg2_type(__x));
234}
235
236// unary_compose and binary_compose (extensions, not part of the standard).
237
238template <class _Operation1, class _Operation2>
239class unary_compose
240  : public unary_function<typename _Operation2::argument_type,
241                          typename _Operation1::result_type>
242{
243protected:
244  _Operation1 __op1;
245  _Operation2 __op2;
246public:
247  unary_compose(const _Operation1& __x, const _Operation2& __y)
248    : __op1(__x), __op2(__y) {}
249  typename _Operation1::result_type
250  operator()(const typename _Operation2::argument_type& __x) const {
251    return __op1(__op2(__x));
252  }
253};
254
255template <class _Operation1, class _Operation2>
256inline unary_compose<_Operation1,_Operation2>
257compose1(const _Operation1& __op1, const _Operation2& __op2)
258{
259  return unary_compose<_Operation1,_Operation2>(__op1, __op2);
260}
261
262template <class _Operation1, class _Operation2, class _Operation3>
263class binary_compose
264  : public unary_function<typename _Operation2::argument_type,
265                          typename _Operation1::result_type> {
266protected:
267  _Operation1 _M_op1;
268  _Operation2 _M_op2;
269  _Operation3 _M_op3;
270public:
271  binary_compose(const _Operation1& __x, const _Operation2& __y,
272                 const _Operation3& __z)
273    : _M_op1(__x), _M_op2(__y), _M_op3(__z) { }
274  typename _Operation1::result_type
275  operator()(const typename _Operation2::argument_type& __x) const {
276    return _M_op1(_M_op2(__x), _M_op3(__x));
277  }
278};
279
280template <class _Operation1, class _Operation2, class _Operation3>
281inline binary_compose<_Operation1, _Operation2, _Operation3>
282compose2(const _Operation1& __op1, const _Operation2& __op2,
283         const _Operation3& __op3)
284{
285  return binary_compose<_Operation1,_Operation2,_Operation3>
286    (__op1, __op2, __op3);
287}
288
289template <class _Arg, class _Result>
290class pointer_to_unary_function : public unary_function<_Arg, _Result> {
291protected:
292  _Result (*_M_ptr)(_Arg);
293public:
294  pointer_to_unary_function() {}
295  explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {}
296  _Result operator()(_Arg __x) const { return _M_ptr(__x); }
297};
298
299template <class _Arg, class _Result>
300inline pointer_to_unary_function<_Arg, _Result> ptr_fun(_Result (*__x)(_Arg))
301{
302  return pointer_to_unary_function<_Arg, _Result>(__x);
303}
304
305template <class _Arg1, class _Arg2, class _Result>
306class pointer_to_binary_function :
307  public binary_function<_Arg1,_Arg2,_Result> {
308protected:
309    _Result (*_M_ptr)(_Arg1, _Arg2);
310public:
311    pointer_to_binary_function() {}
312    explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
313      : _M_ptr(__x) {}
314    _Result operator()(_Arg1 __x, _Arg2 __y) const {
315      return _M_ptr(__x, __y);
316    }
317};
318
319template <class _Arg1, class _Arg2, class _Result>
320inline pointer_to_binary_function<_Arg1,_Arg2,_Result>
321ptr_fun(_Result (*__x)(_Arg1, _Arg2)) {
322  return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__x);
323}
324
325// identity is an extensions: it is not part of the standard.
326template <class _Tp>
327struct _Identity : public unary_function<_Tp,_Tp> {
328  const _Tp& operator()(const _Tp& __x) const { return __x; }
329};
330
331template <class _Tp> struct identity : public _Identity<_Tp> {};
332
333// select1st and select2nd are extensions: they are not part of the standard.
334template <class _Pair>
335struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {
336  const typename _Pair::first_type& operator()(const _Pair& __x) const {
337    return __x.first;
338  }
339};
340
341template <class _Pair>
342struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type>
343{
344  const typename _Pair::second_type& operator()(const _Pair& __x) const {
345    return __x.second;
346  }
347};
348
349template <class _Pair> struct select1st : public _Select1st<_Pair> {};
350template <class _Pair> struct select2nd : public _Select2nd<_Pair> {};
351
352// project1st and project2nd are extensions: they are not part of the standard
353template <class _Arg1, class _Arg2>
354struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> {
355  _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; }
356};
357
358template <class _Arg1, class _Arg2>
359struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> {
360  _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; }
361};
362
363template <class _Arg1, class _Arg2>
364struct project1st : public _Project1st<_Arg1, _Arg2> {};
365
366template <class _Arg1, class _Arg2>
367struct project2nd : public _Project2nd<_Arg1, _Arg2> {};
368
369// constant_void_fun, constant_unary_fun, and constant_binary_fun are
370// extensions: they are not part of the standard.  (The same, of course,
371// is true of the helper functions constant0, constant1, and constant2.)
372template <class _Result>
373struct constant_void_fun
374{
375  typedef _Result result_type;
376  result_type __val;
377  constant_void_fun(const result_type& __v) : __val(__v) {}
378  const result_type& operator()() const { return __val; }
379};
380
381#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
382template <class _Result, class _Argument = _Result>
383#else
384template <class _Result, class _Argument>
385#endif
386struct constant_unary_fun : public unary_function<_Argument, _Result> {
387  _Result _M_val;
388  constant_unary_fun(const _Result& __v) : _M_val(__v) {}
389  const _Result& operator()(const _Argument&) const { return _M_val; }
390};
391
392#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
393template <class _Result, class _Arg1 = _Result, class _Arg2 = _Arg1>
394#else
395template <class _Result, class _Arg1, class _Arg2>
396#endif
397struct constant_binary_fun : public binary_function<_Arg1, _Arg2, _Result> {
398  _Result _M_val;
399  constant_binary_fun(const _Result& __v) : _M_val(__v) {}
400  const _Result& operator()(const _Arg1&, const _Arg2&) const {
401    return _M_val;
402  }
403};
404
405template <class _Result>
406inline constant_void_fun<_Result> constant0(const _Result& __val)
407{
408  return constant_void_fun<_Result>(__val);
409}
410
411template <class _Result>
412inline constant_unary_fun<_Result,_Result> constant1(const _Result& __val)
413{
414  return constant_unary_fun<_Result,_Result>(__val);
415}
416
417template <class _Result>
418inline constant_binary_fun<_Result,_Result,_Result>
419constant2(const _Result& __val)
420{
421  return constant_binary_fun<_Result,_Result,_Result>(__val);
422}
423
424// subtractive_rng is an extension: it is not part of the standard.
425// Note: this code assumes that int is 32 bits.
426class subtractive_rng : public unary_function<unsigned int, unsigned int> {
427private:
428  unsigned int _M_table[55];
429  size_t _M_index1;
430  size_t _M_index2;
431public:
432  unsigned int operator()(unsigned int __limit) {
433    _M_index1 = (_M_index1 + 1) % 55;
434    _M_index2 = (_M_index2 + 1) % 55;
435    _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2];
436    return _M_table[_M_index1] % __limit;
437  }
438
439  void _M_initialize(unsigned int __seed)
440  {
441    unsigned int __k = 1;
442    _M_table[54] = __seed;
443    size_t __i;
444    for (__i = 0; __i < 54; __i++) {
445        size_t __ii = (21 * (__i + 1) % 55) - 1;
446        _M_table[__ii] = __k;
447        __k = __seed - __k;
448        __seed = _M_table[__ii];
449    }
450    for (int __loop = 0; __loop < 4; __loop++) {
451        for (__i = 0; __i < 55; __i++)
452            _M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55];
453    }
454    _M_index1 = 0;
455    _M_index2 = 31;
456  }
457
458  subtractive_rng(unsigned int __seed) { _M_initialize(__seed); }
459  subtractive_rng() { _M_initialize(161803398u); }
460};
461
462
463// Adaptor function objects: pointers to member functions.
464
465// There are a total of 16 = 2^4 function objects in this family.
466//  (1) Member functions taking no arguments vs member functions taking
467//       one argument.
468//  (2) Call through pointer vs call through reference.
469//  (3) Member function with void return type vs member function with
470//      non-void return type.
471//  (4) Const vs non-const member function.
472
473// Note that choice (3) is nothing more than a workaround: according
474//  to the draft, compilers should handle void and non-void the same way.
475//  This feature is not yet widely implemented, though.  You can only use
476//  member functions returning void if your compiler supports partial
477//  specialization.
478
479// All of this complexity is in the function objects themselves.  You can
480//  ignore it by using the helper function mem_fun and mem_fun_ref,
481//  which create whichever type of adaptor is appropriate.
482//  (mem_fun1 and mem_fun1_ref are no longer part of the C++ standard,
483//  but they are provided for backward compatibility.)
484
485
486template <class _Ret, class _Tp>
487class mem_fun_t : public unary_function<_Tp*,_Ret> {
488public:
489  explicit mem_fun_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {}
490  _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); }
491private:
492  _Ret (_Tp::*_M_f)();
493};
494
495template <class _Ret, class _Tp>
496class const_mem_fun_t : public unary_function<const _Tp*,_Ret> {
497public:
498  explicit const_mem_fun_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
499  _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); }
500private:
501  _Ret (_Tp::*_M_f)() const;
502};
503
504
505template <class _Ret, class _Tp>
506class mem_fun_ref_t : public unary_function<_Tp,_Ret> {
507public:
508  explicit mem_fun_ref_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {}
509  _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); }
510private:
511  _Ret (_Tp::*_M_f)();
512};
513
514template <class _Ret, class _Tp>
515class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> {
516public:
517  explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
518  _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
519private:
520  _Ret (_Tp::*_M_f)() const;
521};
522
523template <class _Ret, class _Tp, class _Arg>
524class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> {
525public:
526  explicit mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}
527  _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
528private:
529  _Ret (_Tp::*_M_f)(_Arg);
530};
531
532template <class _Ret, class _Tp, class _Arg>
533class const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> {
534public:
535  explicit const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}
536  _Ret operator()(const _Tp* __p, _Arg __x) const
537    { return (__p->*_M_f)(__x); }
538private:
539  _Ret (_Tp::*_M_f)(_Arg) const;
540};
541
542template <class _Ret, class _Tp, class _Arg>
543class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
544public:
545  explicit mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}
546  _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
547private:
548  _Ret (_Tp::*_M_f)(_Arg);
549};
550
551template <class _Ret, class _Tp, class _Arg>
552class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
553public:
554  explicit const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}
555  _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
556private:
557  _Ret (_Tp::*_M_f)(_Arg) const;
558};
559
560#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
561
562template <class _Tp>
563class mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> {
564public:
565  explicit mem_fun_t(void (_Tp::*__pf)()) : _M_f(__pf) {}
566  void operator()(_Tp* __p) const { (__p->*_M_f)(); }
567private:
568  void (_Tp::*_M_f)();
569};
570
571template <class _Tp>
572class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> {
573public:
574  explicit const_mem_fun_t(void (_Tp::*__pf)() const) : _M_f(__pf) {}
575  void operator()(const _Tp* __p) const { (__p->*_M_f)(); }
576private:
577  void (_Tp::*_M_f)() const;
578};
579
580template <class _Tp>
581class mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
582public:
583  explicit mem_fun_ref_t(void (_Tp::*__pf)()) : _M_f(__pf) {}
584  void operator()(_Tp& __r) const { (__r.*_M_f)(); }
585private:
586  void (_Tp::*_M_f)();
587};
588
589template <class _Tp>
590class const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
591public:
592  explicit const_mem_fun_ref_t(void (_Tp::*__pf)() const) : _M_f(__pf) {}
593  void operator()(const _Tp& __r) const { (__r.*_M_f)(); }
594private:
595  void (_Tp::*_M_f)() const;
596};
597
598template <class _Tp, class _Arg>
599class mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> {
600public:
601  explicit mem_fun1_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}
602  void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
603private:
604  void (_Tp::*_M_f)(_Arg);
605};
606
607template <class _Tp, class _Arg>
608class const_mem_fun1_t<void, _Tp, _Arg>
609  : public binary_function<const _Tp*,_Arg,void> {
610public:
611  explicit const_mem_fun1_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}
612  void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
613private:
614  void (_Tp::*_M_f)(_Arg) const;
615};
616
617template <class _Tp, class _Arg>
618class mem_fun1_ref_t<void, _Tp, _Arg>
619  : public binary_function<_Tp,_Arg,void> {
620public:
621  explicit mem_fun1_ref_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}
622  void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
623private:
624  void (_Tp::*_M_f)(_Arg);
625};
626
627template <class _Tp, class _Arg>
628class const_mem_fun1_ref_t<void, _Tp, _Arg>
629  : public binary_function<_Tp,_Arg,void> {
630public:
631  explicit const_mem_fun1_ref_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}
632  void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
633private:
634  void (_Tp::*_M_f)(_Arg) const;
635};
636
637#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
638
639// Mem_fun adaptor helper functions.  There are only two:
640//  mem_fun and mem_fun_ref.  (mem_fun1 and mem_fun1_ref
641//  are provided for backward compatibility, but they are no longer
642//  part of the C++ standard.)
643
644template <class _Ret, class _Tp>
645inline mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)())
646  { return mem_fun_t<_Ret,_Tp>(__f); }
647
648template <class _Ret, class _Tp>
649inline const_mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)() const)
650  { return const_mem_fun_t<_Ret,_Tp>(__f); }
651
652template <class _Ret, class _Tp>
653inline mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)())
654  { return mem_fun_ref_t<_Ret,_Tp>(__f); }
655
656template <class _Ret, class _Tp>
657inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
658  { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
659
660template <class _Ret, class _Tp, class _Arg>
661inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg))
662  { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); }
663
664template <class _Ret, class _Tp, class _Arg>
665inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg) const)
666  { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); }
667
668template <class _Ret, class _Tp, class _Arg>
669inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
670  { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }
671
672template <class _Ret, class _Tp, class _Arg>
673inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg>
674mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
675  { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }
676
677template <class _Ret, class _Tp, class _Arg>
678inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg))
679  { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); }
680
681template <class _Ret, class _Tp, class _Arg>
682inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg) const)
683  { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); }
684
685template <class _Ret, class _Tp, class _Arg>
686inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun1_ref(_Ret (_Tp::*__f)(_Arg))
687  { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }
688
689template <class _Ret, class _Tp, class _Arg>
690inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg>
691mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const)
692  { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }
693
694__STL_END_NAMESPACE
695
696#endif /* __SGI_STL_INTERNAL_FUNCTION_H */
697
698// Local Variables:
699// mode:C++
700// End:
701