fix hash implementation

This commit is contained in:
bolero-MURAKAMI 2013-02-04 23:48:18 +09:00
parent c72ab5c6c1
commit 3ddcd6cfd0
8 changed files with 25 additions and 23 deletions

View file

@ -13,7 +13,7 @@ namespace sprout {
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR std::size_t
hash_value(sprout::array<T, N> const& v) {
return sprout::hash_range(v.begin(), v.end());
return sprout::hash_range(v);
}
} // namespace sprout

View file

@ -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) {

View file

@ -136,7 +136,7 @@ namespace sprout {
template<typename T, std::size_t N>
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

View file

@ -13,7 +13,7 @@ namespace sprout {
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR std::size_t
hash_value(sscrisk::cel::array<T, N> const& v) {
return sprout::hash_range(v.begin(), v.end());
return sprout::hash_range(v);
}
} // namespace sprout

View file

@ -13,7 +13,7 @@ namespace sprout {
template<typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR std::size_t
hash_value(sprout::basic_string<T, N, Traits> const& v) {
return sprout::hash_range(v.begin(), v.end());
return sprout::hash_range(v);
}
} // namespace sprout

View file

@ -12,7 +12,7 @@ namespace sprout {
template<typename Container>
SPROUT_CONSTEXPR std::size_t
hash_value(sprout::sub_array<Container> const& v) {
return sprout::hash_range(v.begin(), v.end());
return sprout::hash_range(v);
}
} // namespace sprout

View file

@ -9,24 +9,26 @@
#include <sprout/tuple/tuple/get.hpp>
namespace sprout {
namespace detail {
template<typename... Types, sprout::index_t... Indexes>
namespace tuples {
namespace detail {
template<typename... Types, sprout::index_t... Indexes>
inline SPROUT_CONSTEXPR std::size_t
tuple_hash_value_impl(sprout::tuples::tuple<Types...> const& v, sprout::index_tuple<Indexes...>) {
return sprout::hash_values(sprout::tuples::get<Indexes>(v)...);
}
} // namespace detail
//
// hash_value
//
template<typename... Types>
inline SPROUT_CONSTEXPR std::size_t
tuple_hash_value_impl(sprout::tuples::tuple<Types...> const& v, sprout::index_tuple<Indexes...>) {
return sprout::hash_values(sprout::tuples::get<Indexes>(v)...);
hash_value(sprout::tuples::tuple<Types...> const& v) {
return sprout::tuples::detail::tuple_hash_value_impl(
v,
sprout::index_range<0, sprout::tuples::tuple_size<sprout::tuples::tuple<Types...> >::value>::make()
);
}
} // namespace detail
//
// hash_value
//
template<typename... Types>
inline SPROUT_CONSTEXPR std::size_t
hash_value(sprout::tuples::tuple<Types...> const& v) {
return sprout::detail::tuple_hash_value_impl(
v,
sprout::index_range<0, sprout::tuples::tuple_size<sprout::tuples::tuple<Types...> >::value>::make()
);
}
} // namespace tuples
} // namespace sprout
#endif // #ifndef SPROUT_TUPLE_TUPLE_HASH_HPP

View file

@ -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