]> git.lyx.org Git - features.git/blobdiff - boost/boost/functional/hash/detail/hash_float_generic.hpp
boost: add eol property
[features.git] / boost / boost / functional / hash / detail / hash_float_generic.hpp
index abb16a6518e233d507be7861f390a5a58038e787..f9acee9cd1ecb34ced8fe5cdca5fb3d7d066162a 100644 (file)
@@ -1,93 +1,93 @@
-\r
-// Copyright 2005-2009 Daniel James.\r
-// Distributed under the Boost Software License, Version 1.0. (See accompanying\r
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r
-\r
-// A general purpose hash function for non-zero floating point values.\r
-\r
-#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_GENERIC_HEADER)\r
-#define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_GENERIC_HEADER\r
-\r
-#include <boost/functional/hash/detail/float_functions.hpp>\r
-#include <boost/integer/static_log2.hpp>\r
-#include <boost/functional/hash/detail/limits.hpp>\r
-\r
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)\r
-# pragma once\r
-#endif\r
-\r
-#if defined(BOOST_MSVC)\r
-#pragma warning(push)\r
-#if BOOST_MSVC >= 1400\r
-#pragma warning(disable:6294) // Ill-defined for-loop: initial condition does\r
-                              // not satisfy test. Loop body not executed \r
-#endif\r
-#endif\r
-\r
-namespace boost\r
-{\r
-    namespace hash_detail\r
-    {\r
-        inline void hash_float_combine(std::size_t& seed, std::size_t value)\r
-        {\r
-            seed ^= value + (seed<<6) + (seed>>2);\r
-        }\r
-\r
-        template <class T>\r
-        inline std::size_t float_hash_impl2(T v)\r
-        {\r
-            boost::hash_detail::call_frexp<T> frexp;\r
-            boost::hash_detail::call_ldexp<T> ldexp;\r
-        \r
-            int exp = 0;\r
-\r
-            v = frexp(v, &exp);\r
-\r
-            // A postive value is easier to hash, so combine the\r
-            // sign with the exponent and use the absolute value.\r
-            if(v < 0) {\r
-                v = -v;\r
-                exp += limits<T>::max_exponent -\r
-                    limits<T>::min_exponent;\r
-            }\r
-\r
-            // The result of frexp is always between 0.5 and 1, so its\r
-            // top bit will always be 1. Subtract by 0.5 to remove that.\r
-            v -= T(0.5);\r
-            v = ldexp(v, limits<std::size_t>::digits + 1);\r
-            std::size_t seed = static_cast<std::size_t>(v);\r
-            v -= seed;\r
-\r
-            // ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1;\r
-            std::size_t const length\r
-                = (limits<T>::digits *\r
-                        boost::static_log2<limits<T>::radix>::value - 1)\r
-                / limits<std::size_t>::digits;\r
-\r
-            for(std::size_t i = 0; i != length; ++i)\r
-            {\r
-                v = ldexp(v, limits<std::size_t>::digits);\r
-                std::size_t part = static_cast<std::size_t>(v);\r
-                v -= part;\r
-                hash_float_combine(seed, part);\r
-            }\r
-\r
-            hash_float_combine(seed, exp);\r
-\r
-            return seed;\r
-        }\r
-\r
-        template <class T>\r
-        inline std::size_t float_hash_impl(T v)\r
-        {\r
-            typedef BOOST_DEDUCED_TYPENAME select_hash_type<T>::type type;\r
-            return float_hash_impl2(static_cast<type>(v));\r
-        }\r
-    }\r
-}\r
-\r
-#if defined(BOOST_MSVC)\r
-#pragma warning(pop)\r
-#endif\r
-\r
-#endif\r
+
+// 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)
+
+// A general purpose hash function for non-zero floating point values.
+
+#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_GENERIC_HEADER)
+#define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_GENERIC_HEADER
+
+#include <boost/functional/hash/detail/float_functions.hpp>
+#include <boost/integer/static_log2.hpp>
+#include <boost/functional/hash/detail/limits.hpp>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#if defined(BOOST_MSVC)
+#pragma warning(push)
+#if BOOST_MSVC >= 1400
+#pragma warning(disable:6294) // Ill-defined for-loop: initial condition does
+                              // not satisfy test. Loop body not executed 
+#endif
+#endif
+
+namespace boost
+{
+    namespace hash_detail
+    {
+        inline void hash_float_combine(std::size_t& seed, std::size_t value)
+        {
+            seed ^= value + (seed<<6) + (seed>>2);
+        }
+
+        template <class T>
+        inline std::size_t float_hash_impl2(T v)
+        {
+            boost::hash_detail::call_frexp<T> frexp;
+            boost::hash_detail::call_ldexp<T> ldexp;
+        
+            int exp = 0;
+
+            v = frexp(v, &exp);
+
+            // A postive value is easier to hash, so combine the
+            // sign with the exponent and use the absolute value.
+            if(v < 0) {
+                v = -v;
+                exp += limits<T>::max_exponent -
+                    limits<T>::min_exponent;
+            }
+
+            // The result of frexp is always between 0.5 and 1, so its
+            // top bit will always be 1. Subtract by 0.5 to remove that.
+            v -= T(0.5);
+            v = ldexp(v, limits<std::size_t>::digits + 1);
+            std::size_t seed = static_cast<std::size_t>(v);
+            v -= seed;
+
+            // ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1;
+            std::size_t const length
+                = (limits<T>::digits *
+                        boost::static_log2<limits<T>::radix>::value - 1)
+                / limits<std::size_t>::digits;
+
+            for(std::size_t i = 0; i != length; ++i)
+            {
+                v = ldexp(v, limits<std::size_t>::digits);
+                std::size_t part = static_cast<std::size_t>(v);
+                v -= part;
+                hash_float_combine(seed, part);
+            }
+
+            hash_float_combine(seed, exp);
+
+            return seed;
+        }
+
+        template <class T>
+        inline std::size_t float_hash_impl(T v)
+        {
+            typedef BOOST_DEDUCED_TYPENAME select_hash_type<T>::type type;
+            return float_hash_impl2(static_cast<type>(v));
+        }
+    }
+}
+
+#if defined(BOOST_MSVC)
+#pragma warning(pop)
+#endif
+
+#endif