]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | <!-- | |
3 | Copyright Daniel James 2005-2009 | |
4 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | --> | |
7 | ||
8 | <library-reference> | |
9 | <section id="hash.reference.specification"> | |
10 | <para>For the full specification, see section 6.3 of the | |
11 | <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">C++ Standard Library Technical Report</ulink> | |
12 | and issue 6.18 of the | |
13 | <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf">Library Extension Technical Report Issues List</ulink> (page 63). | |
14 | </para> | |
15 | </section> | |
16 | <header name="boost/functional/hash.hpp"> | |
17 | <para> | |
18 | Defines <code><classname>boost::hash</classname></code>, | |
19 | and helper functions. | |
20 | </para> | |
21 | ||
22 | <namespace name="boost"> | |
23 | ||
24 | <!-- | |
25 | boost::hash | |
26 | --> | |
27 | ||
28 | <struct name="hash"> | |
29 | <template> | |
30 | <template-type-parameter name="T"/> | |
31 | </template> | |
32 | ||
33 | <inherit access="public"> | |
34 | <classname>std::unary_function<T, std::size_t></classname> | |
35 | </inherit> | |
36 | ||
37 | <purpose><simpara>A <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">TR1</ulink> compliant hash function object.</simpara></purpose> | |
38 | ||
39 | <method name="operator()" cv="const"> | |
40 | <type>std::size_t</type> | |
41 | <parameter name="val"> | |
42 | <paramtype>T const&</paramtype> | |
43 | </parameter> | |
44 | <returns><para> | |
45 | <programlisting><functionname>hash_value</functionname>(val)</programlisting> | |
46 | </para></returns> | |
47 | <notes> | |
48 | <para> | |
49 | The call to <code><functionname>hash_value</functionname></code> | |
50 | is unqualified, so that custom overloads can be | |
51 | found via argument dependent lookup. | |
52 | </para> | |
53 | <para> | |
54 | This is not defined when the macro <code>BOOST_HASH_NO_EXTENSIONS</code> | |
55 | is defined. The specializations are still defined, so only the specializations | |
56 | required by TR1 are defined. | |
57 | </para> | |
58 | </notes> | |
59 | <throws><para> | |
60 | Only throws if | |
61 | <code><functionname>hash_value</functionname>(T)</code> throws. | |
62 | </para></throws> | |
63 | </method> | |
64 | </struct> | |
65 | ||
66 | <struct-specialization name="hash"> | |
67 | <template></template> | |
68 | <specialization> | |
69 | <template-arg>bool</template-arg> | |
70 | </specialization> | |
71 | <method name="operator()" cv="const"> | |
72 | <type>std::size_t</type> | |
73 | <parameter name="val"> | |
74 | <paramtype>bool</paramtype> | |
75 | </parameter> | |
76 | <returns> | |
77 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
78 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
79 | </returns> | |
80 | <throws><para>Doesn't throw</para></throws> | |
81 | </method> | |
82 | </struct-specialization> | |
83 | ||
84 | <struct-specialization name="hash"> | |
85 | <template></template> | |
86 | <specialization> | |
87 | <template-arg>char</template-arg> | |
88 | </specialization> | |
89 | <method name="operator()" cv="const"> | |
90 | <type>std::size_t</type> | |
91 | <parameter name="val"> | |
92 | <paramtype>char</paramtype> | |
93 | </parameter> | |
94 | <returns> | |
95 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
96 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
97 | </returns> | |
98 | <throws><para>Doesn't throw</para></throws> | |
99 | </method> | |
100 | </struct-specialization> | |
101 | ||
102 | <struct-specialization name="hash"> | |
103 | <template></template> | |
104 | <specialization> | |
105 | <template-arg>signed char</template-arg> | |
106 | </specialization> | |
107 | <method name="operator()" cv="const"> | |
108 | <type>std::size_t</type> | |
109 | <parameter name="val"> | |
110 | <paramtype>signed char</paramtype> | |
111 | </parameter> | |
112 | <returns> | |
113 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
114 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
115 | </returns> | |
116 | <throws><para>Doesn't throw</para></throws> | |
117 | </method> | |
118 | </struct-specialization> | |
119 | ||
120 | <struct-specialization name="hash"> | |
121 | <template></template> | |
122 | <specialization> | |
123 | <template-arg>unsigned char</template-arg> | |
124 | </specialization> | |
125 | <method name="operator()" cv="const"> | |
126 | <type>std::size_t</type> | |
127 | <parameter name="val"> | |
128 | <paramtype>unsigned char</paramtype> | |
129 | </parameter> | |
130 | <returns> | |
131 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
132 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
133 | </returns> | |
134 | <throws><para>Doesn't throw</para></throws> | |
135 | </method> | |
136 | </struct-specialization> | |
137 | ||
138 | <struct-specialization name="hash"> | |
139 | <template></template> | |
140 | <specialization> | |
141 | <template-arg>wchar_t</template-arg> | |
142 | </specialization> | |
143 | <method name="operator()" cv="const"> | |
144 | <type>std::size_t</type> | |
145 | <parameter name="val"> | |
146 | <paramtype>wchar_t</paramtype> | |
147 | </parameter> | |
148 | <returns> | |
149 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
150 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
151 | </returns> | |
152 | <throws><para>Doesn't throw</para></throws> | |
153 | </method> | |
154 | </struct-specialization> | |
155 | ||
156 | <struct-specialization name="hash"> | |
157 | <template></template> | |
158 | <specialization> | |
159 | <template-arg>short</template-arg> | |
160 | </specialization> | |
161 | <method name="operator()" cv="const"> | |
162 | <type>std::size_t</type> | |
163 | <parameter name="val"> | |
164 | <paramtype>short</paramtype> | |
165 | </parameter> | |
166 | <returns> | |
167 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
168 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
169 | </returns> | |
170 | <throws><para>Doesn't throw</para></throws> | |
171 | </method> | |
172 | </struct-specialization> | |
173 | ||
174 | <struct-specialization name="hash"> | |
175 | <template></template> | |
176 | <specialization> | |
177 | <template-arg>unsigned short</template-arg> | |
178 | </specialization> | |
179 | <method name="operator()" cv="const"> | |
180 | <type>std::size_t</type> | |
181 | <parameter name="val"> | |
182 | <paramtype>unsigned short</paramtype> | |
183 | </parameter> | |
184 | <returns> | |
185 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
186 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
187 | </returns> | |
188 | <throws><para>Doesn't throw</para></throws> | |
189 | </method> | |
190 | </struct-specialization> | |
191 | ||
192 | <struct-specialization name="hash"> | |
193 | <template></template> | |
194 | <specialization> | |
195 | <template-arg>int</template-arg> | |
196 | </specialization> | |
197 | <method name="operator()" cv="const"> | |
198 | <type>std::size_t</type> | |
199 | <parameter name="val"> | |
200 | <paramtype>int</paramtype> | |
201 | </parameter> | |
202 | <returns> | |
203 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
204 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
205 | </returns> | |
206 | <throws><para>Doesn't throw</para></throws> | |
207 | </method> | |
208 | </struct-specialization> | |
209 | ||
210 | <struct-specialization name="hash"> | |
211 | <template></template> | |
212 | <specialization> | |
213 | <template-arg>unsigned int</template-arg> | |
214 | </specialization> | |
215 | <method name="operator()" cv="const"> | |
216 | <type>std::size_t</type> | |
217 | <parameter name="val"> | |
218 | <paramtype>unsigned int</paramtype> | |
219 | </parameter> | |
220 | <returns> | |
221 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
222 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
223 | </returns> | |
224 | <throws><para>Doesn't throw</para></throws> | |
225 | </method> | |
226 | </struct-specialization> | |
227 | ||
228 | <struct-specialization name="hash"> | |
229 | <template></template> | |
230 | <specialization> | |
231 | <template-arg>long</template-arg> | |
232 | </specialization> | |
233 | <method name="operator()" cv="const"> | |
234 | <type>std::size_t</type> | |
235 | <parameter name="val"> | |
236 | <paramtype>long</paramtype> | |
237 | </parameter> | |
238 | <returns> | |
239 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
240 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
241 | </returns> | |
242 | <throws><para>Doesn't throw</para></throws> | |
243 | </method> | |
244 | </struct-specialization> | |
245 | ||
246 | <struct-specialization name="hash"> | |
247 | <template></template> | |
248 | <specialization> | |
249 | <template-arg>unsigned long</template-arg> | |
250 | </specialization> | |
251 | <method name="operator()" cv="const"> | |
252 | <type>std::size_t</type> | |
253 | <parameter name="val"> | |
254 | <paramtype>unsigned long</paramtype> | |
255 | </parameter> | |
256 | <returns> | |
257 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
258 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
259 | </returns> | |
260 | <throws><para>Doesn't throw</para></throws> | |
261 | </method> | |
262 | </struct-specialization> | |
263 | ||
264 | <struct-specialization name="hash"> | |
265 | <template></template> | |
266 | <specialization> | |
267 | <template-arg>long long</template-arg> | |
268 | </specialization> | |
269 | <method name="operator()" cv="const"> | |
270 | <type>std::size_t</type> | |
271 | <parameter name="val"> | |
272 | <paramtype>long long</paramtype> | |
273 | </parameter> | |
274 | <returns> | |
275 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
276 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
277 | </returns> | |
278 | <throws><para>Doesn't throw</para></throws> | |
279 | </method> | |
280 | </struct-specialization> | |
281 | ||
282 | <struct-specialization name="hash"> | |
283 | <template></template> | |
284 | <specialization> | |
285 | <template-arg>unsigned long long</template-arg> | |
286 | </specialization> | |
287 | <method name="operator()" cv="const"> | |
288 | <type>std::size_t</type> | |
289 | <parameter name="val"> | |
290 | <paramtype>unsigned long long</paramtype> | |
291 | </parameter> | |
292 | <returns> | |
293 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
294 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
295 | </returns> | |
296 | <throws><para>Doesn't throw</para></throws> | |
297 | </method> | |
298 | </struct-specialization> | |
299 | ||
300 | <struct-specialization name="hash"> | |
301 | <template></template> | |
302 | <specialization> | |
303 | <template-arg>float</template-arg> | |
304 | </specialization> | |
305 | <method name="operator()" cv="const"> | |
306 | <type>std::size_t</type> | |
307 | <parameter name="val"> | |
308 | <paramtype>float</paramtype> | |
309 | </parameter> | |
310 | <returns> | |
311 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
312 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
313 | </returns> | |
314 | <throws><para>Doesn't throw</para></throws> | |
315 | </method> | |
316 | </struct-specialization> | |
317 | ||
318 | <struct-specialization name="hash"> | |
319 | <template></template> | |
320 | <specialization> | |
321 | <template-arg>double</template-arg> | |
322 | </specialization> | |
323 | <method name="operator()" cv="const"> | |
324 | <type>std::size_t</type> | |
325 | <parameter name="val"> | |
326 | <paramtype>double</paramtype> | |
327 | </parameter> | |
328 | <returns> | |
329 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
330 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
331 | </returns> | |
332 | <throws><para>Doesn't throw</para></throws> | |
333 | </method> | |
334 | </struct-specialization> | |
335 | ||
336 | <struct-specialization name="hash"> | |
337 | <template></template> | |
338 | <specialization> | |
339 | <template-arg>long double</template-arg> | |
340 | </specialization> | |
341 | <method name="operator()" cv="const"> | |
342 | <type>std::size_t</type> | |
343 | <parameter name="val"> | |
344 | <paramtype>long double</paramtype> | |
345 | </parameter> | |
346 | <returns> | |
347 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
348 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
349 | </returns> | |
350 | <throws><para>Doesn't throw</para></throws> | |
351 | </method> | |
352 | </struct-specialization> | |
353 | ||
354 | <struct-specialization name="hash"> | |
355 | <template></template> | |
356 | <specialization> | |
357 | <template-arg>std::string</template-arg> | |
358 | </specialization> | |
359 | <method name="operator()" cv="const"> | |
360 | <type>std::size_t</type> | |
361 | <parameter name="val"> | |
362 | <paramtype>std::string const&</paramtype> | |
363 | </parameter> | |
364 | <returns> | |
365 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
366 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
367 | </returns> | |
368 | <throws><para>Doesn't throw</para></throws> | |
369 | </method> | |
370 | </struct-specialization> | |
371 | ||
372 | <struct-specialization name="hash"> | |
373 | <template></template> | |
374 | <specialization> | |
375 | <template-arg>std::wstring</template-arg> | |
376 | </specialization> | |
377 | <method name="operator()" cv="const"> | |
378 | <type>std::size_t</type> | |
379 | <parameter name="val"> | |
380 | <paramtype>std::wstring const&</paramtype> | |
381 | </parameter> | |
382 | <returns> | |
383 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
384 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
385 | </returns> | |
386 | <throws><para>Doesn't throw</para></throws> | |
387 | </method> | |
388 | </struct-specialization> | |
389 | ||
390 | <struct-specialization name="hash"> | |
391 | <template> | |
392 | <template-type-parameter name="T"/> | |
393 | </template> | |
394 | <specialization> | |
395 | <template-arg>T*</template-arg> | |
396 | </specialization> | |
397 | <method name="operator()" cv="const"> | |
398 | <type>std::size_t</type> | |
399 | <parameter name="val"> | |
400 | <paramtype>T*</paramtype> | |
401 | </parameter> | |
402 | <returns> | |
403 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
404 | </returns> | |
405 | <throws><para>Doesn't throw</para></throws> | |
406 | </method> | |
407 | </struct-specialization> | |
408 | ||
409 | <free-function-group name="Support functions (Boost extension)."> | |
410 | ||
411 | <!-- | |
412 | boost::hash_combine | |
413 | --> | |
414 | ||
415 | <function name="hash_combine"> | |
416 | <template> | |
417 | <template-type-parameter name="T"/> | |
418 | </template> | |
419 | <type>void</type> | |
420 | <parameter name="seed"><paramtype>size_t &</paramtype></parameter> | |
421 | <parameter name="v"><paramtype>T const&</paramtype></parameter> | |
422 | <purpose><simpara> | |
423 | Called repeatedly to incrementally create a hash value from | |
424 | several variables. | |
425 | </simpara></purpose> | |
426 | <effects><programlisting>seed ^= <functionname>hash_value</functionname>(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);</programlisting></effects> | |
427 | <notes> | |
428 | <para><functionname>hash_value</functionname> is called without | |
429 | qualification, so that overloads can be found via ADL.</para> | |
430 | <para>This is an extension to TR1</para> | |
431 | </notes> | |
432 | <throws> | |
433 | Only throws if <functionname>hash_value</functionname>(T) throws. | |
434 | Strong exception safety, as long as <functionname>hash_value</functionname>(T) | |
435 | also has strong exception safety. | |
436 | </throws> | |
437 | </function> | |
438 | ||
439 | <!-- | |
440 | boost::hash_range | |
441 | --> | |
442 | ||
443 | <overloaded-function name="hash_range"> | |
444 | <signature> | |
445 | <template> | |
446 | <template-type-parameter name="It"/> | |
447 | </template> | |
448 | <type>std::size_t</type> | |
449 | <parameter name="first"><paramtype>It</paramtype></parameter> | |
450 | <parameter name="last"><paramtype>It</paramtype></parameter> | |
451 | </signature> | |
452 | ||
453 | <signature> | |
454 | <template> | |
455 | <template-type-parameter name="It"/> | |
456 | </template> | |
457 | <type>void</type> | |
458 | <parameter name="seed"><paramtype>std::size_t&</paramtype></parameter> | |
459 | <parameter name="first"><paramtype>It</paramtype></parameter> | |
460 | <parameter name="last"><paramtype>It</paramtype></parameter> | |
461 | </signature> | |
462 | ||
463 | <purpose><simpara> | |
464 | Calculate the combined hash value of the elements of an iterator | |
465 | range. | |
466 | </simpara></purpose> | |
467 | <effects> | |
468 | <para>For the two argument overload: | |
469 | <programlisting> | |
470 | size_t seed = 0; | |
471 | ||
472 | for(; first != last; ++first) | |
473 | { | |
474 | <functionname>hash_combine</functionname>(seed, *first); | |
475 | } | |
476 | ||
477 | return seed; | |
478 | </programlisting> | |
479 | </para>For the three arguments overload: | |
480 | <programlisting> | |
481 | for(; first != last; ++first) | |
482 | { | |
483 | <functionname>hash_combine</functionname>(seed, *first); | |
484 | } | |
485 | </programlisting> | |
486 | <para> | |
487 | </para> | |
488 | </effects> | |
489 | <notes> | |
490 | <para> | |
491 | <code>hash_range</code> is sensitive to the order of the elements | |
492 | so it wouldn't be appropriate to use this with an unordered | |
493 | container. | |
494 | </para> | |
495 | <para>This is an extension to TR1</para> | |
496 | </notes> | |
497 | <throws><para> | |
498 | Only throws if <code><functionname>hash_value</functionname>(std::iterator_traits<It>::value_type)</code> | |
499 | throws. <code>hash_range(std::size_t&, It, It)</code> has basic exception safety as long as | |
500 | <code><functionname>hash_value</functionname>(std::iterator_traits<It>::value_type)</code> | |
501 | has basic exception safety. | |
502 | </para></throws> | |
503 | </overloaded-function> | |
504 | ||
505 | </free-function-group> | |
506 | ||
507 | <free-function-group name="Overloadable hash implementation (Boost extension)."> | |
508 | ||
509 | <!-- | |
510 | boost::hash_value - integers | |
511 | --> | |
512 | ||
513 | <overloaded-function name="hash_value"> | |
514 | <purpose><simpara> | |
515 | Implementation of the hash function. | |
516 | </simpara></purpose> | |
517 | ||
518 | <signature> | |
519 | <type>std::size_t</type> | |
520 | <parameter name="val"><paramtype>bool</paramtype></parameter> | |
521 | </signature> | |
522 | ||
523 | <signature> | |
524 | <type>std::size_t</type> | |
525 | <parameter name="val"><paramtype>char</paramtype></parameter> | |
526 | </signature> | |
527 | ||
528 | <signature> | |
529 | <type>std::size_t</type> | |
530 | <parameter name="val"><paramtype>signed char</paramtype></parameter> | |
531 | </signature> | |
532 | ||
533 | <signature> | |
534 | <type>std::size_t</type> | |
535 | <parameter name="val"><paramtype>unsigned char</paramtype></parameter> | |
536 | </signature> | |
537 | ||
538 | <signature> | |
539 | <type>std::size_t</type> | |
540 | <parameter name="val"><paramtype>wchar_t</paramtype></parameter> | |
541 | </signature> | |
542 | ||
543 | <signature> | |
544 | <type>std::size_t</type> | |
545 | <parameter name="val"><paramtype>short</paramtype></parameter> | |
546 | </signature> | |
547 | ||
548 | <signature> | |
549 | <type>std::size_t</type> | |
550 | <parameter name="val"><paramtype>unsigned short</paramtype></parameter> | |
551 | </signature> | |
552 | ||
553 | <signature> | |
554 | <type>std::size_t</type> | |
555 | <parameter name="val"><paramtype>int</paramtype></parameter> | |
556 | </signature> | |
557 | ||
558 | <signature> | |
559 | <type>std::size_t</type> | |
560 | <parameter name="val"><paramtype>unsigned int</paramtype></parameter> | |
561 | </signature> | |
562 | ||
563 | <signature> | |
564 | <type>std::size_t</type> | |
565 | <parameter name="val"><paramtype>long</paramtype></parameter> | |
566 | </signature> | |
567 | ||
568 | <signature> | |
569 | <type>std::size_t</type> | |
570 | <parameter name="val"><paramtype>unsigned long</paramtype></parameter> | |
571 | </signature> | |
572 | ||
573 | <signature> | |
574 | <type>std::size_t</type> | |
575 | <parameter name="val"><paramtype>long long</paramtype></parameter> | |
576 | </signature> | |
577 | ||
578 | <signature> | |
579 | <type>std::size_t</type> | |
580 | <parameter name="val"><paramtype>unsigned long long</paramtype></parameter> | |
581 | </signature> | |
582 | ||
583 | <signature> | |
584 | <type>std::size_t</type> | |
585 | <parameter name="val"><paramtype>float</paramtype></parameter> | |
586 | </signature> | |
587 | ||
588 | <signature> | |
589 | <type>std::size_t</type> | |
590 | <parameter name="val"><paramtype>double</paramtype></parameter> | |
591 | </signature> | |
592 | ||
593 | <signature> | |
594 | <type>std::size_t</type> | |
595 | <parameter name="val"><paramtype>long double</paramtype></parameter> | |
596 | </signature> | |
597 | ||
598 | <signature> | |
599 | <template><template-type-parameter name="T"/></template> | |
600 | <type>std::size_t</type> | |
601 | <parameter name="val"><paramtype>T* const&</paramtype></parameter> | |
602 | </signature> | |
603 | ||
604 | <signature> | |
605 | <template> | |
606 | <template-type-parameter name="T"/> | |
607 | <template-nontype-parameter name="N"><type>unsigned</type></template-nontype-parameter> | |
608 | </template> | |
609 | <type>std::size_t</type> | |
610 | <parameter><paramtype>T (&val)[N]</paramtype></parameter> | |
611 | </signature> | |
612 | ||
613 | <signature> | |
614 | <template> | |
615 | <template-type-parameter name="T"/> | |
616 | <template-nontype-parameter name="N"><type>unsigned</type></template-nontype-parameter> | |
617 | </template> | |
618 | <type>std::size_t</type> | |
619 | <parameter><paramtype>const T (&val)[N]</paramtype></parameter> | |
620 | </signature> | |
621 | ||
622 | <signature> | |
623 | <template> | |
624 | <template-type-parameter name="Ch"/> | |
625 | <template-type-parameter name="A"/> | |
626 | </template> | |
627 | <type>std::size_t</type> | |
628 | <parameter name="val"> | |
629 | <paramtype>std::basic_string<Ch, std::char_traits<Ch>, A> const&</paramtype> | |
630 | </parameter> | |
631 | </signature> | |
632 | ||
633 | <signature> | |
634 | <template> | |
635 | <template-type-parameter name="A"/> | |
636 | <template-type-parameter name="B"/> | |
637 | </template> | |
638 | <type>std::size_t</type> | |
639 | <parameter name="val"><paramtype>std::pair<A, B> const&</paramtype></parameter> | |
640 | </signature> | |
641 | ||
642 | <signature> | |
643 | <template> | |
644 | <template-type-parameter name="T"/> | |
645 | <template-type-parameter name="A"/> | |
646 | </template> | |
647 | <type>std::size_t</type> | |
648 | <parameter name="val"><paramtype>std::vector<T, A> const&</paramtype></parameter> | |
649 | </signature> | |
650 | ||
651 | <signature> | |
652 | <template> | |
653 | <template-type-parameter name="T"/> | |
654 | <template-type-parameter name="A"/> | |
655 | </template> | |
656 | <type>std::size_t</type> | |
657 | <parameter name="val"><paramtype>std::list<T, A> const&</paramtype></parameter> | |
658 | </signature> | |
659 | ||
660 | <signature> | |
661 | <template> | |
662 | <template-type-parameter name="T"/> | |
663 | <template-type-parameter name="A"/> | |
664 | </template> | |
665 | <type>std::size_t</type> | |
666 | <parameter name="val"><paramtype>std::deque<T, A> const&</paramtype></parameter> | |
667 | </signature> | |
668 | ||
669 | <signature> | |
670 | <template> | |
671 | <template-type-parameter name="K"/> | |
672 | <template-type-parameter name="C"/> | |
673 | <template-type-parameter name="A"/> | |
674 | </template> | |
675 | <type>std::size_t</type> | |
676 | <parameter name="val"><paramtype>std::set<K, C, A> const&</paramtype></parameter> | |
677 | </signature> | |
678 | ||
679 | <signature> | |
680 | <template> | |
681 | <template-type-parameter name="K"/> | |
682 | <template-type-parameter name="C"/> | |
683 | <template-type-parameter name="A"/> | |
684 | </template> | |
685 | <type>std::size_t</type> | |
686 | <parameter name="val"><paramtype>std::multiset<K, C, A> const&</paramtype></parameter> | |
687 | </signature> | |
688 | ||
689 | <signature> | |
690 | <template> | |
691 | <template-type-parameter name="K"/> | |
692 | <template-type-parameter name="T"/> | |
693 | <template-type-parameter name="C"/> | |
694 | <template-type-parameter name="A"/> | |
695 | </template> | |
696 | <type>std::size_t</type> | |
697 | <parameter name="val"><paramtype>std::map<K, T, C, A> const&</paramtype></parameter> | |
698 | </signature> | |
699 | ||
700 | <signature> | |
701 | <template> | |
702 | <template-type-parameter name="K"/> | |
703 | <template-type-parameter name="T"/> | |
704 | <template-type-parameter name="C"/> | |
705 | <template-type-parameter name="A"/> | |
706 | </template> | |
707 | <type>std::size_t</type> | |
708 | <parameter name="val"><paramtype>std::multimap<K, T, C, A> const&</paramtype></parameter> | |
709 | </signature> | |
710 | ||
711 | <signature> | |
712 | <template> | |
713 | <template-type-parameter name="T"/> | |
714 | </template> | |
715 | <type>std::size_t</type> | |
716 | <parameter name="val"><paramtype>std::complex<T> const&</paramtype></parameter> | |
717 | </signature> | |
718 | ||
719 | <description><para> | |
720 | Generally shouldn't be called directly by users, instead they should use | |
721 | <classname>boost::hash</classname>, <functionname>boost::hash_range</functionname> | |
722 | or <functionname>boost::hash_combine</functionname> which | |
723 | call <code>hash_value</code> without namespace qualification so that overloads | |
724 | for custom types are found via ADL. | |
725 | </para></description> | |
726 | ||
727 | <notes> | |
728 | <para>This is an extension to TR1</para> | |
729 | </notes> | |
730 | ||
731 | <throws> | |
732 | Only throws if a user supplied version of | |
733 | <code><functionname>hash_value</functionname></code> | |
734 | throws for an element of a container, or | |
735 | one of the types stored in a pair. | |
736 | </throws> | |
737 | ||
738 | <returns> | |
739 | <informaltable> | |
740 | <tgroup cols="2"> | |
741 | <thead> | |
742 | <row> | |
743 | <entry>Types</entry> | |
744 | <entry>Returns</entry> | |
745 | </row> | |
746 | </thead> | |
747 | <tbody> | |
748 | <row> | |
749 | <entry><code>bool</code>, | |
750 | <code>char</code>, <code>signed char</code>, <code>unsigned char</code>, <code>wchar_t</code>, | |
751 | <code>short</code>, <code>unsigned short</code>, | |
752 | <code>int</code>, <code>unsigned int</code>, <code>long</code>, <code>unsigned long</code> | |
753 | </entry> | |
754 | <entry><code>val</code></entry> | |
755 | </row> | |
756 | <row> | |
757 | <entry><code>long long</code>, <code>unsigned long long</code></entry> | |
758 | <entry><code>val</code> when <code>abs(val) <= std::numeric_limits<std::size_t>::max()</code>.</entry> | |
759 | </row> | |
760 | <row> | |
761 | <entry><code>float</code>, <code>double</code>, <code>long double</code></entry> | |
762 | <entry>An unspecified value, except that equal arguments shall yield the same result.</entry> | |
763 | </row> | |
764 | <row> | |
765 | <entry><code>T*</code></entry> | |
766 | <entry>An unspecified value, except that equal arguments shall yield the same result.</entry> | |
767 | </row> | |
768 | <row> | |
769 | <entry> | |
770 | <code>T val[N]</code>, | |
771 | <code>const T val[N]</code> | |
772 | </entry> | |
773 | <entry><code>hash_range(val, val+N)</code></entry> | |
774 | </row> | |
775 | <row> | |
776 | <entry> | |
777 | <code>std:basic_string<Ch, std::char_traits<Ch>, A></code>, | |
778 | <code>std::vector<T, A></code>, | |
779 | <code>std::list<T, A></code>, | |
780 | <code>std::deque<T, A></code>, | |
781 | <code>std::set<K, C, A></code>, | |
782 | <code>std::multiset<K, C, A></code>, | |
783 | <code>std::map<K, T, C, A></code>, | |
784 | <code>std::multimap<K, T, C, A></code> | |
785 | </entry> | |
786 | <entry><code>hash_range(val.begin(), val.end())</code></entry> | |
787 | </row> | |
788 | <row> | |
789 | <entry><code>std::pair<A, B></code></entry> | |
790 | <entry><programlisting>size_t seed = 0; | |
791 | <functionname>hash_combine</functionname>(seed, val.first); | |
792 | <functionname>hash_combine</functionname>(seed, val.second); | |
793 | return seed;</programlisting></entry> | |
794 | </row> | |
795 | <row> | |
796 | <entry> | |
797 | <code>std::complex<T></code> | |
798 | </entry> | |
799 | <entry>When <code>T</code> is a built in type and <code>val.imag() == 0</code>, the result is equal to <code>hash_value(val.real())</code>. Otherwise an unspecified value, except that equal arguments shall yield the same result.</entry> | |
800 | </row> | |
801 | </tbody> | |
802 | </tgroup> | |
803 | </informaltable> | |
804 | </returns> | |
805 | </overloaded-function> | |
806 | </free-function-group> | |
807 | </namespace> | |
808 | </header> | |
809 | </library-reference> | |
810 |