From 3ddcd6cfd07b77f0d11f5d52802cd4f78f50a542 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Mon, 4 Feb 2013 23:48:18 +0900 Subject: [PATCH] fix hash implementation --- sprout/array/hash.hpp | 2 +- sprout/bitset/bitset.hpp | 2 +- sprout/functional/hash/hash_value.hpp | 2 +- sprout/functional/hash/sscrisk/cel/array.hpp | 2 +- sprout/string/hash.hpp | 2 +- sprout/sub_array/hash.hpp | 2 +- sprout/tuple/tuple/hash.hpp | 34 +++++++++++--------- sprout/uuid/hash.hpp | 2 +- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/sprout/array/hash.hpp b/sprout/array/hash.hpp index 03bb3fd7..7eefce86 100644 --- a/sprout/array/hash.hpp +++ b/sprout/array/hash.hpp @@ -13,7 +13,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR std::size_t hash_value(sprout::array const& v) { - return sprout::hash_range(v.begin(), v.end()); + return sprout::hash_range(v); } } // namespace sprout diff --git a/sprout/bitset/bitset.hpp b/sprout/bitset/bitset.hpp index 3f17c38c..eb543dd2 100644 --- a/sprout/bitset/bitset.hpp +++ b/sprout/bitset/bitset.hpp @@ -437,7 +437,7 @@ namespace sprout { } SPROUT_CONSTEXPR std::size_t do_to_hash() const { - return sprout::hash_range(begin(), end()); + return sprout::hash_range(*this); } word_type& operator[](std::size_t i) { diff --git a/sprout/functional/hash/hash_value.hpp b/sprout/functional/hash/hash_value.hpp index 67d3efda..0a4ef211 100644 --- a/sprout/functional/hash/hash_value.hpp +++ b/sprout/functional/hash/hash_value.hpp @@ -136,7 +136,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR std::size_t hash_value(T const (&v)[N]) { - return sprout::hash_range(&v[0], &v[0] + N); + return sprout::hash_range(v); } } // namespace sprout diff --git a/sprout/functional/hash/sscrisk/cel/array.hpp b/sprout/functional/hash/sscrisk/cel/array.hpp index 98573dff..87f0fc5a 100644 --- a/sprout/functional/hash/sscrisk/cel/array.hpp +++ b/sprout/functional/hash/sscrisk/cel/array.hpp @@ -13,7 +13,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR std::size_t hash_value(sscrisk::cel::array const& v) { - return sprout::hash_range(v.begin(), v.end()); + return sprout::hash_range(v); } } // namespace sprout diff --git a/sprout/string/hash.hpp b/sprout/string/hash.hpp index 9c1eb753..2a5d9301 100644 --- a/sprout/string/hash.hpp +++ b/sprout/string/hash.hpp @@ -13,7 +13,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR std::size_t hash_value(sprout::basic_string const& v) { - return sprout::hash_range(v.begin(), v.end()); + return sprout::hash_range(v); } } // namespace sprout diff --git a/sprout/sub_array/hash.hpp b/sprout/sub_array/hash.hpp index 4cd656bf..056b3007 100644 --- a/sprout/sub_array/hash.hpp +++ b/sprout/sub_array/hash.hpp @@ -12,7 +12,7 @@ namespace sprout { template SPROUT_CONSTEXPR std::size_t hash_value(sprout::sub_array const& v) { - return sprout::hash_range(v.begin(), v.end()); + return sprout::hash_range(v); } } // namespace sprout diff --git a/sprout/tuple/tuple/hash.hpp b/sprout/tuple/tuple/hash.hpp index 39bb9bd2..14baf391 100644 --- a/sprout/tuple/tuple/hash.hpp +++ b/sprout/tuple/tuple/hash.hpp @@ -9,24 +9,26 @@ #include namespace sprout { - namespace detail { - template + namespace tuples { + namespace detail { + template + inline SPROUT_CONSTEXPR std::size_t + tuple_hash_value_impl(sprout::tuples::tuple const& v, sprout::index_tuple) { + return sprout::hash_values(sprout::tuples::get(v)...); + } + } // namespace detail + // + // hash_value + // + template inline SPROUT_CONSTEXPR std::size_t - tuple_hash_value_impl(sprout::tuples::tuple const& v, sprout::index_tuple) { - return sprout::hash_values(sprout::tuples::get(v)...); + hash_value(sprout::tuples::tuple const& v) { + return sprout::tuples::detail::tuple_hash_value_impl( + v, + sprout::index_range<0, sprout::tuples::tuple_size >::value>::make() + ); } - } // namespace detail - // - // hash_value - // - template - inline SPROUT_CONSTEXPR std::size_t - hash_value(sprout::tuples::tuple const& v) { - return sprout::detail::tuple_hash_value_impl( - v, - sprout::index_range<0, sprout::tuples::tuple_size >::value>::make() - ); - } + } // namespace tuples } // namespace sprout #endif // #ifndef SPROUT_TUPLE_TUPLE_HASH_HPP diff --git a/sprout/uuid/hash.hpp b/sprout/uuid/hash.hpp index b5332b35..f674df3a 100644 --- a/sprout/uuid/hash.hpp +++ b/sprout/uuid/hash.hpp @@ -12,7 +12,7 @@ namespace sprout { // inline SPROUT_CONSTEXPR std::size_t hash_value(sprout::uuids::uuid const& v) { - return sprout::hash_range(v.begin(), v.end()); + return sprout::hash_range(v); } } // namespace sprout