Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68199 - in branches/release: boost/functional/hash libs/functional/hash libs/functional/hash/doc libs/functional/hash/test
From: dnljms_at_[hidden]
Date: 2011-01-16 23:15:13


Author: danieljames
Date: 2011-01-16 23:15:00 EST (Sun, 16 Jan 2011)
New Revision: 68199
URL: http://svn.boost.org/trac/boost/changeset/68199

Log:
Merge typeindex support for hash. Fixes #4756.

Added:
   branches/release/libs/functional/hash/test/hash_type_index_test.cpp
      - copied unchanged from r68162, /trunk/libs/functional/hash/test/hash_type_index_test.cpp
Properties modified:
   branches/release/boost/functional/hash/ (props changed)
   branches/release/libs/functional/hash/ (props changed)
Text files modified:
   branches/release/boost/functional/hash/hash.hpp | 19 +++++++++++++++++++
   branches/release/libs/functional/hash/doc/ref.xml | 34 ++++++++++++++++++++++++++++++++++
   branches/release/libs/functional/hash/test/Jamfile.v2 | 1 +
   3 files changed, 54 insertions(+), 0 deletions(-)

Modified: branches/release/boost/functional/hash/hash.hpp
==============================================================================
--- branches/release/boost/functional/hash/hash.hpp (original)
+++ branches/release/boost/functional/hash/hash.hpp 2011-01-16 23:15:00 EST (Sun, 16 Jan 2011)
@@ -24,6 +24,10 @@
 #include <boost/type_traits/is_pointer.hpp>
 #endif
 
+#if !defined(BOOST_NO_0X_HDR_TYPEINDEX)
+#include <typeindex>
+#endif
+
 #if BOOST_WORKAROUND(__GNUC__, < 3) \
     && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
 #define BOOST_HASH_CHAR_TRAITS string_char_traits
@@ -87,6 +91,10 @@
     std::size_t hash_value(
         std::basic_string<Ch, std::BOOST_HASH_CHAR_TRAITS<Ch>, A> const&);
 
+#if !defined(BOOST_NO_0X_HDR_TYPEINDEX)
+ std::size_t hash_value(std::type_index);
+#endif
+
     // Implementation
 
     namespace hash_detail
@@ -331,6 +339,13 @@
         return boost::hash_detail::float_hash_value(v);
     }
 
+#if !defined(BOOST_NO_0X_HDR_TYPEINDEX)
+ inline std::size_t hash_value(std::type_index v)
+ {
+ return v.hash_code();
+ }
+#endif
+
     //
     // boost::hash
     //
@@ -435,6 +450,10 @@
     BOOST_HASH_SPECIALIZE(boost::ulong_long_type)
 #endif
 
+#if !defined(BOOST_NO_0X_HDR_TYPEINDEX)
+ BOOST_HASH_SPECIALIZE(std::type_index)
+#endif
+
 #undef BOOST_HASH_SPECIALIZE
 #undef BOOST_HASH_SPECIALIZE_REF
 

Modified: branches/release/libs/functional/hash/doc/ref.xml
==============================================================================
--- branches/release/libs/functional/hash/doc/ref.xml (original)
+++ branches/release/libs/functional/hash/doc/ref.xml 2011-01-16 23:15:00 EST (Sun, 16 Jan 2011)
@@ -406,6 +406,29 @@
         </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).">
 
       <!--
@@ -716,6 +739,11 @@
           <parameter name="val"><paramtype>std::complex&lt;T&gt; const&amp;</paramtype></parameter>
         </signature>
 
+ <signature>
+ <type>std::size_t</type>
+ <parameter name="val"><paramtype>std::type_index</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>
@@ -798,6 +826,12 @@
                   </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>

Modified: branches/release/libs/functional/hash/test/Jamfile.v2
==============================================================================
--- branches/release/libs/functional/hash/test/Jamfile.v2 (original)
+++ branches/release/libs/functional/hash/test/Jamfile.v2 2011-01-16 23:15:00 EST (Sun, 16 Jan 2011)
@@ -40,6 +40,7 @@
         [ run hash_set_test.cpp ]
         [ run hash_map_test.cpp ]
         [ run hash_complex_test.cpp ]
+ [ run hash_type_index_test.cpp ]
         [ run link_test.cpp link_test_2.cpp ]
         [ run link_ext_test.cpp link_no_ext_test.cpp ]
         [ run extensions_hpp_test.cpp ]


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk