mirror of
https://github.com/boostorg/container_hash.git
synced 2026-03-07 14:34:11 +01:00
Compare commits
19 Commits
feature/re
...
boost-1.34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42f5aeb552 | ||
|
|
524335a091 | ||
|
|
4c24efeadf | ||
|
|
bf7e1328c4 | ||
|
|
946d693768 | ||
|
|
aa9670ad2f | ||
|
|
c8845a10fb | ||
|
|
b81d239dbb | ||
|
|
f0176013b7 | ||
|
|
292d7a7ae5 | ||
|
|
8eb8ad993a | ||
|
|
3b947c29de | ||
|
|
fb20d59aa8 | ||
|
|
9dd1099e28 | ||
|
|
81e3119c51 | ||
|
|
86eae42d6f | ||
|
|
58033a375f | ||
|
|
77ac0f4198 | ||
|
|
e1c1fc681d |
@@ -1,3 +1,8 @@
|
||||
|
||||
[/ Copyright 2005-2006 Daniel James.
|
||||
/ 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) ]
|
||||
|
||||
[section:changes Change Log]
|
||||
|
||||
[h2 Boost 1.33.0]
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
|
||||
[/ Copyright 2005-2006 Daniel James.
|
||||
/ 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) ]
|
||||
|
||||
[section:disable Disabling The Extensions]
|
||||
|
||||
While [classref boost::hash]'s extensions are generally useful, you might want
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
|
||||
[/ Copyright 2005-2006 Daniel James.
|
||||
/ 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) ]
|
||||
|
||||
[section:intro Introduction]
|
||||
|
||||
[def __tr1__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1745.pdf
|
||||
C++ Standard Library Technical Report]]
|
||||
[def __tr1-short__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1745.pdf
|
||||
Technical Report]]
|
||||
[def __tr1-full__
|
||||
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf
|
||||
Draft Technical Report on C++ Library Extensions]]
|
||||
[def __tr1__
|
||||
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf
|
||||
TR1]]
|
||||
[def __multi-index__ [@../../libs/multi_index/doc/index.html
|
||||
Boost Multi-Index Containers Library]]
|
||||
[def __multi-index-short__ [@../../libs/multi_index/doc/index.html
|
||||
Boost.MultiIndex]]
|
||||
[def __issues__ [@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
|
||||
[def __issues__
|
||||
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf
|
||||
Library Extension Technical Report Issues List]]
|
||||
[def __hash-function__ [@http://en.wikipedia.org/wiki/Hash_function hash function]]
|
||||
[def __hash-table__ [@http://en.wikipedia.org/wiki/Hash_table hash table]]
|
||||
|
||||
[classref boost::hash] is an implementation of the __hash-function__ object
|
||||
specified by the __tr1-short__. It is intended for use as the default hash function
|
||||
specified by the __tr1-full__ (TR1). It is intended for use as the default hash function
|
||||
for unordered associative containers, and the __multi-index__'s hash indexes.
|
||||
|
||||
As it is compliant with the __tr1-short__, it will work with:
|
||||
As it is compliant with __tr1__, it will work with:
|
||||
|
||||
* integers
|
||||
* floats
|
||||
@@ -25,7 +33,7 @@ As it is compliant with the __tr1-short__, it will work with:
|
||||
* strings
|
||||
|
||||
It also implements the extension proposed by Peter Dimov in issue 6.18 of the
|
||||
__issues__, this adds support for:
|
||||
__issues__ (page 63), this adds support for:
|
||||
|
||||
* arrays
|
||||
* `std::pair`
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
|
||||
[/ Copyright 2005-2006 Daniel James.
|
||||
/ 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) ]
|
||||
|
||||
[section:links Links]
|
||||
|
||||
[*A Proposal to Add Hash Tables to the Standard Library]\n
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
|
||||
[/ Copyright 2005-2006 Daniel James.
|
||||
/ 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) ]
|
||||
|
||||
[section:portability Portability]
|
||||
|
||||
[def __boost_hash__ [classref boost::hash]]
|
||||
|
||||
401
doc/ref.xml
401
doc/ref.xml
@@ -1,9 +1,15 @@
|
||||
<!--
|
||||
Copyright 2005-2006 Daniel James.
|
||||
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/n1745.pdf">C++ Standard Library Technical Report</ulink>
|
||||
<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/n1756.pdf">Library Extension Technical Report Issues List</ulink>.
|
||||
<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/functional/hash.hpp">
|
||||
@@ -27,7 +33,7 @@
|
||||
<classname>std::unary_function<T, std::size_t></classname>
|
||||
</inherit>
|
||||
|
||||
<purpose>An STL compliant hash function object.</purpose>
|
||||
<purpose>A <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">TR1</ulink> compliant hash function object.</purpose>
|
||||
|
||||
<method name="operator()" cv="const">
|
||||
<type>std::size_t</type>
|
||||
@@ -68,7 +74,7 @@
|
||||
</parameter>
|
||||
<returns>
|
||||
<para>Unspecified in TR1, except that equal arguments yield the same result.</para>
|
||||
<para><functionname alt="boost::hash_value(bool)">hash_value</functionname>(val) in Boost.</para>
|
||||
<para><functionname>hash_value</functionname>(val) in Boost.</para>
|
||||
</returns>
|
||||
<throws><para>Doesn't throw</para></throws>
|
||||
</method>
|
||||
@@ -266,7 +272,7 @@
|
||||
</parameter>
|
||||
<returns>
|
||||
<para>Unspecified in TR1, except that equal arguments yield the same result.</para>
|
||||
<para><functionname alt="boost::hash_value(float)">hash_value</functionname>(val) in Boost.</para>
|
||||
<para><functionname>hash_value</functionname>(val) in Boost.</para>
|
||||
</returns>
|
||||
<throws><para>Doesn't throw</para></throws>
|
||||
</method>
|
||||
@@ -344,6 +350,25 @@
|
||||
</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>
|
||||
|
||||
<!--
|
||||
boost::hash_combine
|
||||
-->
|
||||
@@ -354,7 +379,7 @@
|
||||
</template>
|
||||
<type>void</type>
|
||||
<parameter name="seed"><paramtype>size_t &</paramtype></parameter>
|
||||
<parameter name="v"><paramtype>T const &</paramtype></parameter>
|
||||
<parameter name="v"><paramtype>T const&</paramtype></parameter>
|
||||
<purpose>
|
||||
Called repeatedly to incrementally create a hash value from
|
||||
several variables.
|
||||
@@ -444,21 +469,9 @@ for(; first != last; ++first)
|
||||
|
||||
<overloaded-function name="hash_value">
|
||||
<purpose>
|
||||
Implementation of a hash function for integers.
|
||||
Implementation of the hash function.
|
||||
</purpose>
|
||||
|
||||
<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 hash_value without namespace qualification so that overloads
|
||||
for custom types are found via ADL.
|
||||
</para></description>
|
||||
<notes>
|
||||
<para>Overloads for other types supplied in other headers.</para>
|
||||
<para>This is an extension to TR1</para>
|
||||
</notes>
|
||||
|
||||
<signature>
|
||||
<type>std::size_t</type>
|
||||
<parameter name="val"><paramtype>int</paramtype></parameter>
|
||||
@@ -479,32 +492,6 @@ for(; first != last; ++first)
|
||||
<parameter name="val"><paramtype>unsigned long</paramtype></parameter>
|
||||
</signature>
|
||||
|
||||
<returns>
|
||||
<code>val</code>
|
||||
</returns>
|
||||
</overloaded-function>
|
||||
|
||||
<!--
|
||||
boost::hash_value - floating point
|
||||
-->
|
||||
|
||||
<overloaded-function name="hash_value">
|
||||
<purpose>
|
||||
Implementation of a hash function for floating point values.
|
||||
</purpose>
|
||||
|
||||
<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 hash_value without namespace qualification so that overloads
|
||||
for custom types are found via ADL.
|
||||
</para></description>
|
||||
<notes>
|
||||
<para>Overloads for other types supplied in other headers.</para>
|
||||
<para>This is an extension to TR1</para>
|
||||
</notes>
|
||||
|
||||
<signature>
|
||||
<type>std::size_t</type>
|
||||
<parameter name="val"><paramtype>float</paramtype></parameter>
|
||||
@@ -520,70 +507,12 @@ for(; first != last; ++first)
|
||||
<parameter name="val"><paramtype>long double</paramtype></parameter>
|
||||
</signature>
|
||||
|
||||
<returns>
|
||||
<para>
|
||||
An unspecified value, except that equal arguments shall yield the same
|
||||
result
|
||||
</para>
|
||||
</returns>
|
||||
</overloaded-function>
|
||||
|
||||
<!--
|
||||
boost::hash_value - pointers
|
||||
-->
|
||||
|
||||
<overloaded-function name="hash_value">
|
||||
<purpose>
|
||||
Implementation of a hash function for pointers.
|
||||
</purpose>
|
||||
|
||||
<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 hash_value without namespace qualification so that overloads
|
||||
for custom types are found via ADL.
|
||||
</para></description>
|
||||
<notes>
|
||||
<para>Overloads for other types supplied in other headers.</para>
|
||||
<para>This is an extension to TR1</para>
|
||||
</notes>
|
||||
|
||||
<signature>
|
||||
<template><template-type-parameter name="T"/></template>
|
||||
<type>std::size_t</type>
|
||||
<parameter name="val"><paramtype>T* const&</paramtype></parameter>
|
||||
</signature>
|
||||
|
||||
<returns>
|
||||
<para>
|
||||
An unspecified value, except that equal arguments shall yield the same
|
||||
result
|
||||
</para>
|
||||
</returns>
|
||||
</overloaded-function>
|
||||
|
||||
<!--
|
||||
boost::hash_value - arrays
|
||||
-->
|
||||
|
||||
<overloaded-function name="hash_value">
|
||||
<purpose>
|
||||
Implementation of a hash function for built in arrays.
|
||||
</purpose>
|
||||
|
||||
<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 hash_value without namespace qualification so that overloads
|
||||
for custom types are found via ADL.
|
||||
</para></description>
|
||||
<notes>
|
||||
<para>Overloads for other types supplied in other headers.</para>
|
||||
<para>This is an extension to TR1</para>
|
||||
</notes>
|
||||
|
||||
<signature>
|
||||
<template>
|
||||
<template-type-parameter name="T"/>
|
||||
@@ -602,30 +531,6 @@ for(; first != last; ++first)
|
||||
<parameter><paramtype>const T (&val)[N]</paramtype></parameter>
|
||||
</signature>
|
||||
|
||||
<returns><code>hash_range(val, val+N)</code></returns>
|
||||
</overloaded-function>
|
||||
|
||||
<!--
|
||||
boost::hash_value - string
|
||||
-->
|
||||
|
||||
<overloaded-function name="hash_value">
|
||||
<purpose>
|
||||
Implementation of a hash function for <code>std::basic_string</code>.
|
||||
</purpose>
|
||||
|
||||
<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 hash_value without namespace qualification so that overloads
|
||||
for custom types are found via ADL.
|
||||
</para></description>
|
||||
<notes>
|
||||
<para>Overloads for other types supplied in other headers.</para>
|
||||
<para>This is an extension to TR1</para>
|
||||
</notes>
|
||||
|
||||
<signature>
|
||||
<template>
|
||||
<template-type-parameter name="Ch"/>
|
||||
@@ -636,118 +541,158 @@ for(; first != last; ++first)
|
||||
<paramtype>std::basic_string<Ch, std::char_traits<Ch>, A> const&</paramtype>
|
||||
</parameter>
|
||||
</signature>
|
||||
|
||||
<returns><code>hash_range(val.begin(), val.end())</code></returns>
|
||||
</overloaded-function>
|
||||
|
||||
<!--
|
||||
boost::hash_value - pairs
|
||||
-->
|
||||
|
||||
<overloaded-function name="hash_value">
|
||||
<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>
|
||||
<parameter name="val"><paramtype>std::pair<A, B> const&</paramtype></parameter>
|
||||
</signature>
|
||||
<effects><programlisting>
|
||||
size_t seed = 0;
|
||||
<functionname>hash_combine</functionname>(seed, val.first);
|
||||
<functionname>hash_combine</functionname>(seed, val.second);
|
||||
return seed;
|
||||
</programlisting></effects>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
</notes>
|
||||
|
||||
<throws>
|
||||
Only throws if <code><functionname>hash_value</functionname>(A)</code>
|
||||
or <code><functionname>hash_value</functionname>(B)</code> 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>
|
||||
<notes><para>This is an extension to TR1</para></notes>
|
||||
</overloaded-function>
|
||||
|
||||
<!--
|
||||
boost::hash_value - containers
|
||||
-->
|
||||
|
||||
<overloaded-function name="hash_value">
|
||||
<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>
|
||||
|
||||
<returns>
|
||||
<code><functionname>hash_range</functionname>(val.begin(), val.end());</code>
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Types</entry>
|
||||
<entry>Returns</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><code>int</code>, <code>unsigned int</code>, <code>long</code>, <code>unsigned long</code></entry>
|
||||
<entry><code>val</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>
|
||||
</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>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</returns>
|
||||
<throws>
|
||||
Only throws if <code><functionname>hash_value</functionname>(T)</code> throws.
|
||||
</throws>
|
||||
<notes><para>This is an extension to TR1</para></notes>
|
||||
</overloaded-function>
|
||||
</overloaded-function>
|
||||
</namespace>
|
||||
</header>
|
||||
</library-reference>
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
|
||||
[/ Copyright 2005-2006 Daniel James.
|
||||
/ 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) ]
|
||||
|
||||
[section:acknowledgements Acknowledgements]
|
||||
|
||||
This library is based on the design by Peter Dimov. During the initial
|
||||
development
|
||||
Joaquín M López Muñoz made many useful suggestions and contributed fixes.
|
||||
This library is based on the design by Peter Dimov's original design.
|
||||
|
||||
During the initial development Joaquín M López Muñoz made many useful
|
||||
suggestions, contributed fixes.
|
||||
|
||||
The formal review was managed by Thorsten Ottosen, and the library reviewed by:
|
||||
David Abrahams, Alberto Barbati, Topher Cooper, Caleb Epstein, Dave Harris,
|
||||
Chris Jefferson, Bronek Kozicki, John Maddock, Tobias Swinger, Jaap Suter,
|
||||
Rob Stewart and Pavel Vozenilek. Since then, further constructive criticism has
|
||||
been made by Daniel Krügler, Alexander Nasonov and 沈慧峰.
|
||||
Chris Jefferson, Bronek Kozicki, John Maddock, Tobias Swinger, Jaap Suter, Rob
|
||||
Stewart and Pavel Vozenilek. Since then, there have been further contributions
|
||||
from Daniel Krügler, Alexander Nasonov, 沈慧峰 and John Maddock.
|
||||
|
||||
The implementation of the hash function for pointers is based on suggestions
|
||||
made by Alberto Barbati and Dave Harris. Dave Harris also suggested an
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
|
||||
[/ Copyright 2005-2006 Daniel James.
|
||||
/ 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) ]
|
||||
|
||||
[def __multi-index-short__ [@../../libs/multi_index/doc/index.html
|
||||
Boost.MultiIndex]]
|
||||
|
||||
@@ -12,7 +17,7 @@ If your standard library supplies its own implementation of the unordered
|
||||
associative containers and you wish to use
|
||||
[classref boost::hash], just use an extra template parameter:
|
||||
|
||||
std::unordered_multiset<std::vector<int>, ``[classref boost::hash]``<int> >
|
||||
std::unordered_multiset<int, ``[classref boost::hash]``<int> >
|
||||
set_of_ints;
|
||||
|
||||
std::unordered_set<std::pair<int, int>, ``[classref boost::hash]``<std::pair<int, int> >
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
# (C) Copyright Daniel James 2005.
|
||||
# Use, modification and distribution are subject to 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)
|
||||
|
||||
subproject libs/functional/hash/examples ;
|
||||
|
||||
import testing ;
|
||||
|
||||
DEPENDS all : test ;
|
||||
|
||||
rule hash-example ( name )
|
||||
{
|
||||
return [
|
||||
run $(name).cpp
|
||||
: : : <include>$(BOOST_ROOT)
|
||||
] ;
|
||||
}
|
||||
|
||||
{
|
||||
test-suite functional/examples
|
||||
:
|
||||
[ hash-example books ]
|
||||
[ hash-example point ]
|
||||
[ hash-example portable ]
|
||||
;
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
// STLport:
|
||||
#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
||||
# if defined(__GNUC__) && __GNUC__ < 3 && (defined(linux) || defined(__linux) || defined(__linux__))
|
||||
# if (defined(__GNUC__) && __GNUC__ < 3 && (defined(linux) || defined(__linux) || defined(__linux__))) || defined(__DMC__)
|
||||
# define BOOST_HASH_USE_C99_FLOAT_FUNCS
|
||||
# elif defined(BOOST_MSVC) && BOOST_MSVC < 1300
|
||||
# define BOOST_HASH_USE_C99_FLOAT_FUNCS
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
# if defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
||||
// GNU libstdc++ 3
|
||||
# if defined(__USE_ISOC99) || defined(_GLIBCXX_USE_C99_MATH)
|
||||
# if (defined(__USE_ISOC99) || defined(_GLIBCXX_USE_C99_MATH)) && \
|
||||
!(defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
|
||||
# define BOOST_HASH_USE_FPCLASSIFY
|
||||
# endif
|
||||
# elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||
// subject to 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)
|
||||
|
||||
// Based on Peter Dimov's proposal
|
||||
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
|
||||
// issue 6.18.
|
||||
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_DEQUE_HPP)
|
||||
#define BOOST_FUNCTIONAL_HASH_DEQUE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#warning "boost/functional/hash/deque.hpp is deprecated, use boost/functional/hash.hpp instead."
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,19 @@ namespace boost
|
||||
std::size_t hash_value(long);
|
||||
std::size_t hash_value(unsigned long);
|
||||
|
||||
#if defined(BOOST_MSVC) && defined(_WIN64)
|
||||
// On 64-bit windows std::size_t is a typedef for unsigned long long, which
|
||||
// isn't due to be supported until Boost 1.35. So add support here.
|
||||
// (Technically, Boost.Hash isn't actually documented as supporting
|
||||
// std::size_t. But it would be pretty silly not to).
|
||||
std::size_t hash_value(std::size_t);
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(__DMC__, <= 0x848)
|
||||
template <class T> std::size_t hash_value(T* const&);
|
||||
#else
|
||||
template <class T> std::size_t hash_value(T*);
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
||||
template< class T, unsigned N >
|
||||
@@ -104,8 +116,24 @@ namespace boost
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
|
||||
#if defined(_M_X64) && defined(_WIN64)
|
||||
inline std::size_t hash_value(long long v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
inline std::size_t hash_value(unsigned long long v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Implementation by Alberto Barbati and Dave Harris.
|
||||
#if !BOOST_WORKAROUND(__DMC__, <= 0x848)
|
||||
template <class T> std::size_t hash_value(T* const& v)
|
||||
#else
|
||||
template <class T> std::size_t hash_value(T* v)
|
||||
#endif
|
||||
{
|
||||
std::size_t x = static_cast<std::size_t>(
|
||||
reinterpret_cast<std::ptrdiff_t>(v));
|
||||
@@ -380,7 +408,7 @@ namespace boost
|
||||
}
|
||||
|
||||
template <class T> struct hash
|
||||
: public hash_detail::hash_impl<boost::is_pointer<T>::value>
|
||||
: public boost::hash_detail::hash_impl<boost::is_pointer<T>::value>
|
||||
::BOOST_NESTED_TEMPLATE inner<T>
|
||||
{
|
||||
};
|
||||
@@ -460,7 +488,18 @@ namespace boost
|
||||
#endif
|
||||
};
|
||||
|
||||
#elif !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
#if BOOST_WORKAROUND(__DMC__, <= 0x848)
|
||||
template <class T, unsigned int n> struct hash<T[n]>
|
||||
: std::unary_function<T[n], std::size_t>
|
||||
{
|
||||
std::size_t operator()(const T* val) const
|
||||
{
|
||||
return boost::hash_range(val, val+n);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// On compilers without partial specialization, boost::hash<T>
|
||||
// has already been declared to deal with pointers, so just
|
||||
@@ -468,6 +507,11 @@ namespace boost
|
||||
|
||||
namespace hash_detail
|
||||
{
|
||||
template <bool IsPointer>
|
||||
struct hash_impl;
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
template <>
|
||||
struct hash_impl<false>
|
||||
{
|
||||
@@ -488,15 +532,12 @@ namespace boost
|
||||
#endif
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#else // Visual C++ 6.5
|
||||
|
||||
// There's probably a more elegant way to Visual C++ 6.5 to work
|
||||
// but I don't know what it is.
|
||||
|
||||
namespace hash_detail
|
||||
{
|
||||
template <bool IsConst>
|
||||
struct hash_impl_msvc
|
||||
{
|
||||
@@ -541,8 +582,10 @@ namespace boost
|
||||
template <class T>
|
||||
struct inner : public hash_impl_msvc2<T> {};
|
||||
};
|
||||
|
||||
#endif // Visual C++ 6.5
|
||||
}
|
||||
#endif
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||
// subject to 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)
|
||||
|
||||
// Based on Peter Dimov's proposal
|
||||
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
|
||||
// issue 6.18.
|
||||
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_LIST_HPP)
|
||||
#define BOOST_FUNCTIONAL_HASH_LIST_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#warning "boost/functional/hash/list.hpp is deprecated, use boost/functional/hash.hpp instead."
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||
// subject to 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)
|
||||
|
||||
// Based on Peter Dimov's proposal
|
||||
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
|
||||
// issue 6.18.
|
||||
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_MAP_HPP)
|
||||
#define BOOST_FUNCTIONAL_HASH_MAP_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#warning "boost/functional/hash/map.hpp is deprecated, use boost/functional/hash.hpp instead."
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||
// subject to 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)
|
||||
|
||||
// Based on Peter Dimov's proposal
|
||||
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
|
||||
// issue 6.18.
|
||||
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_PAIR_HPP)
|
||||
#define BOOST_FUNCTIONAL_HASH_PAIR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#warning "boost/functional/hash/pair.hpp is deprecated, use boost/functional/hash.hpp instead."
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#endif
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||
// subject to 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)
|
||||
|
||||
// Based on Peter Dimov's proposal
|
||||
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
|
||||
// issue 6.18.
|
||||
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_SET_HPP)
|
||||
#define BOOST_FUNCTIONAL_HASH_SET_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#warning "boost/functional/hash/set.hpp is deprecated, use boost/functional/hash.hpp instead."
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||
// subject to 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)
|
||||
|
||||
// Based on Peter Dimov's proposal
|
||||
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
|
||||
// issue 6.18.
|
||||
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_VECTOR_HPP)
|
||||
#define BOOST_FUNCTIONAL_HASH_VECTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#warning "boost/functional/hash/vector.hpp is deprecated, use boost/functional/hash.hpp instead."
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,10 @@
|
||||
|
||||
<!--
|
||||
Copyright 2005-2006 Daniel James.
|
||||
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)
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=../../doc/html/hash.html">
|
||||
|
||||
51
test/Jamfile
51
test/Jamfile
@@ -1,51 +0,0 @@
|
||||
|
||||
# Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||
# subject to 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)
|
||||
|
||||
subproject libs/functional/hash/test ;
|
||||
|
||||
import testing ;
|
||||
|
||||
DEPENDS all : test ;
|
||||
|
||||
rule hash-test ( names + : extras * )
|
||||
{
|
||||
return [
|
||||
run $(names).cpp
|
||||
: : : <include>$(BOOST_ROOT) $(extras)
|
||||
: $(names[1])
|
||||
] ;
|
||||
}
|
||||
|
||||
{
|
||||
test-suite functional/hash
|
||||
:
|
||||
[ hash-test hash_fwd_test_1 ]
|
||||
[ hash-test hash_fwd_test_2 ]
|
||||
[ hash-test hash_number_test ]
|
||||
[ hash-test hash_pointer_test ]
|
||||
[ hash-test hash_function_pointer_test ]
|
||||
[ hash-test hash_float_test : <test-info>always_show_run_output ]
|
||||
[ hash-test hash_string_test ]
|
||||
[ hash-test hash_range_test ]
|
||||
[ hash-test hash_custom_test ]
|
||||
[ hash-test hash_global_namespace_test ]
|
||||
[ hash-test hash_friend_test ]
|
||||
[ hash-test hash_built_in_array_test ]
|
||||
[ hash-test hash_value_array_test ]
|
||||
[ hash-test hash_vector_test ]
|
||||
[ hash-test hash_list_test ]
|
||||
[ hash-test hash_deque_test ]
|
||||
[ hash-test hash_set_test ]
|
||||
[ hash-test hash_map_test ]
|
||||
[ hash-test link_test link_test_2 ]
|
||||
[ hash-test link_ext_test link_no_ext_test ]
|
||||
[ run container_fwd_test.cpp : : : <include>$(BOOST_ROOT) ]
|
||||
[ compile-fail hash_no_ext_fail_test.cpp ]
|
||||
[ run hash_no_ext_macro_1.cpp ]
|
||||
[ run hash_no_ext_macro_2.cpp ]
|
||||
;
|
||||
}
|
||||
|
||||
subinclude libs/functional/hash/examples ;
|
||||
@@ -125,12 +125,17 @@ void float_tests(char const* name, T* = 0)
|
||||
BOOST_TEST(x1(half_max) != x1(three_quarter_max));
|
||||
BOOST_TEST(x1(three_quarter_max) == x1(three_quarter_max));
|
||||
|
||||
// Intel with gcc stdlib sometimes segfaults on calls to asin and acos.
|
||||
#if !((defined(__INTEL_COMPILER) || defined(__ICL) || \
|
||||
defined(__ICC) || defined(__ECC)) && \
|
||||
(defined(__GLIBCPP__) || defined(__GLIBCXX__)))
|
||||
T v1 = asin((T) 1);
|
||||
T v2 = acos((T) 0);
|
||||
if(v1 == v2)
|
||||
BOOST_TEST(x1(v1) == x1(v2));
|
||||
BOOST_TEST(x1(v1) == HASH_NAMESPACE::hash_value(v1));
|
||||
BOOST_TEST(x1(v2) == HASH_NAMESPACE::hash_value(v2));
|
||||
#endif
|
||||
|
||||
BOOST_TEST(x1(std::numeric_limits<T>::epsilon()) ==
|
||||
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::epsilon()));
|
||||
|
||||
Reference in New Issue
Block a user