ref.xml 36 KB

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