From 83a874ed49f55336a95d8e264d36eee431cd949a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 13 Apr 2018 09:31:18 +0100 Subject: [PATCH] More general purpose support for iterators with odd reference type (trac #13501) In the last release I added explicit support for `vector` which wasn't working with libc++ because the iterator's `operator*` returned a proxy reference type. Other implementations return a `bool` for const iterators, so they happened to work okay. This solves the problem in a more general purpose way by instantiating `hash_combine` for the iterator `value_type`. So the type returned by `operator*` will be implicitly casted to the correct type. --- include/boost/container_hash/extensions.hpp | 51 --------------------- include/boost/container_hash/hash.hpp | 5 +- 2 files changed, 3 insertions(+), 53 deletions(-) diff --git a/include/boost/container_hash/extensions.hpp b/include/boost/container_hash/extensions.hpp index 4eebb4b..393b702 100644 --- a/include/boost/container_hash/extensions.hpp +++ b/include/boost/container_hash/extensions.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #if !defined(BOOST_NO_CXX11_HDR_ARRAY) # include @@ -71,56 +70,6 @@ namespace boost return seed; } - inline std::size_t hash_range( - std::vector::iterator first, - std::vector::iterator last) - { - std::size_t seed = 0; - - for(; first != last; ++first) - { - hash_combine(seed, *first); - } - - return seed; - } - - inline std::size_t hash_range( - std::vector::const_iterator first, - std::vector::const_iterator last) - { - std::size_t seed = 0; - - for(; first != last; ++first) - { - hash_combine(seed, *first); - } - - return seed; - } - - inline void hash_range( - std::size_t& seed, - std::vector::iterator first, - std::vector::iterator last) - { - for(; first != last; ++first) - { - hash_combine(seed, *first); - } - } - - inline void hash_range( - std::size_t& seed, - std::vector::const_iterator first, - std::vector::const_iterator last) - { - for(; first != last; ++first) - { - hash_combine(seed, *first); - } - } - template std::size_t hash_value(std::vector const& v) { diff --git a/include/boost/container_hash/hash.hpp b/include/boost/container_hash/hash.hpp index 76de793..fd814a2 100644 --- a/include/boost/container_hash/hash.hpp +++ b/include/boost/container_hash/hash.hpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -426,7 +427,7 @@ namespace boost for(; first != last; ++first) { - hash_combine(seed, *first); + hash_combine::value_type>(seed, *first); } return seed; @@ -437,7 +438,7 @@ namespace boost { for(; first != last; ++first) { - hash_combine(seed, *first); + hash_combine::value_type>(seed, *first); } }