]>
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 | <para> | |
59 | Forward declared in | |
60 | <code><boost/functional/hash_fwd.hpp></code> | |
61 | </para> | |
62 | <para> | |
63 | This hash function is not intended for general use, and isn't | |
64 | guaranteed to be equal during separate runs of a program - so | |
65 | please don't use it for any persistent storage or communication. | |
66 | </para> | |
67 | </notes> | |
68 | <throws><para> | |
69 | Only throws if | |
70 | <code><functionname>hash_value</functionname>(T)</code> throws. | |
71 | </para></throws> | |
72 | </method> | |
73 | </struct> | |
74 | ||
75 | <struct-specialization name="hash"> | |
76 | <template></template> | |
77 | <specialization> | |
78 | <template-arg>bool</template-arg> | |
79 | </specialization> | |
80 | <method name="operator()" cv="const"> | |
81 | <type>std::size_t</type> | |
82 | <parameter name="val"> | |
83 | <paramtype>bool</paramtype> | |
84 | </parameter> | |
85 | <returns> | |
86 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
87 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
88 | </returns> | |
89 | <throws><para>Doesn't throw</para></throws> | |
90 | </method> | |
91 | </struct-specialization> | |
92 | ||
93 | <struct-specialization name="hash"> | |
94 | <template></template> | |
95 | <specialization> | |
96 | <template-arg>char</template-arg> | |
97 | </specialization> | |
98 | <method name="operator()" cv="const"> | |
99 | <type>std::size_t</type> | |
100 | <parameter name="val"> | |
101 | <paramtype>char</paramtype> | |
102 | </parameter> | |
103 | <returns> | |
104 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
105 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
106 | </returns> | |
107 | <throws><para>Doesn't throw</para></throws> | |
108 | </method> | |
109 | </struct-specialization> | |
110 | ||
111 | <struct-specialization name="hash"> | |
112 | <template></template> | |
113 | <specialization> | |
114 | <template-arg>signed char</template-arg> | |
115 | </specialization> | |
116 | <method name="operator()" cv="const"> | |
117 | <type>std::size_t</type> | |
118 | <parameter name="val"> | |
119 | <paramtype>signed char</paramtype> | |
120 | </parameter> | |
121 | <returns> | |
122 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
123 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
124 | </returns> | |
125 | <throws><para>Doesn't throw</para></throws> | |
126 | </method> | |
127 | </struct-specialization> | |
128 | ||
129 | <struct-specialization name="hash"> | |
130 | <template></template> | |
131 | <specialization> | |
132 | <template-arg>unsigned char</template-arg> | |
133 | </specialization> | |
134 | <method name="operator()" cv="const"> | |
135 | <type>std::size_t</type> | |
136 | <parameter name="val"> | |
137 | <paramtype>unsigned char</paramtype> | |
138 | </parameter> | |
139 | <returns> | |
140 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
141 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
142 | </returns> | |
143 | <throws><para>Doesn't throw</para></throws> | |
144 | </method> | |
145 | </struct-specialization> | |
146 | ||
147 | <struct-specialization name="hash"> | |
148 | <template></template> | |
149 | <specialization> | |
150 | <template-arg>wchar_t</template-arg> | |
151 | </specialization> | |
152 | <method name="operator()" cv="const"> | |
153 | <type>std::size_t</type> | |
154 | <parameter name="val"> | |
155 | <paramtype>wchar_t</paramtype> | |
156 | </parameter> | |
157 | <returns> | |
158 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
159 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
160 | </returns> | |
161 | <throws><para>Doesn't throw</para></throws> | |
162 | </method> | |
163 | </struct-specialization> | |
164 | ||
165 | <struct-specialization name="hash"> | |
166 | <template></template> | |
167 | <specialization> | |
168 | <template-arg>short</template-arg> | |
169 | </specialization> | |
170 | <method name="operator()" cv="const"> | |
171 | <type>std::size_t</type> | |
172 | <parameter name="val"> | |
173 | <paramtype>short</paramtype> | |
174 | </parameter> | |
175 | <returns> | |
176 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
177 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
178 | </returns> | |
179 | <throws><para>Doesn't throw</para></throws> | |
180 | </method> | |
181 | </struct-specialization> | |
182 | ||
183 | <struct-specialization name="hash"> | |
184 | <template></template> | |
185 | <specialization> | |
186 | <template-arg>unsigned short</template-arg> | |
187 | </specialization> | |
188 | <method name="operator()" cv="const"> | |
189 | <type>std::size_t</type> | |
190 | <parameter name="val"> | |
191 | <paramtype>unsigned short</paramtype> | |
192 | </parameter> | |
193 | <returns> | |
194 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
195 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
196 | </returns> | |
197 | <throws><para>Doesn't throw</para></throws> | |
198 | </method> | |
199 | </struct-specialization> | |
200 | ||
201 | <struct-specialization name="hash"> | |
202 | <template></template> | |
203 | <specialization> | |
204 | <template-arg>int</template-arg> | |
205 | </specialization> | |
206 | <method name="operator()" cv="const"> | |
207 | <type>std::size_t</type> | |
208 | <parameter name="val"> | |
209 | <paramtype>int</paramtype> | |
210 | </parameter> | |
211 | <returns> | |
212 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
213 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
214 | </returns> | |
215 | <throws><para>Doesn't throw</para></throws> | |
216 | </method> | |
217 | </struct-specialization> | |
218 | ||
219 | <struct-specialization name="hash"> | |
220 | <template></template> | |
221 | <specialization> | |
222 | <template-arg>unsigned int</template-arg> | |
223 | </specialization> | |
224 | <method name="operator()" cv="const"> | |
225 | <type>std::size_t</type> | |
226 | <parameter name="val"> | |
227 | <paramtype>unsigned int</paramtype> | |
228 | </parameter> | |
229 | <returns> | |
230 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
231 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
232 | </returns> | |
233 | <throws><para>Doesn't throw</para></throws> | |
234 | </method> | |
235 | </struct-specialization> | |
236 | ||
237 | <struct-specialization name="hash"> | |
238 | <template></template> | |
239 | <specialization> | |
240 | <template-arg>long</template-arg> | |
241 | </specialization> | |
242 | <method name="operator()" cv="const"> | |
243 | <type>std::size_t</type> | |
244 | <parameter name="val"> | |
245 | <paramtype>long</paramtype> | |
246 | </parameter> | |
247 | <returns> | |
248 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
249 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
250 | </returns> | |
251 | <throws><para>Doesn't throw</para></throws> | |
252 | </method> | |
253 | </struct-specialization> | |
254 | ||
255 | <struct-specialization name="hash"> | |
256 | <template></template> | |
257 | <specialization> | |
258 | <template-arg>unsigned long</template-arg> | |
259 | </specialization> | |
260 | <method name="operator()" cv="const"> | |
261 | <type>std::size_t</type> | |
262 | <parameter name="val"> | |
263 | <paramtype>unsigned long</paramtype> | |
264 | </parameter> | |
265 | <returns> | |
266 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
267 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
268 | </returns> | |
269 | <throws><para>Doesn't throw</para></throws> | |
270 | </method> | |
271 | </struct-specialization> | |
272 | ||
273 | <struct-specialization name="hash"> | |
274 | <template></template> | |
275 | <specialization> | |
276 | <template-arg>long long</template-arg> | |
277 | </specialization> | |
278 | <method name="operator()" cv="const"> | |
279 | <type>std::size_t</type> | |
280 | <parameter name="val"> | |
281 | <paramtype>long long</paramtype> | |
282 | </parameter> | |
283 | <returns> | |
284 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
285 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
286 | </returns> | |
287 | <throws><para>Doesn't throw</para></throws> | |
288 | </method> | |
289 | </struct-specialization> | |
290 | ||
291 | <struct-specialization name="hash"> | |
292 | <template></template> | |
293 | <specialization> | |
294 | <template-arg>unsigned long long</template-arg> | |
295 | </specialization> | |
296 | <method name="operator()" cv="const"> | |
297 | <type>std::size_t</type> | |
298 | <parameter name="val"> | |
299 | <paramtype>unsigned long long</paramtype> | |
300 | </parameter> | |
301 | <returns> | |
302 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
303 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
304 | </returns> | |
305 | <throws><para>Doesn't throw</para></throws> | |
306 | </method> | |
307 | </struct-specialization> | |
308 | ||
309 | <struct-specialization name="hash"> | |
310 | <template></template> | |
311 | <specialization> | |
312 | <template-arg>float</template-arg> | |
313 | </specialization> | |
314 | <method name="operator()" cv="const"> | |
315 | <type>std::size_t</type> | |
316 | <parameter name="val"> | |
317 | <paramtype>float</paramtype> | |
318 | </parameter> | |
319 | <returns> | |
320 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
321 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
322 | </returns> | |
323 | <throws><para>Doesn't throw</para></throws> | |
324 | </method> | |
325 | </struct-specialization> | |
326 | ||
327 | <struct-specialization name="hash"> | |
328 | <template></template> | |
329 | <specialization> | |
330 | <template-arg>double</template-arg> | |
331 | </specialization> | |
332 | <method name="operator()" cv="const"> | |
333 | <type>std::size_t</type> | |
334 | <parameter name="val"> | |
335 | <paramtype>double</paramtype> | |
336 | </parameter> | |
337 | <returns> | |
338 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
339 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
340 | </returns> | |
341 | <throws><para>Doesn't throw</para></throws> | |
342 | </method> | |
343 | </struct-specialization> | |
344 | ||
345 | <struct-specialization name="hash"> | |
346 | <template></template> | |
347 | <specialization> | |
348 | <template-arg>long double</template-arg> | |
349 | </specialization> | |
350 | <method name="operator()" cv="const"> | |
351 | <type>std::size_t</type> | |
352 | <parameter name="val"> | |
353 | <paramtype>long double</paramtype> | |
354 | </parameter> | |
355 | <returns> | |
356 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
357 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
358 | </returns> | |
359 | <throws><para>Doesn't throw</para></throws> | |
360 | </method> | |
361 | </struct-specialization> | |
362 | ||
363 | <struct-specialization name="hash"> | |
364 | <template></template> | |
365 | <specialization> | |
366 | <template-arg>std::string</template-arg> | |
367 | </specialization> | |
368 | <method name="operator()" cv="const"> | |
369 | <type>std::size_t</type> | |
370 | <parameter name="val"> | |
371 | <paramtype>std::string const&</paramtype> | |
372 | </parameter> | |
373 | <returns> | |
374 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
375 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
376 | </returns> | |
377 | <throws><para>Doesn't throw</para></throws> | |
378 | </method> | |
379 | </struct-specialization> | |
380 | ||
381 | <struct-specialization name="hash"> | |
382 | <template></template> | |
383 | <specialization> | |
384 | <template-arg>std::wstring</template-arg> | |
385 | </specialization> | |
386 | <method name="operator()" cv="const"> | |
387 | <type>std::size_t</type> | |
388 | <parameter name="val"> | |
389 | <paramtype>std::wstring const&</paramtype> | |
390 | </parameter> | |
391 | <returns> | |
392 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
393 | <para><functionname>hash_value</functionname>(val) in Boost.</para> | |
394 | </returns> | |
395 | <throws><para>Doesn't throw</para></throws> | |
396 | </method> | |
397 | </struct-specialization> | |
398 | ||
399 | <struct-specialization name="hash"> | |
400 | <template> | |
401 | <template-type-parameter name="T"/> | |
402 | </template> | |
403 | <specialization> | |
404 | <template-arg>T*</template-arg> | |
405 | </specialization> | |
406 | <method name="operator()" cv="const"> | |
407 | <type>std::size_t</type> | |
408 | <parameter name="val"> | |
409 | <paramtype>T*</paramtype> | |
410 | </parameter> | |
411 | <returns> | |
412 | <para>Unspecified in TR1, except that equal arguments yield the same result.</para> | |
413 | </returns> | |
414 | <throws><para>Doesn't throw</para></throws> | |
415 | </method> | |
416 | </struct-specialization> | |
417 | ||
418 | <struct-specialization name="hash"> | |
419 | <template></template> | |
420 | <specialization> | |
421 | <template-arg>std::type_index</template-arg> | |
422 | </specialization> | |
423 | <method name="operator()" cv="const"> | |
424 | <type>std::size_t</type> | |
425 | <parameter name="val"> | |
426 | <paramtype>std::type_index</paramtype> | |
427 | </parameter> | |
428 | <returns> | |
429 | <para><code>val.hash_code()</code></para> | |
430 | </returns> | |
431 | <throws><para>Doesn't throw</para></throws> | |
432 | </method> | |
433 | <notes> | |
434 | <para> | |
435 | Only available if it's in your standard library and Boost.Config | |
436 | is aware of it. | |
437 | </para> | |
438 | </notes> | |
439 | </struct-specialization> | |
440 | ||
441 | <free-function-group name="Support functions (Boost extension)."> | |
442 | ||
443 | <!-- | |
444 | boost::hash_combine | |
445 | --> | |
446 | ||
447 | <function name="hash_combine"> | |
448 | <template> | |
449 | <template-type-parameter name="T"/> | |
450 | </template> | |
451 | <type>void</type> | |
452 | <parameter name="seed"><paramtype>size_t &</paramtype></parameter> | |
453 | <parameter name="v"><paramtype>T const&</paramtype></parameter> | |
454 | <purpose><simpara> | |
455 | Called repeatedly to incrementally create a hash value from | |
456 | several variables. | |
457 | </simpara></purpose> | |
458 | <effects> | |
459 | Updates <code>seed</code> with a new hash value generated by | |
460 | combining it with the result of | |
461 | <code><functionname>hash_value</functionname>(v)</code>. Will | |
462 | always produce the same result for the same combination of | |
463 | <code>seed</code> and | |
464 | <code><functionname>hash_value</functionname>(v)</code> during | |
465 | the single run of a program. | |
466 | </effects> | |
467 | <notes> | |
468 | <para><functionname>hash_value</functionname> is called without | |
469 | qualification, so that overloads can be found via ADL.</para> | |
470 | <para>This is an extension to TR1</para> | |
471 | <para> | |
472 | Forward declared in | |
473 | <code><boost/functional/hash_fwd.hpp></code> | |
474 | </para> | |
475 | <para> | |
476 | This hash function is not intended for general use, and isn't | |
477 | guaranteed to be equal during separate runs of a program - so | |
478 | please don't use it for any persistent storage or communication. | |
479 | </para> | |
480 | </notes> | |
481 | <throws> | |
482 | Only throws if <functionname>hash_value</functionname>(T) throws. | |
483 | Strong exception safety, as long as <functionname>hash_value</functionname>(T) | |
484 | also has strong exception safety. | |
485 | </throws> | |
486 | </function> | |
487 | ||
488 | <!-- | |
489 | boost::hash_range | |
490 | --> | |
491 | ||
492 | <overloaded-function name="hash_range"> | |
493 | <signature> | |
494 | <template> | |
495 | <template-type-parameter name="It"/> | |
496 | </template> | |
497 | <type>std::size_t</type> | |
498 | <parameter name="first"><paramtype>It</paramtype></parameter> | |
499 | <parameter name="last"><paramtype>It</paramtype></parameter> | |
500 | </signature> | |
501 | ||
502 | <signature> | |
503 | <template> | |
504 | <template-type-parameter name="It"/> | |
505 | </template> | |
506 | <type>void</type> | |
507 | <parameter name="seed"><paramtype>std::size_t&</paramtype></parameter> | |
508 | <parameter name="first"><paramtype>It</paramtype></parameter> | |
509 | <parameter name="last"><paramtype>It</paramtype></parameter> | |
510 | </signature> | |
511 | ||
512 | <purpose><simpara> | |
513 | Calculate the combined hash value of the elements of an iterator | |
514 | range. | |
515 | </simpara></purpose> | |
516 | <effects> | |
517 | <para>For the two argument overload: | |
518 | <programlisting> | |
519 | size_t seed = 0; | |
520 | ||
521 | for(; first != last; ++first) | |
522 | { | |
523 | <functionname>hash_combine</functionname>(seed, *first); | |
524 | } | |
525 | ||
526 | return seed; | |
527 | </programlisting> | |
528 | </para> | |
529 | <para>For the three arguments overload:</para> | |
530 | <programlisting> | |
531 | for(; first != last; ++first) | |
532 | { | |
533 | <functionname>hash_combine</functionname>(seed, *first); | |
534 | } | |
535 | </programlisting> | |
536 | </effects> | |
537 | <notes> | |
538 | <para> | |
539 | <code>hash_range</code> is sensitive to the order of the elements | |
540 | so it wouldn't be appropriate to use this with an unordered | |
541 | container. | |
542 | </para> | |
543 | <para>This is an extension to TR1</para> | |
544 | <para> | |
545 | Forward declared in | |
546 | <code><boost/functional/hash_fwd.hpp></code> | |
547 | </para> | |
548 | <para> | |
549 | This hash function is not intended for general use, and isn't | |
550 | guaranteed to be equal during separate runs of a program - so | |
551 | please don't use it for any persistent storage or communication. | |
552 | </para> | |
553 | </notes> | |
554 | <throws><para> | |
555 | Only throws if <code><functionname>hash_value</functionname>(std::iterator_traits<It>::value_type)</code> | |
556 | throws. <code>hash_range(std::size_t&, It, It)</code> has basic exception safety as long as | |
557 | <code><functionname>hash_value</functionname>(std::iterator_traits<It>::value_type)</code> | |
558 | has basic exception safety. | |
559 | </para></throws> | |
560 | </overloaded-function> | |
561 | ||
562 | </free-function-group> | |
563 | ||
564 | <free-function-group name="Overloadable hash implementation (Boost extension)."> | |
565 | ||
566 | <!-- | |
567 | boost::hash_value - integers | |
568 | --> | |
569 | ||
570 | <overloaded-function name="hash_value"> | |
571 | <purpose><simpara> | |
572 | Implementation of the hash function. | |
573 | </simpara></purpose> | |
574 | ||
575 | <signature> | |
576 | <type>std::size_t</type> | |
577 | <parameter name="val"><paramtype>bool</paramtype></parameter> | |
578 | </signature> | |
579 | ||
580 | <signature> | |
581 | <type>std::size_t</type> | |
582 | <parameter name="val"><paramtype>char</paramtype></parameter> | |
583 | </signature> | |
584 | ||
585 | <signature> | |
586 | <type>std::size_t</type> | |
587 | <parameter name="val"><paramtype>signed char</paramtype></parameter> | |
588 | </signature> | |
589 | ||
590 | <signature> | |
591 | <type>std::size_t</type> | |
592 | <parameter name="val"><paramtype>unsigned char</paramtype></parameter> | |
593 | </signature> | |
594 | ||
595 | <signature> | |
596 | <type>std::size_t</type> | |
597 | <parameter name="val"><paramtype>wchar_t</paramtype></parameter> | |
598 | </signature> | |
599 | ||
600 | <signature> | |
601 | <type>std::size_t</type> | |
602 | <parameter name="val"><paramtype>short</paramtype></parameter> | |
603 | </signature> | |
604 | ||
605 | <signature> | |
606 | <type>std::size_t</type> | |
607 | <parameter name="val"><paramtype>unsigned short</paramtype></parameter> | |
608 | </signature> | |
609 | ||
610 | <signature> | |
611 | <type>std::size_t</type> | |
612 | <parameter name="val"><paramtype>int</paramtype></parameter> | |
613 | </signature> | |
614 | ||
615 | <signature> | |
616 | <type>std::size_t</type> | |
617 | <parameter name="val"><paramtype>unsigned int</paramtype></parameter> | |
618 | </signature> | |
619 | ||
620 | <signature> | |
621 | <type>std::size_t</type> | |
622 | <parameter name="val"><paramtype>long</paramtype></parameter> | |
623 | </signature> | |
624 | ||
625 | <signature> | |
626 | <type>std::size_t</type> | |
627 | <parameter name="val"><paramtype>unsigned long</paramtype></parameter> | |
628 | </signature> | |
629 | ||
630 | <signature> | |
631 | <type>std::size_t</type> | |
632 | <parameter name="val"><paramtype>long long</paramtype></parameter> | |
633 | </signature> | |
634 | ||
635 | <signature> | |
636 | <type>std::size_t</type> | |
637 | <parameter name="val"><paramtype>unsigned long long</paramtype></parameter> | |
638 | </signature> | |
639 | ||
640 | <signature> | |
641 | <type>std::size_t</type> | |
642 | <parameter name="val"><paramtype>float</paramtype></parameter> | |
643 | </signature> | |
644 | ||
645 | <signature> | |
646 | <type>std::size_t</type> | |
647 | <parameter name="val"><paramtype>double</paramtype></parameter> | |
648 | </signature> | |
649 | ||
650 | <signature> | |
651 | <type>std::size_t</type> | |
652 | <parameter name="val"><paramtype>long double</paramtype></parameter> | |
653 | </signature> | |
654 | ||
655 | <signature> | |
656 | <template><template-type-parameter name="T"/></template> | |
657 | <type>std::size_t</type> | |
658 | <parameter name="val"><paramtype>T* const&</paramtype></parameter> | |
659 | </signature> | |
660 | ||
661 | <signature> | |
662 | <template> | |
663 | <template-type-parameter name="T"/> | |
664 | <template-nontype-parameter name="N"><type>unsigned</type></template-nontype-parameter> | |
665 | </template> | |
666 | <type>std::size_t</type> | |
667 | <parameter><paramtype>T (&val)[N]</paramtype></parameter> | |
668 | </signature> | |
669 | ||
670 | <signature> | |
671 | <template> | |
672 | <template-type-parameter name="T"/> | |
673 | <template-nontype-parameter name="N"><type>unsigned</type></template-nontype-parameter> | |
674 | </template> | |
675 | <type>std::size_t</type> | |
676 | <parameter><paramtype>const T (&val)[N]</paramtype></parameter> | |
677 | </signature> | |
678 | ||
679 | <signature> | |
680 | <template> | |
681 | <template-type-parameter name="Ch"/> | |
682 | <template-type-parameter name="A"/> | |
683 | </template> | |
684 | <type>std::size_t</type> | |
685 | <parameter name="val"> | |
686 | <paramtype>std::basic_string<Ch, std::char_traits<Ch>, A> const&</paramtype> | |
687 | </parameter> | |
688 | </signature> | |
689 | ||
690 | <signature> | |
691 | <template> | |
692 | <template-type-parameter name="A"/> | |
693 | <template-type-parameter name="B"/> | |
694 | </template> | |
695 | <type>std::size_t</type> | |
696 | <parameter name="val"><paramtype>std::pair<A, B> const&</paramtype></parameter> | |
697 | </signature> | |
698 | ||
699 | <signature> | |
700 | <template> | |
701 | <template-type-parameter name="T"/> | |
702 | <template-type-parameter name="A"/> | |
703 | </template> | |
704 | <type>std::size_t</type> | |
705 | <parameter name="val"><paramtype>std::vector<T, A> const&</paramtype></parameter> | |
706 | </signature> | |
707 | ||
708 | <signature> | |
709 | <template> | |
710 | <template-type-parameter name="T"/> | |
711 | <template-type-parameter name="A"/> | |
712 | </template> | |
713 | <type>std::size_t</type> | |
714 | <parameter name="val"><paramtype>std::list<T, A> const&</paramtype></parameter> | |
715 | </signature> | |
716 | ||
717 | <signature> | |
718 | <template> | |
719 | <template-type-parameter name="T"/> | |
720 | <template-type-parameter name="A"/> | |
721 | </template> | |
722 | <type>std::size_t</type> | |
723 | <parameter name="val"><paramtype>std::deque<T, A> const&</paramtype></parameter> | |
724 | </signature> | |
725 | ||
726 | <signature> | |
727 | <template> | |
728 | <template-type-parameter name="K"/> | |
729 | <template-type-parameter name="C"/> | |
730 | <template-type-parameter name="A"/> | |
731 | </template> | |
732 | <type>std::size_t</type> | |
733 | <parameter name="val"><paramtype>std::set<K, C, A> const&</paramtype></parameter> | |
734 | </signature> | |
735 | ||
736 | <signature> | |
737 | <template> | |
738 | <template-type-parameter name="K"/> | |
739 | <template-type-parameter name="C"/> | |
740 | <template-type-parameter name="A"/> | |
741 | </template> | |
742 | <type>std::size_t</type> | |
743 | <parameter name="val"><paramtype>std::multiset<K, C, A> const&</paramtype></parameter> | |
744 | </signature> | |
745 | ||
746 | <signature> | |
747 | <template> | |
748 | <template-type-parameter name="K"/> | |
749 | <template-type-parameter name="T"/> | |
750 | <template-type-parameter name="C"/> | |
751 | <template-type-parameter name="A"/> | |
752 | </template> | |
753 | <type>std::size_t</type> | |
754 | <parameter name="val"><paramtype>std::map<K, T, C, A> const&</paramtype></parameter> | |
755 | </signature> | |
756 | ||
757 | <signature> | |
758 | <template> | |
759 | <template-type-parameter name="K"/> | |
760 | <template-type-parameter name="T"/> | |
761 | <template-type-parameter name="C"/> | |
762 | <template-type-parameter name="A"/> | |
763 | </template> | |
764 | <type>std::size_t</type> | |
765 | <parameter name="val"><paramtype>std::multimap<K, T, C, A> const&</paramtype></parameter> | |
766 | </signature> | |
767 | ||
768 | <signature> | |
769 | <template> | |
770 | <template-type-parameter name="T"/> | |
771 | </template> | |
772 | <type>std::size_t</type> | |
773 | <parameter name="val"><paramtype>std::complex<T> const&</paramtype></parameter> | |
774 | </signature> | |
775 | ||
776 | <signature> | |
777 | <type>std::size_t</type> | |
778 | <parameter name="val"><paramtype>std::type_index</paramtype></parameter> | |
779 | </signature> | |
780 | ||
781 | <signature> | |
782 | <template> | |
783 | <template-type-parameter name="T"/> | |
784 | <template-nontype-parameter name="N"> | |
785 | <type>std::size_t</type> | |
786 | </template-nontype-parameter> | |
787 | </template> | |
788 | <type>std::size_t</type> | |
789 | <parameter name="val"><paramtype>std::array<T, N> const&</paramtype></parameter> | |
790 | </signature> | |
791 | ||
792 | <signature> | |
793 | <template> | |
794 | <template-type-parameter name="T" pack="1"/> | |
795 | </template> | |
796 | <type>std::size_t</type> | |
797 | <parameter name="val"><paramtype>std::tuple<T...></paramtype></parameter> | |
798 | </signature> | |
799 | ||
800 | <description><para> | |
801 | Generally shouldn't be called directly by users, instead they should use | |
802 | <classname>boost::hash</classname>, <functionname>boost::hash_range</functionname> | |
803 | or <functionname>boost::hash_combine</functionname> which | |
804 | call <code>hash_value</code> without namespace qualification so that overloads | |
805 | for custom types are found via ADL. | |
806 | </para></description> | |
807 | ||
808 | <notes> | |
809 | <para>This is an extension to TR1</para> | |
810 | <para> | |
811 | This hash function is not intended for general use, and isn't | |
812 | guaranteed to be equal during separate runs of a program - so | |
813 | please don't use it for any persistent storage or communication. | |
814 | </para> | |
815 | </notes> | |
816 | ||
817 | <throws> | |
818 | Only throws if a user supplied version of | |
819 | <code><functionname>hash_value</functionname></code> | |
820 | throws for an element of a container, or | |
821 | one of the types stored in a pair. | |
822 | </throws> | |
823 | ||
824 | <returns> | |
825 | <informaltable> | |
826 | <tgroup cols="2"> | |
827 | <thead> | |
828 | <row> | |
829 | <entry>Types</entry> | |
830 | <entry>Returns</entry> | |
831 | </row> | |
832 | </thead> | |
833 | <tbody> | |
834 | <row> | |
835 | <entry><code>bool</code>, | |
836 | <code>char</code>, <code>signed char</code>, <code>unsigned char</code>, <code>wchar_t</code>, | |
837 | <code>short</code>, <code>unsigned short</code>, | |
838 | <code>int</code>, <code>unsigned int</code>, <code>long</code>, <code>unsigned long</code> | |
839 | </entry> | |
840 | <entry><code>val</code></entry> | |
841 | </row> | |
842 | <row> | |
843 | <entry><code>long long</code>, <code>unsigned long long</code></entry> | |
844 | <entry><code>val</code> when <code>abs(val) <= std::numeric_limits<std::size_t>::max()</code>.</entry> | |
845 | </row> | |
846 | <row> | |
847 | <entry><code>float</code>, <code>double</code>, <code>long double</code></entry> | |
848 | <entry>An unspecified value, except that equal arguments shall yield the same result.</entry> | |
849 | </row> | |
850 | <row> | |
851 | <entry><code>T*</code></entry> | |
852 | <entry>An unspecified value, except that equal arguments shall yield the same result.</entry> | |
853 | </row> | |
854 | <row> | |
855 | <entry> | |
856 | <code>T val[N]</code>, | |
857 | <code>const T val[N]</code> | |
858 | </entry> | |
859 | <entry><code>hash_range(val, val+N)</code></entry> | |
860 | </row> | |
861 | <row> | |
862 | <entry> | |
863 | <code>std:basic_string<Ch, std::char_traits<Ch>, A></code>, | |
864 | <code>std::vector<T, A></code>, | |
865 | <code>std::list<T, A></code>, | |
866 | <code>std::deque<T, A></code>, | |
867 | <code>std::set<K, C, A></code>, | |
868 | <code>std::multiset<K, C, A></code>, | |
869 | <code>std::map<K, T, C, A></code>, | |
870 | <code>std::multimap<K, T, C, A></code>, | |
871 | <code>std::array<T, N></code> | |
872 | </entry> | |
873 | <entry><code>hash_range(val.begin(), val.end())</code></entry> | |
874 | </row> | |
875 | <row> | |
876 | <entry><code>std::pair<A, B></code></entry> | |
877 | <entry><programlisting>size_t seed = 0; | |
878 | <functionname>hash_combine</functionname>(seed, val.first); | |
879 | <functionname>hash_combine</functionname>(seed, val.second); | |
880 | return seed;</programlisting></entry> | |
881 | </row> | |
882 | <row> | |
883 | <entry><code>std::tuple<T...></code></entry> | |
884 | <entry><programlisting>size_t seed = 0; | |
885 | <functionname>hash_combine</functionname>(seed, get<0>(val)); | |
886 | <functionname>hash_combine</functionname>(seed, get<1>(val)); | |
887 | // .... | |
888 | return seed;</programlisting></entry> | |
889 | </row> | |
890 | <row> | |
891 | <entry> | |
892 | <code>std::complex<T></code> | |
893 | </entry> | |
894 | <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> | |
895 | </row> | |
896 | <row> | |
897 | <entry> | |
898 | <code>std::type_index</code> | |
899 | </entry> | |
900 | <entry><code>val.hash_code()</code></entry> | |
901 | </row> | |
902 | </tbody> | |
903 | </tgroup> | |
904 | </informaltable> | |
905 | </returns> | |
906 | </overloaded-function> | |
907 | </free-function-group> | |
908 | </namespace> | |
909 | </header> | |
910 | </library-reference> | |
911 |