]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/functional/index.html
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / functional / index.html
CommitLineData
7c673cae
FG
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
3<html>
4<head>
5 <meta http-equiv="Content-Language" content="en-us">
6 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
7 <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
8 <meta name="ProgId" content="FrontPage.Editor.Document">
9
10 <title>Boost Function Object Adapter Library</title>
11</head>
12
13<body bgcolor="#FFFFFF" text="#000000">
14 <table border="1" bgcolor="#007F7F" cellpadding="2" summary="">
15 <tr>
16 <td bgcolor="#FFFFFF"><img src="../../boost.png" alt=
17 "boost.png (6897 bytes)" width="277" height="86"></td>
18
19 <td><a href="../../index.htm"><font face="Arial" color=
20 "#FFFFFF"><big>Home</big></font></a></td>
21
22 <td><a href="../libraries.htm"><font face="Arial" color=
23 "#FFFFFF"><big>Libraries</big></font></a></td>
24
25 <td><a href="http://www.boost.org/people/people.htm"><font face="Arial" color=
26 "#FFFFFF"><big>People</big></font></a></td>
27
28 <td><a href="http://www.boost.org/more/faq.htm"><font face="Arial" color=
29 "#FFFFFF"><big>FAQ</big></font></a></td>
30
31 <td><a href="../../more/index.htm"><font face="Arial" color=
32 "#FFFFFF"><big>More</big></font></a></td>
33 </tr>
34 </table>
35
36 <h1>Improved Function Object Adapters</h1>
37
38 <p>The header <a href="../../boost/functional.hpp">functional.hpp</a>
39 provides enhancements to the function object adapters specified in the C++
40 Standard Library (sections 20.3.5, through to 20.3.8). The enhancements are
41 principally possible due to two changes:</p>
42
43 <ol>
44 <li>We use the Boost <tt><a href=
45 "../utility/call_traits.htm">call_traits</a></tt> templates to avoid the
46 problem of <a href="binders.html#refref">references to references</a>,
47 and to improve the efficiency of <a href="mem_fun.html#args">parameter
48 passing</a>.</li>
49
50 <li>We use two <a href="function_traits.html">function object traits</a>
51 class templates to avoid the need for <tt><a href=
52 "ptr_fun.html">ptr_fun</a></tt> with the adapters in this library.</li>
53 </ol>
54
55 <h3>Contents</h3>
56
57 <p>The header contains the following function and class templates:</p>
58
59 <table border="1" cellpadding="5" summary="">
60 <tr>
61 <th align="left"><a href="function_traits.html">Function object
62 traits</a></th>
63
64 <td valign="top"><tt>unary_traits<br>
65 binary_traits</tt></td>
66
67 <td valign="top">Used to determine the types of function objects' and
68 functions' arguments. Eliminate the necessity for
69 <tt>ptr_fun</tt>.</td>
70 </tr>
71
72 <tr>
73 <th align="left"><a href="negators.html">Negators</a></th>
74
75 <td valign="top"><tt>unary_negate<br>
76 binary_negate<br>
77 not1<br>
78 not2</tt></td>
79
80 <td valign="top">Based on section 20.3.5 of the standard.</td>
81 </tr>
82
83 <tr>
84 <th align="left"><a href="binders.html">Binders</a></th>
85
86 <td valign="top"><tt>binder1st<br>
87 binder2nd<br>
88 bind1st<br>
89 bind2nd</tt></td>
90
91 <td valign="top">Based on section 20.3.6 of the standard.</td>
92 </tr>
93
94 <tr>
95 <th align="left"><a href="ptr_fun.html">Adapters for pointers to
96 functions</a></th>
97
98 <td valign="top"><tt>pointer_to_unary_function<br>
99 pointer_to_binary_function<br>
100 ptr_fun</tt></td>
101
102 <td valign="top">Based on section 20.3.7 of the standard. Not required
103 for use with this library since the binders and negators can adapt
104 functions, but may be needed with third party adapters.</td>
105 </tr>
106
107 <tr>
108 <th align="left"><a href="mem_fun.html">Adapters for pointers to member
109 functions</a></th>
110
111 <td valign="top"><tt>mem_fun_t<br>
112 mem_fun1_t<br>
113 const_mem_fun_t<br>
114 const_mem_fun1_t<br>
115 mem_fun_ref_t<br>
116 mem_fun1_ref_t<br>
117 const_mem_fun_ref_t<br>
118 const_mem_fun1_ref_t<br>
119 mem_fun<br>
120 mem_fun_ref</tt></td>
121
122 <td valign="top">Based on section 20.3.8 of the standard.</td>
123 </tr>
1e59de90
TL
124
125 <tr>
126 <th align="left"><a href="identity.html">Identity</a></th>
127 <td valign="top"><tt>identity</tt></td>
128 <td valign="top">[func.identity] in ISO/IEC 14882:2020</td>
129 </tr>
7c673cae
FG
130 </table>
131
132 <h3>Usage</h3>
133
134 <p>Using these adapters should be pretty much the same as using the
135 standard function object adapters; the only differences are that you need
136 to write <tt>boost::</tt> instead of <tt>std::</tt>, and that you will get
137 fewer headaches.</p>
138
139 <p>For example, suppose you had a <tt>Person</tt> class that contained a
140 <tt>set_name</tt> function:</p>
141
142 <blockquote>
143 <pre>
144class Person
145{
146 public:
147 void set_name(const std::string &amp;name);
148 // ...
149};
150</pre>
151 </blockquote>
152
153 <p>You could rename a bunch of people in a collection, <tt>c</tt>, by
154 writing</p>
155
156 <blockquote>
157 <pre>
158std::for_each(c.begin(), c.end(),
159 boost::bind2nd(boost::mem_fun_ref(&amp;Person::set_name), "Fred"));
160</pre>
161 </blockquote>
162
163 <p>If the standard adapters had been used instead then this code would
164 normally fail to compile, because <tt>set_name</tt> takes a reference
165 argument. Refer to the comments in the <a href="binders.html#refref">binder
166 documentation</a> to explain why this is so.</p>
167
168 <h3>Compiler Compatibility</h3>
169
170 <p>The header and <a href="test/function_test.cpp">test program</a> have been
171 compiled with the following compilers:</p>
172
173 <table border="1" cellpadding="5" summary="">
174 <tr>
175 <th>Compiler</th>
176
177 <th>Comments</th>
178 </tr>
179
180 <tr>
181 <td valign="top">Borland C++Builder 4 Update 2</td>
182
183 <td valign="top">No known issues.</td>
184 </tr>
185
186 <tr>
187 <td valign="top">Borland C++ 5.5</td>
188
189 <td valign="top">No known issues.</td>
190 </tr>
191
192 <tr>
193 <td valign="top">g++ 2.95.2</td>
194
195 <td valign="top">No known issues.</td>
196 </tr>
197
198 <tr>
199 <td valign="top">Microsoft Visual C++ Service Pack 3</td>
200
201 <td valign="top">
202 Compiler lacks partial specialisation, so this library offers little
203 more than is provided by the standard adapters:
204
205 <ul>
206 <li>The <tt>call_traits</tt> mechanism is unable to prevent
207 references to references, and so the adapters in this library will
208 be usable in fewer situations.</li>
209
210 <li>The <tt>function_traits</tt> mechanism is unable to determine
211 the argument and result types of functions, therefore
212 <tt>ptr_fun</tt> continues to be required to adapt functions.</li>
213 </ul>
214 </td>
215 </tr>
216 </table>
217
218 <h3>Future Directions</h3>
219
220 <p>This library's primary focus is to solve the problem of references to
221 references while maintaining as much compatibility as possible with the
222 standard library. This allows you to use the techniques you read about in
223 books and magazines with many of today's compilers.</p>
224
225 <p>In the longer term, even better solutions are likely:</p>
226
227 <ol>
228 <li>Several Boost members are working on expression template libraries.
229 These will allow a more natural syntax for combining and adapting
230 functions. As this is a new technology, it may be some time before it has
231 matured and is widely supported by major compilers but shows great
232 promise. In the meantime, the functional.hpp library fills the gap.</li>
233
234 <li>The Standard Committee has recognised the problem of references to
235 references occurring during template instantiation and has moved to fix
236 the standard (see the <a href=
237 "http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#106">C++
238 standard core language active issues list</a>).</li>
239 </ol>
240
241 <h3>Author</h3>
242
243 <p><a href="http://www.boost.org/people/mark_rodgers.htm">Mark Rodgers</a></p>
244
245 <h3>Acknowledgements</h3>
246
247 <p>Thanks to <a href="http://www.boost.org/people/john_maddock.htm">John Maddock</a> for
248 suggesting the mechanism that allowed the function objects traits to work
249 correctly. <a href="http://www.boost.org/people/jens_maurer.htm">Jens Maurer</a> provided
250 invaluable feedback during the <a href=
251 "http://www.boost.org/more/formal_review_process.htm">formal review process</a>.</p>
252 <hr>
253
254 <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
255 "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
256 height="31" width="88"></a></p>
257
258 <p>Revised
259 <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->02
260 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38510" --></p>
261
262 <p><i>Copyright &copy; 2000 Cadenza New Zealand Ltd.</i></p>
263
264 <p><i>Distributed under the Boost Software License, Version 1.0. (See
265 accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
266 copy at <a href=
267 "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
268</body>
269</html>