$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r67170 - in trunk: boost/functional/hash/detail libs/functional/hash/doc libs/functional/hash/test libs/unordered/test/unordered
From: dnljms_at_[hidden]
Date: 2010-12-11 09:43:02
Author: danieljames
Date: 2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
New Revision: 67170
URL: http://svn.boost.org/trac/boost/changeset/67170
Log:
Avoid `-Wconversion` warnings in unordered & hash.
Text files modified: 
   trunk/boost/functional/hash/detail/hash_float_generic.hpp |     4 ++--                                    
   trunk/libs/functional/hash/doc/changes.qbk                |     4 ++++                                    
   trunk/libs/functional/hash/test/Jamfile.v2                |     4 ++--                                    
   trunk/libs/functional/hash/test/hash_complex_test.cpp     |     2 +-                                      
   trunk/libs/functional/hash/test/hash_number_test.cpp      |     3 ++-                                     
   trunk/libs/unordered/test/unordered/Jamfile.v2            |     4 ++--                                    
   trunk/libs/unordered/test/unordered/insert_tests.cpp      |    18 +++++++++---------                      
   trunk/libs/unordered/test/unordered/load_factor_tests.cpp |     2 +-                                      
   trunk/libs/unordered/test/unordered/rehash_tests.cpp      |     3 ++-                                     
   9 files changed, 25 insertions(+), 19 deletions(-)
Modified: trunk/boost/functional/hash/detail/hash_float_generic.hpp
==============================================================================
--- trunk/boost/functional/hash/detail/hash_float_generic.hpp	(original)
+++ trunk/boost/functional/hash/detail/hash_float_generic.hpp	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -53,7 +53,7 @@
 
             v = ldexp(v, limits<std::size_t>::digits);
             std::size_t seed = static_cast<std::size_t>(v);
-            v -= seed;
+            v -= static_cast<T>(seed);
 
             // ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1;
             std::size_t const length
@@ -66,7 +66,7 @@
             {
                 v = ldexp(v, limits<std::size_t>::digits);
                 std::size_t part = static_cast<std::size_t>(v);
-                v -= part;
+                v -= static_cast<T>(part);
                 hash_float_combine(seed, part);
             }
 
Modified: trunk/libs/functional/hash/doc/changes.qbk
==============================================================================
--- trunk/libs/functional/hash/doc/changes.qbk	(original)
+++ trunk/libs/functional/hash/doc/changes.qbk	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -119,4 +119,8 @@
   it's opt-in for now. This, or something like it, will become the
   default in a future version.
 
+[h2 Boost 1.46.0]
+
+* Avoid warning due with gcc's `-Wconversion` flag.
+
 [endsect]
Modified: trunk/libs/functional/hash/test/Jamfile.v2
==============================================================================
--- trunk/libs/functional/hash/test/Jamfile.v2	(original)
+++ trunk/libs/functional/hash/test/Jamfile.v2	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -11,8 +11,8 @@
         <warnings>all
         <toolset>intel:<warnings>on
         <toolset>intel:<cxxflags>-strict-ansi
-        <toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
-        <toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
+        <toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
+        <toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
         <toolset>msvc:<warnings-as-errors>on
         #<toolset>gcc:<warnings-as-errors>on
         #<toolset>darwin:<warnings-as-errors>on
Modified: trunk/libs/functional/hash/test/hash_complex_test.cpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_complex_test.cpp	(original)
+++ trunk/libs/functional/hash/test/hash_complex_test.cpp	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -69,7 +69,7 @@
     generic_complex_tests(complex(0.5,0));
     generic_complex_tests(complex(25,0));
     generic_complex_tests(complex(25,0));
-    generic_complex_tests(complex(-67.5324535,56.23578678));
+    generic_complex_tests(complex(static_cast<Float>(-67.5324535),static_cast<Float>(56.23578678)));
 }
 
 template <class Integer>
Modified: trunk/libs/functional/hash/test/hash_number_test.cpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_number_test.cpp	(original)
+++ trunk/libs/functional/hash/test/hash_number_test.cpp	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -113,7 +113,8 @@
     if(T(1) != T(2))
         BOOST_TEST(x1(T(1)) !=  x2(T(2)));
     if((limits::max)() != (limits::max)() - 1)
-        BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1));
+        BOOST_TEST(x1(static_cast<T>((limits::max)()))
+        	!= x2(static_cast<T>((limits::max)() - 1)));
 }
 
 void bool_test()
