From 9348a89fb4165d6f6341224b9427916281312d89 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 17 Oct 2021 00:09:20 +0300 Subject: [PATCH] Fix msvc-14.1 errors caused by their unconstrained stdext::hash_value overload (!) --- include/boost/container_hash/hash.hpp | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/boost/container_hash/hash.hpp b/include/boost/container_hash/hash.hpp index c1ea3ff..159b0af 100644 --- a/include/boost/container_hash/hash.hpp +++ b/include/boost/container_hash/hash.hpp @@ -179,6 +179,44 @@ namespace boost return boost::hash_unordered_range( v.begin(), v.end() ); } +#if defined(BOOST_MSVC) && BOOST_MSVC >= 1910 && BOOST_MSVC < 1920 && BOOST_CXX_VERSION >= 201700L + + // resolve ambiguity with unconstrained stdext::hash_value in :-/ + + template class L, class... T> + typename boost::enable_if_c>::value && !hash_detail::is_contiguous_range>::value && !hash_detail::is_unordered_range>::value, std::size_t>::type + hash_value( L const& v ) + { + return boost::hash_range( v.begin(), v.end() ); + } + + // contiguous ranges (string, vector, array) + + template class L, class... T> + typename boost::enable_if>, std::size_t>::type + hash_value( L const& v ) + { + return boost::hash_range( v.data(), v.data() + v.size() ); + } + + template class L, class T, std::size_t N> + typename boost::enable_if>, std::size_t>::type + hash_value( L const& v ) + { + return boost::hash_range( v.data(), v.data() + v.size() ); + } + + // unordered ranges (unordered_set, unordered_map) + + template class L, class... T> + typename boost::enable_if>, std::size_t>::type + hash_value( L const& v ) + { + return boost::hash_unordered_range( v.begin(), v.end() ); + } + +#endif + // std::type_index #if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX)