OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / thrust / iterator / detail / iterator_traits.inl
1 /*
2  *  Copyright 2008-2013 NVIDIA Corporation
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17
18 /*! \file iterator_traits.inl
19  *  \brief Inline file for iterator_traits.h.
20  */
21
22 #include <thrust/iterator/iterator_categories.h>
23 #include <thrust/iterator/detail/iterator_category_to_traversal.h>
24 #include <thrust/detail/type_traits.h>
25
26 namespace thrust
27 {
28
29 template<typename Iterator>
30   struct iterator_value
31 {
32   typedef typename thrust::iterator_traits<Iterator>::value_type type;
33 }; // end iterator_value
34
35
36 template<typename Iterator>
37   struct iterator_pointer
38 {
39   typedef typename thrust::iterator_traits<Iterator>::pointer type;
40 }; // end iterator_pointer
41
42
43 template<typename Iterator>
44   struct iterator_reference
45 {
46   typedef typename iterator_traits<Iterator>::reference type;
47 }; // end iterator_reference
48
49
50 template<typename Iterator>
51   struct iterator_difference
52 {
53   typedef typename thrust::iterator_traits<Iterator>::difference_type type;
54 }; // end iterator_difference
55
56
57 template<typename Iterator>
58   struct iterator_system
59     : detail::iterator_category_to_system<
60         typename thrust::iterator_traits<Iterator>::iterator_category
61       >
62 {
63 }; // end iterator_system
64
65 // specialize iterator_system for void *, which has no category
66 template<>
67   struct iterator_system<void *>
68 {
69   typedef thrust::iterator_system<int*>::type type;
70 }; // end iterator_system<void*>
71
72 template<>
73   struct iterator_system<const void *>
74 {
75   typedef thrust::iterator_system<const int*>::type type;
76 }; // end iterator_system<void*>
77
78
79 template <typename Iterator>
80   struct iterator_traversal
81     : detail::iterator_category_to_traversal<
82         typename thrust::iterator_traits<Iterator>::iterator_category
83       >
84 {
85 }; // end iterator_traversal
86
87 namespace detail
88 {
89
90 template <typename T>
91   struct is_iterator_traversal
92     : thrust::detail::is_convertible<T, incrementable_traversal_tag>
93 {
94 }; // end is_iterator_traversal
95
96
97 template<typename T>
98   struct is_iterator_system
99     : detail::or_<
100         detail::is_convertible<T, any_system_tag>,
101         detail::or_<
102           detail::is_convertible<T, host_system_tag>,
103           detail::is_convertible<T, device_system_tag>
104         >
105       >
106 {
107 }; // end is_iterator_system
108
109
110 } // end namespace detail
111 } // end namespace thrust
112