| 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 | |
| 5 | #ifndef BOOST_HASH_IS_RANGE_HPP_INCLUDED |
| 6 | #define BOOST_HASH_IS_RANGE_HPP_INCLUDED |
| 7 | |
| 8 | #include <iterator> |
| 9 | #include <type_traits> |
| 10 | |
| 11 | namespace boost |
| 12 | { |
| 13 | |
| 14 | namespace hash_detail |
| 15 | { |
| 16 | |
| 17 | template<class T> struct iterator_traits: std::iterator_traits<T> {}; |
| 18 | template<> struct iterator_traits< void* > {}; |
| 19 | template<> struct iterator_traits< void const* > {}; |
| 20 | |
| 21 | template<class T, class It> |
| 22 | std::integral_constant< bool, !std::is_same<typename std::remove_cv<T>::type, typename iterator_traits<It>::value_type>::value > |
| 23 | is_range_check( It first, It last ); |
| 24 | |
| 25 | template<class T> decltype( is_range_check<T>( std::declval<T const&>().begin(), std::declval<T const&>().end() ) ) is_range_( int ); |
| 26 | template<class T> std::false_type is_range_( ... ); |
| 27 | |
| 28 | } // namespace hash_detail |
| 29 | |
| 30 | namespace container_hash |
| 31 | { |
| 32 | |
| 33 | template<class T> struct is_range: decltype( hash_detail::is_range_<T>( 0 ) ) |
| 34 | { |
| 35 | }; |
| 36 | |
| 37 | } // namespace container_hash |
| 38 | |
| 39 | } // namespace boost |
| 40 | |
| 41 | #endif // #ifndef BOOST_HASH_IS_RANGE_HPP_INCLUDED |
| 42 | |