From Jason Turner

[depr.function.objects]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpztm2i3ae/{from.md → to.md} +0 -234
tmp/tmpztm2i3ae/{from.md → to.md} RENAMED
@@ -1,234 +0,0 @@
1
- ## Function objects <a id="depr.function.objects">[[depr.function.objects]]</a>
2
-
3
- ### Base <a id="depr.base">[[depr.base]]</a>
4
-
5
- The class templates `unary_function` and `binary_function` are
6
- deprecated. A program shall not declare specializations of these
7
- templates.
8
-
9
- ``` cpp
10
- namespace std {
11
- template <class Arg, class Result>
12
- struct unary_function {
13
- typedef Arg argument_type;
14
- typedef Result result_type;
15
- };
16
- }
17
- ```
18
-
19
- ``` cpp
20
- namespace std {
21
- template <class Arg1, class Arg2, class Result>
22
- struct binary_function {
23
- typedef Arg1 first_argument_type;
24
- typedef Arg2 second_argument_type;
25
- typedef Result result_type;
26
- };
27
- }
28
- ```
29
-
30
- ### Function adaptors <a id="depr.adaptors">[[depr.adaptors]]</a>
31
-
32
- The adaptors ptr_fun, mem_fun, mem_fun_ref, and their corresponding
33
- return types are deprecated. The function template `bind`  [[func.bind]]
34
- provides a better solution.
35
-
36
- #### Adaptors for pointers to functions <a id="depr.function.pointer.adaptors">[[depr.function.pointer.adaptors]]</a>
37
-
38
- To allow pointers to (unary and binary) functions to work with function
39
- adaptors the library provides:
40
-
41
- ``` cpp
42
- template <class Arg, class Result>
43
- class pointer_to_unary_function : public unary_function<Arg, Result> {
44
- public:
45
- explicit pointer_to_unary_function(Result (*f)(Arg));
46
- Result operator()(Arg x) const;
47
- };
48
- ```
49
-
50
- `operator()` returns `f(x)`.
51
-
52
- ``` cpp
53
- template <class Arg, class Result>
54
- pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg));
55
- ```
56
-
57
- *Returns:* `pointer_to_unary_function<Arg, Result>(f)`.
58
-
59
- ``` cpp
60
- template <class Arg1, class Arg2, class Result>
61
- class pointer_to_binary_function :
62
- public binary_function<Arg1,Arg2,Result> {
63
- public:
64
- explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
65
- Result operator()(Arg1 x, Arg2 y) const;
66
- };
67
- ```
68
-
69
- `operator()` returns `f(x,y)`.
70
-
71
- ``` cpp
72
- template <class Arg1, class Arg2, class Result>
73
- pointer_to_binary_function<Arg1,Arg2,Result>
74
- ptr_fun(Result (*f)(Arg1, Arg2));
75
- ```
76
-
77
- *Returns:* `pointer_to_binary_function<Arg1,Arg2,Result>(f)`.
78
-
79
- ``` cpp
80
- int compare(const char*, const char*);
81
- replace_if(v.begin(), v.end(),
82
- not1(bind2nd(ptr_fun(compare), "abc")), "def");
83
- ```
84
-
85
- replaces each `abc` with `def` in sequence `v`.
86
-
87
- #### Adaptors for pointers to members <a id="depr.member.pointer.adaptors">[[depr.member.pointer.adaptors]]</a>
88
-
89
- The purpose of the following is to provide the same facilities for
90
- pointer to members as those provided for pointers to functions in 
91
- [[depr.function.pointer.adaptors]].
92
-
93
- ``` cpp
94
- template <class S, class T> class mem_fun_t
95
- : public unary_function<T*, S> {
96
- public:
97
- explicit mem_fun_t(S (T::*p)());
98
- S operator()(T* p) const;
99
- };
100
- ```
101
-
102
- `mem_fun_t` calls the member function it is initialized with given a
103
- pointer argument.
104
-
105
- ``` cpp
106
- template <class S, class T, class A> class mem_fun1_t
107
- : public binary_function<T*, A, S> {
108
- public:
109
- explicit mem_fun1_t(S (T::*p)(A));
110
- S operator()(T* p, A x) const;
111
- };
112
- ```
113
-
114
- `mem_fun1_t` calls the member function it is initialized with given a
115
- pointer argument and an additional argument of the appropriate type.
116
-
117
- ``` cpp
118
- template<class S, class T> mem_fun_t<S,T>
119
- mem_fun(S (T::*f)());
120
- template<class S, class T, class A> mem_fun1_t<S,T,A>
121
- mem_fun(S (T::*f)(A));
122
- ```
123
-
124
- `mem_fun(&X::f)` returns an object through which `X::f` can be called
125
- given a pointer to an `X` followed by the argument required for `f` (if
126
- any).
127
-
128
- ``` cpp
129
- template <class S, class T> class mem_fun_ref_t
130
- : public unary_function<T, S> {
131
- public:
132
- explicit mem_fun_ref_t(S (T::*p)());
133
- S operator()(T& p) const;
134
- };
135
- ```
136
-
137
- `mem_fun_ref_t` calls the member function it is initialized with given a
138
- reference argument.
139
-
140
- ``` cpp
141
- template <class S, class T, class A> class mem_fun1_ref_t
142
- : public binary_function<T, A, S> {
143
- public:
144
- explicit mem_fun1_ref_t(S (T::*p)(A));
145
- S operator()(T& p, A x) const;
146
- };
147
- ```
148
-
149
- `mem_fun1_ref_t` calls the member function it is initialized with given
150
- a reference argument and an additional argument of the appropriate type.
151
-
152
- ``` cpp
153
- template<class S, class T> mem_fun_ref_t<S,T>
154
- mem_fun_ref(S (T::*f)());
155
- template<class S, class T, class A> mem_fun1_ref_t<S,T,A>
156
- mem_fun_ref(S (T::*f)(A));
157
- ```
158
-
159
- `mem_fun_ref(&X::f)` returns an object through which `X::f` can be
160
- called given a reference to an `X` followed by the argument required for
161
- `f` (if any).
162
-
163
- ``` cpp
164
- template <class S, class T> class const_mem_fun_t
165
- : public unary_function<const T*, S> {
166
- public:
167
- explicit const_mem_fun_t(S (T::*p)() const);
168
- S operator()(const T* p) const;
169
- };
170
- ```
171
-
172
- `const_mem_fun_t` calls the member function it is initialized with given
173
- a pointer argument.
174
-
175
- ``` cpp
176
- template <class S, class T, class A> class const_mem_fun1_t
177
- : public binary_function<const T*, A, S> {
178
- public:
179
- explicit const_mem_fun1_t(S (T::*p)(A) const);
180
- S operator()(const T* p, A x) const;
181
- };
182
- ```
183
-
184
- `const_mem_fun1_t` calls the member function it is initialized with
185
- given a pointer argument and an additional argument of the appropriate
186
- type.
187
-
188
- ``` cpp
189
- template<class S, class T> const_mem_fun_t<S,T>
190
- mem_fun(S (T::*f)() const);
191
- template<class S, class T, class A> const_mem_fun1_t<S,T,A>
192
- mem_fun(S (T::*f)(A) const);
193
- ```
194
-
195
- `mem_fun(&X::f)` returns an object through which `X::f` can be called
196
- given a pointer to an `X` followed by the argument required for `f` (if
197
- any).
198
-
199
- ``` cpp
200
- template <class S, class T> class const_mem_fun_ref_t
201
- : public unary_function<T, S> {
202
- public:
203
- explicit const_mem_fun_ref_t(S (T::*p)() const);
204
- S operator()(const T& p) const;
205
- };
206
- ```
207
-
208
- `const_mem_fun_ref_t` calls the member function it is initialized with
209
- given a reference argument.
210
-
211
- ``` cpp
212
- template <class S, class T, class A> class const_mem_fun1_ref_t
213
- : public binary_function<T, A, S> {
214
- public:
215
- explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
216
- S operator()(const T& p, A x) const;
217
- };
218
- ```
219
-
220
- `const_mem_fun1_ref_t` calls the member function it is initialized with
221
- given a reference argument and an additional argument of the appropriate
222
- type.
223
-
224
- ``` cpp
225
- template<class S, class T> const_mem_fun_ref_t<S,T>
226
- mem_fun_ref(S (T::*f)() const);
227
- template<class S, class T, class A> const_mem_fun1_ref_t<S,T,A>
228
- mem_fun_ref(S (T::*f)(A) const);
229
- ```
230
-
231
- `mem_fun_ref(&X::f)` returns an object through which `X::f` can be
232
- called given a reference to an `X` followed by the argument required for
233
- `f` (if any).
234
-