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