From 866bd60dd39583454ff8b798f7ae065d8088264f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 3 Jun 2022 19:52:03 +0300 Subject: [PATCH] Reject ranges that have themselves as their value_type (e.g. filesystem::path) --- include/boost/container_hash/detail/is_range.hpp | 8 ++++++-- test/Jamfile.v2 | 2 +- test/hash_fs_path_test.cpp | 8 ++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/boost/container_hash/detail/is_range.hpp b/include/boost/container_hash/detail/is_range.hpp index 41288e9..e880869 100644 --- a/include/boost/container_hash/detail/is_range.hpp +++ b/include/boost/container_hash/detail/is_range.hpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include #include @@ -20,9 +22,11 @@ namespace hash_detail #if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 40700) -template true_type is_range_check( It first, It last, typename std::iterator_traits::difference_type* = 0 ); +template true_type is_range_check( It first, It last, + typename std::iterator_traits::difference_type* = 0, + typename enable_if_< !is_same::type, typename std::iterator_traits::value_type>::value >::type* = 0 ); -template decltype( is_range_check( declval().begin(), declval().end() ) ) is_range_( int ); +template decltype( is_range_check( declval().begin(), declval().end() ) ) is_range_( int ); template false_type is_range_( ... ); template struct is_range: decltype( is_range_( 0 ) ) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c25099b..2e9d364 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -71,4 +71,4 @@ run hash_number_test2.cpp ; run hash_integral_test.cpp ; run hash_string_test2.cpp ; -run hash_fs_path_test.cpp ; +run hash_fs_path_test.cpp /boost//filesystem/off ; diff --git a/test/hash_fs_path_test.cpp b/test/hash_fs_path_test.cpp index 64e58fa..0cce00b 100644 --- a/test/hash_fs_path_test.cpp +++ b/test/hash_fs_path_test.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#if defined(_MSC_VER) +# pragma warning(disable: 4714) // forceinline not inlined +#endif + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wsign-conversion" +#endif + #include #include #include