is_range.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2017 Peter Dimov.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // https://www.boost.org/LICENSE_1_0.txt
  4. #ifndef BOOST_HASH_IS_RANGE_HPP_INCLUDED
  5. #define BOOST_HASH_IS_RANGE_HPP_INCLUDED
  6. #include <iterator>
  7. #include <type_traits>
  8. namespace boost
  9. {
  10. namespace hash_detail
  11. {
  12. template<class T> struct iterator_traits: std::iterator_traits<T> {};
  13. template<> struct iterator_traits< void* > {};
  14. template<> struct iterator_traits< void const* > {};
  15. template<class T, class It>
  16. std::integral_constant< bool, !std::is_same<typename std::remove_cv<T>::type, typename iterator_traits<It>::value_type>::value >
  17. is_range_check( It first, It last );
  18. template<class T> decltype( is_range_check<T>( std::declval<T const&>().begin(), std::declval<T const&>().end() ) ) is_range_( int );
  19. template<class T> std::false_type is_range_( ... );
  20. } // namespace hash_detail
  21. namespace container_hash
  22. {
  23. template<class T> struct is_range: decltype( hash_detail::is_range_<T>( 0 ) )
  24. {
  25. };
  26. } // namespace container_hash
  27. } // namespace boost
  28. #endif // #ifndef BOOST_HASH_IS_RANGE_HPP_INCLUDED