1// Copyright 2017, 2018 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_CONTIGUOUS_RANGE_HPP_INCLUDED
6#define BOOST_HASH_IS_CONTIGUOUS_RANGE_HPP_INCLUDED
7
8#include <boost/container_hash/detail/requires_cxx11.hpp>
9#include <boost/container_hash/is_range.hpp>
10#include <boost/type_traits/integral_constant.hpp>
11#include <boost/config.hpp>
12#include <boost/config/workaround.hpp>
13
14#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 40700) && !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
15
16#include <boost/type_traits/is_integral.hpp>
17#include <boost/type_traits/declval.hpp>
18#include <boost/type_traits/is_same.hpp>
19#include <iterator>
20
21namespace boost
22{
23namespace hash_detail
24{
25
26template<class It, class T, class S>
27 integral_constant< bool, is_same<typename std::iterator_traits<It>::value_type, T>::value && is_integral<S>::value >
28 is_contiguous_range_check( It first, It last, T const*, T const*, S );
29
30template<class T> decltype( is_contiguous_range_check( declval<T const&>().begin(), declval<T const&>().end(), declval<T const&>().data(), declval<T const&>().data() + declval<T const&>().size(), declval<T const&>().size() ) ) is_contiguous_range_( int );
31template<class T> false_type is_contiguous_range_( ... );
32
33template<class T> struct is_contiguous_range: decltype( hash_detail::is_contiguous_range_<T>( 0 ) )
34{
35};
36
37} // namespace hash_detail
38
39namespace container_hash
40{
41
42template<class T> struct is_contiguous_range: integral_constant< bool, is_range<T>::value && hash_detail::is_contiguous_range<T>::value >
43{
44};
45
46} // namespace container_hash
47} // namespace boost
48
49#else // !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
50
51#include <cstddef>
52#include <vector>
53#include <string>
54#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
55#include <array>
56#endif
57
58namespace boost
59{
60namespace container_hash
61{
62
63template<class T> struct is_contiguous_range: false_type
64{
65};
66
67template<class E, class T, class A> struct is_contiguous_range< std::basic_string<E, T, A> >: true_type
68{
69};
70
71template<class E, class T, class A> struct is_contiguous_range< std::basic_string<E, T, A> const >: true_type
72{
73};
74
75#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
76
77template<class T, std::size_t N> struct is_contiguous_range< std::array<T, N> >: true_type
78{
79};
80
81template<class T, std::size_t N> struct is_contiguous_range< std::array<T, N> const >: true_type
82{
83};
84
85#endif
86
87} // namespace container_hash
88} // namespace boost
89
90#endif // !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
91
92#endif // #ifndef BOOST_HASH_IS_CONTIGUOUS_RANGE_HPP_INCLUDED
93