Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53159 - in trunk: boost/functional/hash boost/functional/hash/detail libs/functional/hash/test
From: daniel_james_at_[hidden]
Date: 2009-05-21 17:21:15


Author: danieljames
Date: 2009-05-21 17:21:11 EDT (Thu, 21 May 2009)
New Revision: 53159
URL: http://svn.boost.org/trac/boost/changeset/53159

Log:
Move the hash limits workaround into its own file.
Added:
   trunk/boost/functional/hash/detail/limits.hpp (contents, props changed)
Text files modified:
   trunk/boost/functional/hash/detail/hash_float.hpp | 35 +----------------------------------
   trunk/boost/functional/hash/hash.hpp | 1 +
   trunk/libs/functional/hash/test/hash_float_test.hpp | 2 +-
   trunk/libs/functional/hash/test/hash_function_pointer_test.cpp | 1 -
   trunk/libs/functional/hash/test/hash_number_test.cpp | 2 +-
   trunk/libs/functional/hash/test/hash_string_test.cpp | 1 -
   6 files changed, 4 insertions(+), 38 deletions(-)

Modified: trunk/boost/functional/hash/detail/hash_float.hpp
==============================================================================
--- trunk/boost/functional/hash/detail/hash_float.hpp (original)
+++ trunk/boost/functional/hash/detail/hash_float.hpp 2009-05-21 17:21:11 EDT (Thu, 21 May 2009)
@@ -19,9 +19,9 @@
 #endif
 
 #include <boost/functional/hash/detail/float_functions.hpp>
+#include <boost/functional/hash/detail/limits.hpp>
 #include <boost/integer/static_log2.hpp>
 #include <boost/cstdint.hpp>
-#include <boost/limits.hpp>
 #include <boost/assert.hpp>
 
 // Select implementation for the current platform.
@@ -50,43 +50,10 @@
 
 #endif
 
-// On OpenBSD, numeric_limits is not reliable for long doubles, but
-// the macros defined in <float.h> are.
-
-#if defined(__OpenBSD__)
-#include <float.h>
-#endif
-
 namespace boost
 {
     namespace hash_detail
     {
- template <class T>
- struct limits : std::numeric_limits<T> {};
-
-#if defined(__OpenBSD__)
- template <>
- struct limits<long double>
- : std::numeric_limits<long double>
- {
- static long double epsilon() {
- return LDBL_EPSILON;
- }
-
- static long double (max)() {
- return LDBL_MAX;
- }
-
- static long double (min)() {
- return LDBL_MIN;
- }
-
- BOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG);
- BOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP);
- BOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP);
- };
-#endif // __OpenBSD__
-
         inline void hash_float_combine(std::size_t& seed, std::size_t value)
         {
             seed ^= value + (seed<<6) + (seed>>2);

Added: trunk/boost/functional/hash/detail/limits.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/functional/hash/detail/limits.hpp 2009-05-21 17:21:11 EDT (Thu, 21 May 2009)
@@ -0,0 +1,57 @@
+
+// Copyright 2005-2009 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)
+//
+// On some platforms std::limits gives incorrect values for long double.
+// This tries to work around them.
+
+#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER)
+#define BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/limits.hpp>
+
+// On OpenBSD, numeric_limits is not reliable for long doubles, but
+// the macros defined in <float.h> are.
+
+#if defined(__OpenBSD__)
+#include <float.h>
+#endif
+
+namespace boost
+{
+ namespace hash_detail
+ {
+ template <class T>
+ struct limits : std::numeric_limits<T> {};
+
+#if defined(__OpenBSD__)
+ template <>
+ struct limits<long double>
+ : std::numeric_limits<long double>
+ {
+ static long double epsilon() {
+ return LDBL_EPSILON;
+ }
+
+ static long double (max)() {
+ return LDBL_MAX;
+ }
+
+ static long double (min)() {
+ return LDBL_MIN;
+ }
+
+ BOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG);
+ BOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP);
+ BOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP);
+ };
+#endif // __OpenBSD__
+ }
+}
+
+#endif
\ No newline at end of file

Modified: trunk/boost/functional/hash/hash.hpp
==============================================================================
--- trunk/boost/functional/hash/hash.hpp (original)
+++ trunk/boost/functional/hash/hash.hpp 2009-05-21 17:21:11 EDT (Thu, 21 May 2009)
@@ -15,6 +15,7 @@
 #include <boost/functional/hash/detail/hash_float.hpp>
 #include <boost/detail/container_fwd.hpp>
 #include <string>
+#include <boost/limits.hpp>
 
 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
 #include <boost/type_traits/is_pointer.hpp>

Modified: trunk/libs/functional/hash/test/hash_float_test.hpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_float_test.hpp (original)
+++ trunk/libs/functional/hash/test/hash_float_test.hpp 2009-05-21 17:21:11 EDT (Thu, 21 May 2009)
@@ -14,7 +14,7 @@
 #include <boost/detail/lightweight_test.hpp>
 
 #include <cmath>
-#include <boost/limits.hpp>
+#include <boost/functional/hash/detail/limits.hpp>
 
 #include <iostream>
 

Modified: trunk/libs/functional/hash/test/hash_function_pointer_test.cpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_function_pointer_test.cpp (original)
+++ trunk/libs/functional/hash/test/hash_function_pointer_test.cpp 2009-05-21 17:21:11 EDT (Thu, 21 May 2009)
@@ -13,7 +13,6 @@
 
 #include <boost/detail/lightweight_test.hpp>
 
-#include <boost/limits.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/type_traits/is_base_and_derived.hpp>
 

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 2009-05-21 17:21:11 EDT (Thu, 21 May 2009)
@@ -15,7 +15,7 @@
 #include <boost/detail/lightweight_test.hpp>
 
 #include <boost/preprocessor/cat.hpp>
-#include <boost/limits.hpp>
+#include <boost/functional/hash/detail/limits.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/type_traits/is_base_and_derived.hpp>
 

Modified: trunk/libs/functional/hash/test/hash_string_test.cpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_string_test.cpp (original)
+++ trunk/libs/functional/hash/test/hash_string_test.cpp 2009-05-21 17:21:11 EDT (Thu, 21 May 2009)
@@ -13,7 +13,6 @@
 
 #include <boost/detail/lightweight_test.hpp>
 
-#include <boost/limits.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/type_traits/is_base_and_derived.hpp>
 #include <string>


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