Modified: trunk/libs/unordered/test/unordered/Jamfile.v2
==============================================================================
--- trunk/libs/unordered/test/unordered/Jamfile.v2	(original)
+++ trunk/libs/unordered/test/unordered/Jamfile.v2	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -9,8 +9,8 @@
     : requirements
         <warnings>all
         <toolset>intel:<warnings>on
-        <toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
-        <toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
+        <toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
+        <toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
         <toolset>gcc:<define>_GLIBCXX_DEBUG
         #<toolset>darwin:<define>_GLIBCXX_DEBUG
         <toolset>msvc:<warnings-as-errors>on
Modified: trunk/libs/unordered/test/unordered/insert_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/insert_tests.cpp	(original)
+++ trunk/libs/unordered/test/unordered/insert_tests.cpp	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -52,7 +52,7 @@
 
         tracker.compare_key(x, *it);
 
-        if(x.size() < b * old_bucket_count)
+        if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
             BOOST_TEST(x.bucket_count() == old_bucket_count);
     }
 
@@ -83,7 +83,7 @@
 
         tracker.compare_key(x, *it);
 
-        if(x.size() < b * old_bucket_count)
+        if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
             BOOST_TEST(x.bucket_count() == old_bucket_count);
     }
 
@@ -118,7 +118,7 @@
             BOOST_TEST(*r1 == *r2);
             tracker.compare_key(x, *it);
 
-            if(x.size() < b * old_bucket_count)
+            if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
                 BOOST_TEST(x.bucket_count() == old_bucket_count);
         }
 
@@ -145,7 +145,7 @@
             BOOST_TEST(*r1 == *r2);
             tracker.compare_key(x, *it);
 
-            if(x.size() < b * old_bucket_count)
+            if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
                 BOOST_TEST(x.bucket_count() == old_bucket_count);
         }
 
@@ -172,7 +172,7 @@
             BOOST_TEST(*pos == *r2);
             tracker.compare_key(x, *it);
 
-            if(x.size() < b * old_bucket_count)
+	        if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
                 BOOST_TEST(x.bucket_count() == old_bucket_count);
         }
 
@@ -197,7 +197,7 @@
             tracker.insert(*it);
             tracker.compare_key(x, *it);
 
-            if(x.size() < b * old_bucket_count)
+	        if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
                 BOOST_TEST(x.bucket_count() == old_bucket_count);
         }
 
@@ -275,7 +275,7 @@
 
         tracker.compare_key(x, *it);
 
-        if(x.size() < b * old_bucket_count)
+        if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
             BOOST_TEST(x.bucket_count() == old_bucket_count);
     }
 
@@ -306,7 +306,7 @@
 
         tracker.compare_key(x, *it);
 
-        if(x.size() < b * old_bucket_count)
+        if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
             BOOST_TEST(x.bucket_count() == old_bucket_count);
     }
 
@@ -335,7 +335,7 @@
 
         tracker.compare_key(x, *it);
 
-        if(x.size() < b * old_bucket_count)
+        if(static_cast<double>(x.size()) < b * static_cast<double>(old_bucket_count))
             BOOST_TEST(x.bucket_count() == old_bucket_count);
     }
 
Modified: trunk/libs/unordered/test/unordered/load_factor_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/load_factor_tests.cpp	(original)
+++ trunk/libs/unordered/test/unordered/load_factor_tests.cpp	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -51,7 +51,7 @@
         BOOST_DEDUCED_TYPENAME X::size_type old_size = x.size(),
                  old_bucket_count = x.bucket_count();
         x.insert(*it);
-        if(old_size + 1 < b * old_bucket_count)
+        if(static_cast<double>(old_size + 1) < b * static_cast<double>(old_bucket_count))
             BOOST_TEST(x.bucket_count() == old_bucket_count);
     }
 }
Modified: trunk/libs/unordered/test/unordered/rehash_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/rehash_tests.cpp	(original)
+++ trunk/libs/unordered/test/unordered/rehash_tests.cpp	2010-12-11 09:43:00 EST (Sat, 11 Dec 2010)
@@ -19,7 +19,8 @@
 template <class X>
 bool postcondition(X const& x, BOOST_DEDUCED_TYPENAME X::size_type n)
 {
-    return x.bucket_count() > x.size() / x.max_load_factor() &&
+    return static_cast<double>(x.bucket_count()) >
+    	static_cast<double>(x.size()) / x.max_load_factor() &&
         x.bucket_count() >= n;
 }