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

View file

@ -437,7 +437,7 @@ namespace sprout {
} }
SPROUT_CONSTEXPR std::size_t do_to_hash() const { 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) { word_type& operator[](std::size_t i) {

View file

@ -136,7 +136,7 @@ namespace sprout {
template<typename T, std::size_t N> template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR std::size_t inline SPROUT_CONSTEXPR std::size_t
hash_value(T const (&v)[N]) { hash_value(T const (&v)[N]) {
return sprout::hash_range(&v[0], &v[0] + N); return sprout::hash_range(v);
} }
} // namespace sprout } // namespace sprout

View file

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

View file

@ -13,7 +13,7 @@ namespace sprout {
template<typename T, std::size_t N, typename Traits> template<typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR std::size_t inline SPROUT_CONSTEXPR std::size_t
hash_value(sprout::basic_string<T, N, Traits> const& v) { 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 } // namespace sprout

View file

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

View file

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

View file

@ -12,7 +12,7 @@ namespace sprout {
// //
inline SPROUT_CONSTEXPR std::size_t inline SPROUT_CONSTEXPR std::size_t
hash_value(sprout::uuids::uuid const& v) { hash_value(sprout::uuids::uuid const& v) {
return sprout::hash_range(v.begin(), v.end()); return sprout::hash_range(v);
} }
} // namespace sprout } // namespace sprout