123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994 |
- <!--
- Copyright Daniel James 2005-2009
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- -->
- <library-reference>
- <section id="hash.reference.specification">
- <para>For the full specification, see section 6.3 of the
- <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">C++ Standard Library Technical Report</ulink>
- and issue 6.18 of the
- <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf">Library Extension Technical Report Issues List</ulink> (page 63).
- </para>
- </section>
- <header name="boost/container_hash/hash.hpp">
- <para>
- Defines <code><classname>boost::hash</classname></code>,
- and helper functions.
- </para>
- <namespace name="boost">
- <!--
- boost::hash
- -->
- <struct name="hash">
- <template>
- <template-type-parameter name="T"/>
- </template>
- <inherit access="public">
- <classname>std::unary_function<T, std::size_t></classname>
- </inherit>
- <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>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>T const&</paramtype>
- </parameter>
- <returns><para>
- <programlisting><functionname>hash_value</functionname>(val)</programlisting>
- </para></returns>
- <notes>
- <para>
- The call to <code><functionname>hash_value</functionname></code>
- is unqualified, so that custom overloads can be
- found via argument dependent lookup.
- </para>
- <para>
- This is not defined when the macro <code>BOOST_HASH_NO_EXTENSIONS</code>
- is defined. The specializations are still defined, so only the specializations
- required by TR1 are defined.
- </para>
- <para>
- Forward declared in
- <code><boost/container_hash/hash_fwd.hpp></code>
- </para>
- <para>
- This hash function is not intended for general use, and isn't
- guaranteed to be equal during separate runs of a program - so
- please don't use it for any persistent storage or communication.
- </para>
- </notes>
- <throws><para>
- Only throws if
- <code><functionname>hash_value</functionname>(T)</code> throws.
- </para></throws>
- </method>
- </struct>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>bool</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>bool</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>char</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>char</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>signed char</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>signed char</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>unsigned char</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>unsigned char</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>wchar_t</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>wchar_t</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>char16_t</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>char16_t</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>char32_t</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>char32_t</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>short</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>short</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>unsigned short</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>unsigned short</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>int</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>int</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>unsigned int</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>unsigned int</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>long</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>long</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>unsigned long</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>unsigned long</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>long long</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>long long</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>unsigned long long</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>unsigned long long</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>float</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>float</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>double</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>double</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>long double</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>long double</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>std::string</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>std::string const&</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>std::wstring</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>std::wstring const&</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>std::u16string</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>std::u16string const&</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>std::u32string</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>std::u32string const&</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- <para><functionname>hash_value</functionname>(val) in Boost.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template>
- <template-type-parameter name="T"/>
- </template>
- <specialization>
- <template-arg>T*</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>T*</paramtype>
- </parameter>
- <returns>
- <para>Unspecified in TR1, except that equal arguments yield the same result.</para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- </struct-specialization>
- <struct-specialization name="hash">
- <template></template>
- <specialization>
- <template-arg>std::type_index</template-arg>
- </specialization>
- <method name="operator()" cv="const">
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>std::type_index</paramtype>
- </parameter>
- <returns>
- <para><code>val.hash_code()</code></para>
- </returns>
- <throws><para>Doesn't throw</para></throws>
- </method>
- <notes>
- <para>
- Only available if it's in your standard library and Boost.Config
- is aware of it.
- </para>
- </notes>
- </struct-specialization>
- <free-function-group name="Support functions (Boost extension).">
- <!--
- boost::hash_combine
- -->
- <function name="hash_combine">
- <template>
- <template-type-parameter name="T"/>
- </template>
- <type>void</type>
- <parameter name="seed"><paramtype>size_t &</paramtype></parameter>
- <parameter name="v"><paramtype>T const&</paramtype></parameter>
- <purpose><simpara>
- Called repeatedly to incrementally create a hash value from
- several variables.
- </simpara></purpose>
- <effects>
- Updates <code>seed</code> with a new hash value generated by
- combining it with the result of
- <code><functionname>hash_value</functionname>(v)</code>. Will
- always produce the same result for the same combination of
- <code>seed</code> and
- <code><functionname>hash_value</functionname>(v)</code> during
- the single run of a program.
- </effects>
- <notes>
- <para><functionname>hash_value</functionname> is called without
- qualification, so that overloads can be found via ADL.</para>
- <para>This is an extension to TR1</para>
- <para>
- Forward declared in
- <code><boost/container_hash/hash_fwd.hpp></code>
- </para>
- <para>
- This hash function is not intended for general use, and isn't
- guaranteed to be equal during separate runs of a program - so
- please don't use it for any persistent storage or communication.
- </para>
- </notes>
- <throws>
- Only throws if <functionname>hash_value</functionname>(T) throws.
- Strong exception safety, as long as <functionname>hash_value</functionname>(T)
- also has strong exception safety.
- </throws>
- </function>
- <!--
- boost::hash_range
- -->
- <overloaded-function name="hash_range">
- <signature>
- <template>
- <template-type-parameter name="It"/>
- </template>
- <type>std::size_t</type>
- <parameter name="first"><paramtype>It</paramtype></parameter>
- <parameter name="last"><paramtype>It</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="It"/>
- </template>
- <type>void</type>
- <parameter name="seed"><paramtype>std::size_t&</paramtype></parameter>
- <parameter name="first"><paramtype>It</paramtype></parameter>
- <parameter name="last"><paramtype>It</paramtype></parameter>
- </signature>
- <purpose><simpara>
- Calculate the combined hash value of the elements of an iterator
- range.
- </simpara></purpose>
- <effects>
- <para>For the two argument overload:
- <programlisting>
- size_t seed = 0;
- for(; first != last; ++first)
- {
- <functionname>hash_combine</functionname>(seed, *first);
- }
- return seed;
- </programlisting>
- </para>
- <para>For the three arguments overload:</para>
- <programlisting>
- for(; first != last; ++first)
- {
- <functionname>hash_combine</functionname>(seed, *first);
- }
- </programlisting>
- </effects>
- <notes>
- <para>
- <code>hash_range</code> is sensitive to the order of the elements
- so it wouldn't be appropriate to use this with an unordered
- container.
- </para>
- <para>This is an extension to TR1</para>
- <para>
- Forward declared in
- <code><boost/container_hash/hash_fwd.hpp></code>
- </para>
- <para>
- This hash function is not intended for general use, and isn't
- guaranteed to be equal during separate runs of a program - so
- please don't use it for any persistent storage or communication.
- </para>
- </notes>
- <throws><para>
- Only throws if <code><functionname>hash_value</functionname>(std::iterator_traits<It>::value_type)</code>
- throws. <code>hash_range(std::size_t&, It, It)</code> has basic exception safety as long as
- <code><functionname>hash_value</functionname>(std::iterator_traits<It>::value_type)</code>
- has basic exception safety.
- </para></throws>
- </overloaded-function>
- </free-function-group>
- <free-function-group name="Overloadable hash implementation (Boost extension).">
- <!--
- boost::hash_value - integers
- -->
- <overloaded-function name="hash_value">
- <purpose><simpara>
- Implementation of the hash function.
- </simpara></purpose>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>bool</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>char</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>signed char</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>unsigned char</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>wchar_t</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>char16_t</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>char32_t</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>short</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>unsigned short</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>int</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>unsigned int</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>long</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>unsigned long</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>long long</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>unsigned long long</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>float</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>double</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>long double</paramtype></parameter>
- </signature>
- <signature>
- <template><template-type-parameter name="T"/></template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>T* const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="T"/>
- <template-nontype-parameter name="N"><type>unsigned</type></template-nontype-parameter>
- </template>
- <type>std::size_t</type>
- <parameter><paramtype>T (&val)[N]</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="T"/>
- <template-nontype-parameter name="N"><type>unsigned</type></template-nontype-parameter>
- </template>
- <type>std::size_t</type>
- <parameter><paramtype>const T (&val)[N]</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="Ch"/>
- <template-type-parameter name="A"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val">
- <paramtype>std::basic_string<Ch, std::char_traits<Ch>, A> const&</paramtype>
- </parameter>
- </signature>
-
- <signature>
- <template>
- <template-type-parameter name="A"/>
- <template-type-parameter name="B"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::pair<A, B> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="T"/>
- <template-type-parameter name="A"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::vector<T, A> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="T"/>
- <template-type-parameter name="A"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::list<T, A> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="T"/>
- <template-type-parameter name="A"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::deque<T, A> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="K"/>
- <template-type-parameter name="C"/>
- <template-type-parameter name="A"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::set<K, C, A> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="K"/>
- <template-type-parameter name="C"/>
- <template-type-parameter name="A"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::multiset<K, C, A> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="K"/>
- <template-type-parameter name="T"/>
- <template-type-parameter name="C"/>
- <template-type-parameter name="A"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::map<K, T, C, A> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="K"/>
- <template-type-parameter name="T"/>
- <template-type-parameter name="C"/>
- <template-type-parameter name="A"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::multimap<K, T, C, A> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="T"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::complex<T> const&</paramtype></parameter>
- </signature>
- <signature>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::type_index</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="T"/>
- <template-nontype-parameter name="N">
- <type>std::size_t</type>
- </template-nontype-parameter>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::array<T, N> const&</paramtype></parameter>
- </signature>
- <signature>
- <template>
- <template-type-parameter name="T" pack="1"/>
- </template>
- <type>std::size_t</type>
- <parameter name="val"><paramtype>std::tuple<T...></paramtype></parameter>
- </signature>
- <description><para>
- Generally shouldn't be called directly by users, instead they should use
- <classname>boost::hash</classname>, <functionname>boost::hash_range</functionname>
- or <functionname>boost::hash_combine</functionname> which
- call <code>hash_value</code> without namespace qualification so that overloads
- for custom types are found via ADL.
- </para></description>
- <notes>
- <para>This is an extension to TR1</para>
- <para>
- This hash function is not intended for general use, and isn't
- guaranteed to be equal during separate runs of a program - so
- please don't use it for any persistent storage or communication.
- </para>
- </notes>
- <throws>
- Only throws if a user supplied version of
- <code><functionname>hash_value</functionname></code>
- throws for an element of a container, or
- one of the types stored in a pair.
- </throws>
- <returns>
- <informaltable>
- <tgroup cols="2">
- <thead>
- <row>
- <entry>Types</entry>
- <entry>Returns</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><code>bool</code>,
- <code>char</code>, <code>signed char</code>, <code>unsigned char</code>,
- <code>wchar_t</code>, <code>char16_t</code>, <code>char32_t</code>,
- <code>short</code>, <code>unsigned short</code>,
- <code>int</code>, <code>unsigned int</code>, <code>long</code>, <code>unsigned long</code>
- </entry>
- <entry><code>val</code></entry>
- </row>
- <row>
- <entry><code>long long</code>, <code>unsigned long long</code></entry>
- <entry><code>val</code> when <code>abs(val) <= std::numeric_limits<std::size_t>::max()</code>.</entry>
- </row>
- <row>
- <entry><code>float</code>, <code>double</code>, <code>long double</code></entry>
- <entry>An unspecified value, except that equal arguments shall yield the same result.</entry>
- </row>
- <row>
- <entry><code>T*</code></entry>
- <entry>An unspecified value, except that equal arguments shall yield the same result.</entry>
- </row>
- <row>
- <entry>
- <code>T val[N]</code>,
- <code>const T val[N]</code>
- </entry>
- <entry><code>hash_range(val, val+N)</code></entry>
- </row>
- <row>
- <entry>
- <code>std:basic_string<Ch, std::char_traits<Ch>, A></code>,
- <code>std::vector<T, A></code>,
- <code>std::list<T, A></code>,
- <code>std::deque<T, A></code>,
- <code>std::set<K, C, A></code>,
- <code>std::multiset<K, C, A></code>,
- <code>std::map<K, T, C, A></code>,
- <code>std::multimap<K, T, C, A></code>,
- <code>std::array<T, N></code>
- </entry>
- <entry><code>hash_range(val.begin(), val.end())</code></entry>
- </row>
- <row>
- <entry><code>std::pair<A, B></code></entry>
- <entry><programlisting>size_t seed = 0;
- <functionname>hash_combine</functionname>(seed, val.first);
- <functionname>hash_combine</functionname>(seed, val.second);
- return seed;</programlisting></entry>
- </row>
- <row>
- <entry><code>std::tuple<T...></code></entry>
- <entry><programlisting>size_t seed = 0;
- <functionname>hash_combine</functionname>(seed, get<0>(val));
- <functionname>hash_combine</functionname>(seed, get<1>(val));
- // ....
- return seed;</programlisting></entry>
- </row>
- <row>
- <entry>
- <code>std::complex<T></code>
- </entry>
- <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>
- </row>
- <row>
- <entry>
- <code>std::type_index</code>
- </entry>
- <entry><code>val.hash_code()</code></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </returns>
- </overloaded-function>
- </free-function-group>
- </namespace>
- </header>
- </library-reference>
|