ReactOS 0.4.15-dev-7924-g5949c20
_function_adaptors.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) 1994
4 * Hewlett-Packard Company
5 *
6 * Copyright (c) 1996-1998
7 * Silicon Graphics Computer Systems, Inc.
8 *
9 * Copyright (c) 1997
10 * Moscow Center for SPARC Technology
11 *
12 * Copyright (c) 1999
13 * Boris Fomitchev
14 *
15 * Copyright (c) 2000
16 * Pavel Kuznetsov
17 *
18 * Copyright (c) 2001
19 * Meridian'93
20 *
21 * This material is provided "as is", with absolutely no warranty expressed
22 * or implied. Any use is at your own risk.
23 *
24 * Permission to use or copy this software for any purpose is hereby granted
25 * without fee, provided the above notices are retained on all copies.
26 * Permission to modify the code and to distribute modified code is granted,
27 * provided the above notices are retained, and a notice that the code was
28 * modified is included with the above copyright notice.
29 *
30 */
31
32/* NOTE: This is an internal header file, included by other STL headers.
33 * You should not attempt to use it directly.
34 */
35
36// This file has noo macro protection as it is meant to be included several times
37// from other header.
38// Adaptor function objects: pointers to member functions.
39
40// There are a total of 16 = 2^4 function objects in this family.
41// (1) Member functions taking no arguments vs member functions taking
42// one argument.
43// (2) Call through pointer vs call through reference.
44// (3) Member function with void return type vs member function with
45// non-void return type.
46// (4) Const vs non-const member function.
47
48// Note that choice (3) is nothing more than a workaround: according
49// to the draft, compilers should handle void and non-void the same way.
50// This feature is not yet widely implemented, though. You can only use
51// member functions returning void if your compiler supports partial
52// specialization.
53
54// All of this complexity is in the function objects themselves. You can
55// ignore it by using the helper function mem_fun and mem_fun_ref,
56// which create whichever type of adaptor is appropriate.
57
59
60//This implementation will only be used if needed, that is to say when there is the return void bug
61//and when there is no partial template specialization
62#if defined (_STLP_DONT_RETURN_VOID) && defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && defined (_STLP_MEMBER_TEMPLATE_CLASSES)
63
64template<class _Result, class _Tp>
65class _Mem_fun0_ptr : public unary_function<_Tp*, _Result> {
66protected:
67 typedef _Result (_Tp::*__fun_type) ();
68 explicit _Mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
69
70public:
71 _Result operator ()(_Tp* __p) const { return (__p->*_M_f)(); }
72
73private:
74 __fun_type _M_f;
75};
76
77template<class _Result, class _Tp, class _Arg>
78class _Mem_fun1_ptr : public binary_function<_Tp*,_Arg,_Result> {
79protected:
80 typedef _Result (_Tp::*__fun_type) (_Arg);
81 explicit _Mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
82
83public:
84 _Result operator ()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
85
86private:
87 __fun_type _M_f;
88};
89
90template<class _Result, class _Tp>
91class _Const_mem_fun0_ptr : public unary_function<const _Tp*,_Result> {
92protected:
93 typedef _Result (_Tp::*__fun_type) () const;
94 explicit _Const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
95
96public:
97 _Result operator ()(const _Tp* __p) const { return (__p->*_M_f)(); }
98
99private:
100 __fun_type _M_f;
101};
102
103template<class _Result, class _Tp, class _Arg>
104class _Const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,_Result> {
105protected:
106 typedef _Result (_Tp::*__fun_type) (_Arg) const;
107 explicit _Const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
108
109public:
110 _Result operator ()(const _Tp* __p, _Arg __x) const {
111 return (__p->*_M_f)(__x); }
112
113private:
114 __fun_type _M_f;
115};
116
117template<class _Result, class _Tp>
118class _Mem_fun0_ref : public unary_function<_Tp,_Result> {
119protected:
120 typedef _Result (_Tp::*__fun_type) ();
121 explicit _Mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
122
123public:
124 _Result operator ()(_Tp& __p) const { return (__p.*_M_f)(); }
125
126private:
127 __fun_type _M_f;
128};
129
130template<class _Result, class _Tp, class _Arg>
131class _Mem_fun1_ref : public binary_function<_Tp,_Arg,_Result> {
132protected:
133 typedef _Result (_Tp::*__fun_type) (_Arg);
134 explicit _Mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
135
136public:
137 _Result operator ()(_Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); }
138
139private:
140 __fun_type _M_f;
141};
142
143template<class _Result, class _Tp>
144class _Const_mem_fun0_ref : public unary_function<_Tp,_Result> {
145protected:
146 typedef _Result (_Tp::*__fun_type) () const;
147 explicit _Const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
148
149public:
150 _Result operator ()(const _Tp& __p) const { return (__p.*_M_f)(); }
151
152private:
153 __fun_type _M_f;
154};
155
156template<class _Result, class _Tp, class _Arg>
157class _Const_mem_fun1_ref : public binary_function<_Tp,_Arg,_Result> {
158protected:
159 typedef _Result (_Tp::*__fun_type) (_Arg) const;
160 explicit _Const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
161
162public:
163 _Result operator ()(const _Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); }
164
165private:
166 __fun_type _M_f;
167};
168
169template<class _Result>
170struct _Mem_fun_traits {
171 template<class _Tp>
172 struct _Args0 {
173 typedef _Mem_fun0_ptr<_Result,_Tp> _Ptr;
174 typedef _Const_mem_fun0_ptr<_Result,_Tp> _Ptr_const;
175 typedef _Mem_fun0_ref<_Result,_Tp> _Ref;
176 typedef _Const_mem_fun0_ref<_Result,_Tp> _Ref_const;
177 };
178
179 template<class _Tp, class _Arg>
180 struct _Args1 {
181 typedef _Mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr;
182 typedef _Const_mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr_const;
183 typedef _Mem_fun1_ref<_Result,_Tp,_Arg> _Ref;
184 typedef _Const_mem_fun1_ref<_Result,_Tp,_Arg> _Ref_const;
185 };
186};
187
188template<class _Arg, class _Result>
189class _Ptr_fun1_base : public unary_function<_Arg, _Result> {
190protected:
191 typedef _Result (*__fun_type) (_Arg);
192 explicit _Ptr_fun1_base(__fun_type __f) : _M_f(__f) {}
193
194public:
195 _Result operator()(_Arg __x) const { return _M_f(__x); }
196
197private:
198 __fun_type _M_f;
199};
200
201template <class _Arg1, class _Arg2, class _Result>
202class _Ptr_fun2_base : public binary_function<_Arg1,_Arg2,_Result> {
203protected:
204 typedef _Result (*__fun_type) (_Arg1, _Arg2);
205 explicit _Ptr_fun2_base(__fun_type __f) : _M_f(__f) {}
206
207public:
208 _Result operator()(_Arg1 __x, _Arg2 __y) const { return _M_f(__x, __y); }
209
210private:
211 __fun_type _M_f;
212};
213
214template<class _Result>
215struct _Ptr_fun_traits {
216 template<class _Arg> struct _Args1 {
217 typedef _Ptr_fun1_base<_Arg,_Result> _Fun;
218 };
219
220 template<class _Arg1, class _Arg2> struct _Args2 {
221 typedef _Ptr_fun2_base<_Arg1,_Arg2,_Result> _Fun;
222 };
223};
224
225/* Specializations for void return type */
226template<class _Tp>
227class _Void_mem_fun0_ptr : public unary_function<_Tp*,void> {
228protected:
229 typedef void (_Tp::*__fun_type) ();
230 explicit _Void_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
231
232public:
233 void operator ()(_Tp* __p) const { (__p->*_M_f)(); }
234
235private:
236 __fun_type _M_f;
237};
238
239template<class _Tp, class _Arg>
240class _Void_mem_fun1_ptr : public binary_function<_Tp*,_Arg,void> {
241protected:
242 typedef void (_Tp::*__fun_type) (_Arg);
243 explicit _Void_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
244
245public:
246 void operator ()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
247
248private:
249 __fun_type _M_f;
250};
251
252template<class _Tp>
253class _Void_const_mem_fun0_ptr : public unary_function<const _Tp*,void> {
254protected:
255 typedef void (_Tp::*__fun_type) () const;
256 explicit _Void_const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
257
258public:
259 void operator ()(const _Tp* __p) const { (__p->*_M_f)(); }
260
261private:
262 __fun_type _M_f;
263};
264
265template<class _Tp, class _Arg>
266class _Void_const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,void> {
267protected:
268 typedef void (_Tp::*__fun_type) (_Arg) const;
269 explicit _Void_const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
270
271public:
272 void operator ()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
273
274private:
275 __fun_type _M_f;
276};
277
278template<class _Tp>
279class _Void_mem_fun0_ref : public unary_function<_Tp,void> {
280protected:
281 typedef void (_Tp::*__fun_type) ();
282 explicit _Void_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
283
284public:
285 void operator ()(_Tp& __p) const { (__p.*_M_f)(); }
286
287private:
288 __fun_type _M_f;
289};
290
291template<class _Tp, class _Arg>
292class _Void_mem_fun1_ref : public binary_function<_Tp,_Arg,void> {
293protected:
294 typedef void (_Tp::*__fun_type) (_Arg);
295 explicit _Void_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
296
297public:
298 void operator ()(_Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); }
299
300private:
301 __fun_type _M_f;
302};
303
304template<class _Tp>
305class _Void_const_mem_fun0_ref : public unary_function<_Tp,void> {
306protected:
307 typedef void (_Tp::*__fun_type) () const;
308 explicit _Void_const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
309
310public:
311 void operator ()(const _Tp& __p) const { (__p.*_M_f)(); }
312
313private:
314 __fun_type _M_f;
315};
316
317template<class _Tp, class _Arg>
318class _Void_const_mem_fun1_ref : public binary_function<_Tp,_Arg,void> {
319protected:
320 typedef void (_Tp::*__fun_type) (_Arg) const;
321 explicit _Void_const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
322
323public:
324 void operator ()(const _Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); }
325
326private:
327 __fun_type _M_f;
328};
329
331struct _Mem_fun_traits<void> {
332 template<class _Tp> struct _Args0 {
333 typedef _Void_mem_fun0_ptr<_Tp> _Ptr;
334 typedef _Void_const_mem_fun0_ptr<_Tp> _Ptr_const;
335 typedef _Void_mem_fun0_ref<_Tp> _Ref;
336 typedef _Void_const_mem_fun0_ref<_Tp> _Ref_const;
337 };
338
339 template<class _Tp, class _Arg> struct _Args1 {
340 typedef _Void_mem_fun1_ptr<_Tp,_Arg> _Ptr;
341 typedef _Void_const_mem_fun1_ptr<_Tp,_Arg> _Ptr_const;
342 typedef _Void_mem_fun1_ref<_Tp,_Arg> _Ref;
343 typedef _Void_const_mem_fun1_ref<_Tp,_Arg> _Ref_const;
344 };
345};
346
347template<class _Arg>
348class _Ptr_void_fun1_base : public unary_function<_Arg, void> {
349protected:
350 typedef void (*__fun_type) (_Arg);
351 explicit _Ptr_void_fun1_base(__fun_type __f) : _M_f(__f) {}
352
353public:
354 void operator()(_Arg __x) const { _M_f(__x); }
355
356private:
357 __fun_type _M_f;
358};
359
360template <class _Arg1, class _Arg2>
361class _Ptr_void_fun2_base : public binary_function<_Arg1,_Arg2,void> {
362protected:
363 typedef void (*__fun_type) (_Arg1, _Arg2);
364 explicit _Ptr_void_fun2_base(__fun_type __f) : _M_f(__f) {}
365
366public:
367 void operator()(_Arg1 __x, _Arg2 __y) const { _M_f(__x, __y); }
368
369private:
370 __fun_type _M_f;
371};
372
374struct _Ptr_fun_traits<void> {
375 template<class _Arg> struct _Args1 {
376 typedef _Ptr_void_fun1_base<_Arg> _Fun;
377 };
378
379 template<class _Arg1, class _Arg2> struct _Args2 {
380 typedef _Ptr_void_fun2_base<_Arg1,_Arg2> _Fun;
381 };
382};
383
384// pavel: need extra level of inheritance here since MSVC++ does not
385// accept traits-based fake partial specialization for template
386// arguments other than first
387
388template<class _Result, class _Arg>
389class _Ptr_fun1 :
390 public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun {
391protected:
392 typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun _Base;
393 explicit _Ptr_fun1(typename _Base::__fun_type __f) : _Base(__f) {}
394};
395
396template<class _Result, class _Arg1, class _Arg2>
397class _Ptr_fun2 :
398 public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun {
399protected:
400 typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun _Base;
401 explicit _Ptr_fun2(typename _Base::__fun_type __f) : _Base(__f) {}
402};
403
404template <class _Result, class _Tp>
405class mem_fun_t :
406 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr {
407 typedef typename
408 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr _Base;
409public:
410 explicit mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {}
411};
412
413template <class _Result, class _Tp>
414class const_mem_fun_t :
415 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const {
416 typedef typename
417 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const _Base;
418public:
419 explicit const_mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {}
420};
421
422template <class _Result, class _Tp>
423class mem_fun_ref_t :
424 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref {
425 typedef typename
426 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref _Base;
427public:
428 explicit mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
429};
430
431template <class _Result, class _Tp>
433 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const {
434 typedef typename
435 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const _Base;
436public:
437 explicit const_mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
438};
439
440template <class _Result, class _Tp, class _Arg>
441class mem_fun1_t :
442 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr {
443 typedef typename
444 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr _Base;
445public:
446 explicit mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {}
447};
448
449template <class _Result, class _Tp, class _Arg>
450class const_mem_fun1_t :
451 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const {
452 typedef typename
453 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const _Base;
454public:
455 explicit const_mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {}
456};
457
458template <class _Result, class _Tp, class _Arg>
459class mem_fun1_ref_t :
460 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref {
461 typedef typename
462 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref _Base;
463public:
464 explicit mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
465};
466
467template <class _Result, class _Tp, class _Arg>
469 public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const {
470 typedef typename
471 _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const _Base;
472public:
473 explicit const_mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
474};
475
476template <class _Arg, class _Result>
478 public _Ptr_fun1<_Result,_Arg> {
479 typedef typename
480 _Ptr_fun1<_Result,_Arg>::__fun_type __fun_type;
481public:
482 explicit pointer_to_unary_function(__fun_type __f)
483 : _Ptr_fun1<_Result,_Arg>(__f) {}
484};
485
486template <class _Arg1, class _Arg2, class _Result>
488 public _Ptr_fun2<_Result,_Arg1,_Arg2> {
489 typedef typename
490 _Ptr_fun2<_Result,_Arg1,_Arg2>::__fun_type __fun_type;
491public:
492 explicit pointer_to_binary_function(__fun_type __f)
493 : _Ptr_fun2<_Result,_Arg1,_Arg2>(__f) {}
494};
495
496#else
497
498template <class _Ret, class _Tp>
499class mem_fun_t : public unary_function<_Tp*,_Ret> {
500 typedef _Ret (_Tp::*__fun_type)(void);
501public:
502 explicit mem_fun_t(__fun_type __pf) : _M_f(__pf) {}
503 _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); }
504private:
506};
507
508template <class _Ret, class _Tp>
509class const_mem_fun_t : public unary_function<const _Tp*,_Ret> {
510 typedef _Ret (_Tp::*__fun_type)(void) const;
511public:
512 explicit const_mem_fun_t(__fun_type __pf) : _M_f(__pf) {}
513 _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); }
514private:
516};
517
518template <class _Ret, class _Tp>
519class mem_fun_ref_t : public unary_function<_Tp,_Ret> {
520 typedef _Ret (_Tp::*__fun_type)(void);
521public:
522 explicit mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {}
523 _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); }
524private:
526};
527
528template <class _Ret, class _Tp>
529class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> {
530 typedef _Ret (_Tp::*__fun_type)(void) const;
531public:
532 explicit const_mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {}
533 _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
534private:
536};
537
538template <class _Ret, class _Tp, class _Arg>
539class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> {
540 typedef _Ret (_Tp::*__fun_type)(_Arg);
541public:
542 explicit mem_fun1_t(__fun_type __pf) : _M_f(__pf) {}
543 _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
544private:
546};
547
548template <class _Ret, class _Tp, class _Arg>
549class const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> {
550 typedef _Ret (_Tp::*__fun_type)(_Arg) const;
551public:
552 explicit const_mem_fun1_t(__fun_type __pf) : _M_f(__pf) {}
553 _Ret operator()(const _Tp* __p, _Arg __x) const
554 { return (__p->*_M_f)(__x); }
555private:
557};
558
559template <class _Ret, class _Tp, class _Arg>
560class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
561 typedef _Ret (_Tp::*__fun_type)(_Arg);
562public:
563 explicit mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {}
564 _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
565private:
567};
568
569template <class _Ret, class _Tp, class _Arg>
570class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
571 typedef _Ret (_Tp::*__fun_type)(_Arg) const;
572public:
573 explicit const_mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {}
574 _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
575private:
577};
578
579template <class _Arg, class _Result>
580class pointer_to_unary_function : public unary_function<_Arg, _Result> {
581protected:
582 _Result (*_M_ptr)(_Arg);
583public:
585 explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {}
586 _Result operator()(_Arg __x) const { return _M_ptr(__x); }
587};
588
589template <class _Arg1, class _Arg2, class _Result>
591 public binary_function<_Arg1,_Arg2,_Result> {
592protected:
593 _Result (*_M_ptr)(_Arg1, _Arg2);
594public:
596 explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
597 : _M_ptr(__x) {}
598 _Result operator()(_Arg1 __x, _Arg2 __y) const {
599 return _M_ptr(__x, __y);
600 }
601};
602
603# if defined (_STLP_DONT_RETURN_VOID) && !defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION)
604//Partial specializations for the void type
605template <class _Tp>
606class mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> {
607 typedef void (_Tp::*__fun_type)(void);
608public:
609 explicit mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
610 void operator()(_Tp* __p) const { (__p->*_M_f)(); }
611private:
613};
614
615template <class _Tp>
616class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> {
617 typedef void (_Tp::*__fun_type)(void) const;
618public:
619 explicit const_mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
620 void operator()(const _Tp* __p) const { (__p->*_M_f)(); }
621private:
623};
624
625template <class _Tp>
626class mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
627 typedef void (_Tp::*__fun_type)(void);
628public:
629 explicit mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
630 void operator()(_Tp& __r) const { (__r.*_M_f)(); }
631private:
633};
634
635template <class _Tp>
636class const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
637 typedef void (_Tp::*__fun_type)(void) const;
638public:
639 explicit const_mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
640 void operator()(const _Tp& __r) const { (__r.*_M_f)(); }
641private:
643};
644
645template <class _Tp, class _Arg>
646class mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> {
647 typedef void (_Tp::*__fun_type)(_Arg);
648public:
649 explicit mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
650 void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
651private:
653};
654
655template <class _Tp, class _Arg>
656class const_mem_fun1_t<void, _Tp, _Arg>
657 : public binary_function<const _Tp*,_Arg,void> {
658 typedef void (_Tp::*__fun_type)(_Arg) const;
659public:
660 explicit const_mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
661 void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
662private:
664};
665
666template <class _Tp, class _Arg>
667class mem_fun1_ref_t<void, _Tp, _Arg>
668 : public binary_function<_Tp,_Arg,void> {
669 typedef void (_Tp::*__fun_type)(_Arg);
670public:
671 explicit mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
672 void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
673private:
675};
676
677template <class _Tp, class _Arg>
678class const_mem_fun1_ref_t<void, _Tp, _Arg>
679 : public binary_function<_Tp,_Arg,void> {
680 typedef void (_Tp::*__fun_type)(_Arg) const;
681public:
682 explicit const_mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
683 void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
684private:
686};
687
688template <class _Arg>
689class pointer_to_unary_function<_Arg, void> : public unary_function<_Arg, void> {
690 typedef void (*__fun_type)(_Arg);
691 __fun_type _M_ptr;
692public:
694 explicit pointer_to_unary_function(__fun_type __x) : _M_ptr(__x) {}
695 void operator()(_Arg __x) const { _M_ptr(__x); }
696};
697
698template <class _Arg1, class _Arg2>
699class pointer_to_binary_function<_Arg1, _Arg2, void> : public binary_function<_Arg1,_Arg2,void> {
700 typedef void (*__fun_type)(_Arg1, _Arg2);
701 __fun_type _M_ptr;
702public:
704 explicit pointer_to_binary_function(__fun_type __x) : _M_ptr(__x) {}
705 void operator()(_Arg1 __x, _Arg2 __y) const { _M_ptr(__x, __y); }
706};
707
708# endif
709
710#endif
711
712#if !defined (_STLP_MEMBER_POINTER_PARAM_BUG)
713// Mem_fun adaptor helper functions. There are only two:
714// mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref
715// are provided for backward compatibility, but they are no longer
716// part of the C++ standard.)
717
718template <class _Result, class _Tp>
720mem_fun(_Result (_Tp::*__f)()) { return mem_fun_t<_Result,_Tp>(__f); }
721
722template <class _Result, class _Tp>
724mem_fun(_Result (_Tp::*__f)() const) { return const_mem_fun_t<_Result,_Tp>(__f); }
725
726template <class _Result, class _Tp>
728mem_fun_ref(_Result (_Tp::*__f)()) { return mem_fun_ref_t<_Result,_Tp>(__f); }
729
730template <class _Result, class _Tp>
732mem_fun_ref(_Result (_Tp::*__f)() const) { return const_mem_fun_ref_t<_Result,_Tp>(__f); }
733
734template <class _Result, class _Tp, class _Arg>
736mem_fun(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); }
737
738template <class _Result, class _Tp, class _Arg>
740mem_fun(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); }
741
742template <class _Result, class _Tp, class _Arg>
744mem_fun_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
745
746template <class _Result, class _Tp, class _Arg>
748mem_fun_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
749
750# if !(defined (_STLP_NO_EXTENSIONS) || defined (_STLP_NO_ANACHRONISMS))
751// mem_fun1 and mem_fun1_ref are no longer part of the C++ standard,
752// but they are provided for backward compatibility.
753template <class _Result, class _Tp, class _Arg>
755mem_fun1(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); }
756
757template <class _Result, class _Tp, class _Arg>
759mem_fun1(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); }
760
761template <class _Result, class _Tp, class _Arg>
763mem_fun1_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
764
765template <class _Result, class _Tp, class _Arg>
767mem_fun1_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
768
769# endif
770
771#endif
772
773template <class _Arg, class _Result>
775ptr_fun(_Result (*__f)(_Arg))
777
778template <class _Arg1, class _Arg2, class _Result>
780ptr_fun(_Result (*__f)(_Arg1, _Arg2))
782
mem_fun1_t< _Result, _Tp, _Arg > mem_fun1(_Result(_Tp::*__f)(_Arg))
pointer_to_unary_function< _Arg, _Result > ptr_fun(_Result(*__f)(_Arg))
mem_fun1_ref_t< _Result, _Tp, _Arg > mem_fun1_ref(_Result(_Tp::*__f)(_Arg))
mem_fun_ref_t< _Result, _Tp > mem_fun_ref(_Result(_Tp::*__f)())
mem_fun_t< _Result, _Tp > mem_fun(_Result(_Tp::*__f)())
_Ret operator()(const _Tp &__r, _Arg __x) const
_Ret(_Tp::* __fun_type)(_Arg) const
const_mem_fun1_ref_t(__fun_type __pf)
_Ret operator()(const _Tp *__p, _Arg __x) const
const_mem_fun1_t(__fun_type __pf)
_Ret(_Tp::* __fun_type)(_Arg) const
_Ret operator()(const _Tp &__r) const
const_mem_fun_ref_t(__fun_type __pf)
_Ret(_Tp::* __fun_type)(void) const
_Ret operator()(const _Tp *__p) const
_Ret(_Tp::* __fun_type)(void) const
const_mem_fun_t(__fun_type __pf)
mem_fun1_ref_t(__fun_type __pf)
_Ret operator()(_Tp &__r, _Arg __x) const
_Ret(_Tp::* __fun_type)(_Arg)
_Ret operator()(_Tp *__p, _Arg __x) const
mem_fun1_t(__fun_type __pf)
_Ret(_Tp::* __fun_type)(_Arg)
__fun_type _M_f
_Ret operator()(_Tp &__r) const
_Ret(_Tp::* __fun_type)(void)
mem_fun_ref_t(__fun_type __pf)
mem_fun_t(__fun_type __pf)
_Ret(_Tp::* __fun_type)(void)
_Ret operator()(_Tp *__p) const
__fun_type _M_f
_Result operator()(_Arg1 __x, _Arg2 __y) const
pointer_to_binary_function(_Result(*__x)(_Arg1, _Arg2))
_Result(* _M_ptr)(_Arg1, _Arg2)
_Result operator()(_Arg __x) const
pointer_to_unary_function(_Result(*__x)(_Arg))
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
#define _STLP_PSPEC3(t1, t2, t3)
Definition: features.h:1028
#define _STLP_PSPEC2(t1, t2)
Definition: features.h:1027
#define _STLP_TEMPLATE
Definition: features.h:616
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503