]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/detail/is_contiguous_iterator.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / detail / is_contiguous_iterator.hpp
CommitLineData
7c673cae
FG
1//---------------------------------------------------------------------------//
2// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3//
4// Distributed under the Boost Software License, Version 1.0
5// See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt
7//
8// See http://boostorg.github.com/compute for more information.
9//---------------------------------------------------------------------------//
10
11#ifndef BOOST_COMPUTE_DETAIL_IS_CONTIGUOUS_ITERATOR_HPP
12#define BOOST_COMPUTE_DETAIL_IS_CONTIGUOUS_ITERATOR_HPP
13
14#include <vector>
15#include <valarray>
16
17#include <boost/config.hpp>
18#include <boost/type_traits.hpp>
19#include <boost/utility/enable_if.hpp>
20
21namespace boost {
22namespace compute {
23namespace detail {
24
25// default = false
26template<class Iterator, class Enable = void>
27struct _is_contiguous_iterator : public boost::false_type {};
28
29// std::vector<T>::iterator = true
30template<class Iterator>
31struct _is_contiguous_iterator<
32 Iterator,
33 typename boost::enable_if<
34 typename boost::is_same<
35 Iterator,
36 typename std::vector<typename Iterator::value_type>::iterator
37 >::type
38 >::type
39> : public boost::true_type {};
40
41// std::vector<T>::const_iterator = true
42template<class Iterator>
43struct _is_contiguous_iterator<
44 Iterator,
45 typename boost::enable_if<
46 typename boost::is_same<
47 Iterator,
48 typename std::vector<typename Iterator::value_type>::const_iterator
49 >::type
50 >::type
51> : public boost::true_type {};
52
53// std::valarray<T>::iterator = true
54template<class Iterator>
55struct _is_contiguous_iterator<
56 Iterator,
57 typename boost::enable_if<
58 typename boost::is_same<
59 Iterator,
60 typename std::valarray<typename Iterator::value_type>::iterator
61 >::type
62 >::type
63> : public boost::true_type {};
64
65// std::valarray<T>::const_iterator = true
66template<class Iterator>
67struct _is_contiguous_iterator<
68 Iterator,
69 typename boost::enable_if<
70 typename boost::is_same<
71 Iterator,
72 typename std::valarray<typename Iterator::value_type>::const_iterator
73 >::type
74 >::type
75> : public boost::true_type {};
76
77// T* = true
78template<class Iterator>
79struct _is_contiguous_iterator<
80 Iterator,
81 typename boost::enable_if<
82 boost::is_pointer<Iterator>
83 >::type
84> : public boost::true_type {};
85
86// the is_contiguous_iterator meta-function returns true if Iterator points
87// to a range of contiguous values. examples of contiguous iterators are
88// std::vector<>::iterator and float*. examples of non-contiguous iterators
89// are std::set<>::iterator and std::insert_iterator<>.
90//
91// the implementation consists of two phases. the first checks that value_type
92// for the iterator is not void. this must be done as for many containers void
93// is not a valid value_type (ex. std::vector<void>::iterator is not valid).
94// after ensuring a non-void value_type, the _is_contiguous_iterator function
95// is invoked. it has specializations retuning true for all (known) contiguous
96// iterators types and a default value of false.
97template<class Iterator, class Enable = void>
98struct is_contiguous_iterator :
99 public _is_contiguous_iterator<
100 typename boost::remove_cv<Iterator>::type
101 > {};
102
103// value_type of void = false
104template<class Iterator>
105struct is_contiguous_iterator<
106 Iterator,
107 typename boost::enable_if<
108 typename boost::is_void<
109 typename Iterator::value_type
110 >::type
111 >::type
112> : public boost::false_type {};
113
114} // end detail namespace
115} // end compute namespace
116} // end boost namespace
117
118#endif // BOOST_COMPUTE_DETAIL_IS_CONTIGUOUS_ITERATOR_HPP