Reject ranges that have themselves as their value_type (e.g. filesystem::path)

This commit is contained in:
Peter Dimov
2022-06-03 19:52:03 +03:00
parent 6781cff622
commit 866bd60dd3
3 changed files with 15 additions and 3 deletions
@@ -9,6 +9,8 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <iterator>
@@ -20,9 +22,11 @@ namespace hash_detail
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 40700)
template<class It> true_type is_range_check( It first, It last, typename std::iterator_traits<It>::difference_type* = 0 );
template<class T, class It> true_type is_range_check( It first, It last,
typename std::iterator_traits<It>::difference_type* = 0,
typename enable_if_< !is_same<typename remove_cv<T>::type, typename std::iterator_traits<It>::value_type>::value >::type* = 0 );
template<class T> decltype( is_range_check( declval<T const&>().begin(), declval<T const&>().end() ) ) is_range_( int );
template<class T> decltype( is_range_check<T>( declval<T const&>().begin(), declval<T const&>().end() ) ) is_range_( int );
template<class T> false_type is_range_( ... );
template<class T> struct is_range: decltype( is_range_<T>( 0 ) )