aboutsummaryrefslogtreecommitdiff
path: root/cutl/details/boost/functional/hash/detail/hash_float_x86.hpp
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-06-28 17:17:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-06-28 17:17:23 +0200
commitb51965dddbed68f23c5e8c169c23c794313ce5f6 (patch)
tree37bbdf4e5b1cdd34ea0694a5abd1483d1de2b3af /cutl/details/boost/functional/hash/detail/hash_float_x86.hpp
parent5f06e7e30e4f511ce2fb27c5feefa6aeb6f00841 (diff)
Add boost subset as an implementation detail
Diffstat (limited to 'cutl/details/boost/functional/hash/detail/hash_float_x86.hpp')
-rw-r--r--cutl/details/boost/functional/hash/detail/hash_float_x86.hpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/cutl/details/boost/functional/hash/detail/hash_float_x86.hpp b/cutl/details/boost/functional/hash/detail/hash_float_x86.hpp
new file mode 100644
index 0000000..6a70556
--- /dev/null
+++ b/cutl/details/boost/functional/hash/detail/hash_float_x86.hpp
@@ -0,0 +1,56 @@
+
+// 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 non-portable hash function form non-zero floats on x86.
+//
+// Even if you're on an x86 platform, this might not work if their floating
+// point isn't set up as this expects. So this should only be used if it's
+// absolutely certain that it will work.
+
+#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_X86_HEADER)
+#define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_X86_HEADER
+
+#include <cutl/details/boost/cstdint.hpp>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+namespace cutl_details_boost
+{
+ namespace hash_detail
+ {
+ inline void hash_float_combine(std::size_t& seed, std::size_t value)
+ {
+ seed ^= value + (seed<<6) + (seed>>2);
+ }
+
+ inline std::size_t float_hash_impl(float v)
+ {
+ cutl_details_boost::uint32_t* ptr = (cutl_details_boost::uint32_t*)&v;
+ std::size_t seed = *ptr;
+ return seed;
+ }
+
+ inline std::size_t float_hash_impl(double v)
+ {
+ cutl_details_boost::uint32_t* ptr = (cutl_details_boost::uint32_t*)&v;
+ std::size_t seed = *ptr++;
+ hash_float_combine(seed, *ptr);
+ return seed;
+ }
+
+ inline std::size_t float_hash_impl(long double v)
+ {
+ cutl_details_boost::uint32_t* ptr = (cutl_details_boost::uint32_t*)&v;
+ std::size_t seed = *ptr++;
+ hash_float_combine(seed, *ptr++);
+ hash_float_combine(seed, *(cutl_details_boost::uint16_t*)ptr);
+ return seed;
+ }
+ }
+}
+
+#endif