Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64031 - in branches/release: boost/functional/hash libs/functional/hash libs/functional/hash/doc libs/functional/hash/test libs/range libs/range/doc
From: daniel_james_at_[hidden]
Date: 2010-07-14 21:12:25


Author: danieljames
Date: 2010-07-14 21:12:23 EDT (Wed, 14 Jul 2010)
New Revision: 64031
URL: http://svn.boost.org/trac/boost/changeset/64031

Log:
Merge hash, opt-in to breaking change rather than opt-out.
Properties modified:
   branches/release/boost/functional/hash/ (props changed)
   branches/release/libs/functional/hash/ (props changed)
   branches/release/libs/range/ (props changed)
   branches/release/libs/range/doc/ (props changed)
Text files modified:
   branches/release/boost/functional/hash/hash.hpp | 5 ++++-
   branches/release/libs/functional/hash/doc/changes.qbk | 15 ++++++++++-----
   branches/release/libs/functional/hash/test/Jamfile.v2 | 1 +
   3 files changed, 15 insertions(+), 6 deletions(-)

Modified: branches/release/boost/functional/hash/hash.hpp
==============================================================================
--- branches/release/boost/functional/hash/hash.hpp (original)
+++ branches/release/boost/functional/hash/hash.hpp 2010-07-14 21:12:23 EDT (Wed, 14 Jul 2010)
@@ -15,7 +15,10 @@
 #include <boost/functional/hash/detail/hash_float.hpp>
 #include <string>
 #include <boost/limits.hpp>
+
+#if defined(BOOST_HASH_NO_IMPLICIT_CASTS)
 #include <boost/static_assert.hpp>
+#endif
 
 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
 #include <boost/type_traits/is_pointer.hpp>
@@ -30,7 +33,7 @@
 
 namespace boost
 {
-#if !defined(BOOST_HASH_ALLOW_IMPLICIT_CASTS)
+#if defined(BOOST_HASH_NO_IMPLICIT_CASTS)
 
     // If you get a static assertion here, it's because hash_value
     // isn't declared for your type.

Modified: branches/release/libs/functional/hash/doc/changes.qbk
==============================================================================
--- branches/release/libs/functional/hash/doc/changes.qbk (original)
+++ branches/release/libs/functional/hash/doc/changes.qbk 2010-07-14 21:12:23 EDT (Wed, 14 Jul 2010)
@@ -108,10 +108,15 @@
 
 [h2 Boost 1.44.0]
 
-* Prevent implicit conversions when calling `hash_value`. If you find
- that the new version breaks your code, you can enable the old
- behaviour by defining `BOOST_HASH_ALLOW_IMPLICIT_CASTS` - although
- I would recommend that you update your code to work with the new
- version.
+* Add option to prevent implicit conversions when calling `hash_value` by
+ defining `BOOST_HASH_NO_IMPLICIT_CASTS`. When using `boost::hash`
+ for a type that does not have `hash_value` declared but does have
+ an implicit conversion to a type that does, it would use that
+ implicit conversion to hash it. Which can sometimes go very wrong,
+ e.g. using a conversion to bool and only hashing to 2 possible
+ values. Since fixing this is a breaking change and was only
+ approached quite late in the release cycle with little discussion
+ it's opt-in for now. This, or something like it, will become the
+ default in a future version.
 
 [endsect]

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 2010-07-14 21:12:23 EDT (Wed, 14 Jul 2010)
@@ -7,6 +7,7 @@
 
 project hash-tests
     : requirements
+ <define>BOOST_HASH_NO_IMPLICIT_CASTS
         <warnings>all
         <toolset>intel:<warnings>on
         <toolset>intel:<cxxflags>-strict-ansi


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