Bolt  1.3
C++ template library with support for OpenCL
iterator_traits.h
Go to the documentation of this file.
1 /***************************************************************************
2 * © 2012,2014 Advanced Micro Devices, Inc. All rights reserved.
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 #pragma once
19 #if !defined( BOLT_CL_ITERATOR_TRAITS_H )
20 #define BOLT_CL_ITERATOR_TRAITS_H
21 
27 // #include <iterator>
28 
29 namespace bolt {
30 namespace cl {
31 
33  {
34  operator std::input_iterator_tag ( ) const
35  {
36  }
37  };
38 
40  {
41  operator std::output_iterator_tag ( ) const
42  {
43  }
44  };
45 
47  {
48  operator std::forward_iterator_tag ( ) const
49  {
50  }
51  };
52 
54  {
55  operator std::bidirectional_iterator_tag ( ) const
56  {
57  }
58  };
59 
61  {
62  operator std::random_access_iterator_tag ( ) const
63  {
64  }
65 
66  random_access_iterator_tag& operator=( const std::random_access_iterator_tag& )
67  {
68  return *this;
69  }
70  };
71 
72  struct fancy_iterator_tag: public std::random_access_iterator_tag
73  {
74  operator fancy_iterator_tag ( ) const
75  {
76  }
77  };
78 
79  template< typename iterator >
81  {
82  typedef typename iterator::iterator_category memory_system;
83  typedef typename iterator::iterator_category iterator_category;
84  typedef typename iterator::value_type value_type;
85  typedef typename iterator::difference_type difference_type;
86  typedef typename iterator::pointer pointer;
87  typedef typename iterator::reference reference;
88  };
89 
90  template< class T >
91  struct iterator_traits< T* >
92  {
93  typedef typename std::random_access_iterator_tag iterator_category;
94  typedef T value_type;
95  // difference_type set to int for OpenCL backend
96  typedef int difference_type;
97  typedef T* pointer;
98  typedef T& reference;
99  };
100 
101  template< class T >
102  struct iterator_traits< const T* >
103  {
104  typedef typename std::random_access_iterator_tag iterator_category;
105  typedef T value_type;
106  // difference_type set to int for OpenCL backend
107  typedef int difference_type;
108  typedef const T* pointer;
109  typedef const T& reference;
110  };
111 
112  template<typename Iterator>
114  {
115  typedef typename bolt::cl::iterator_traits<Iterator>::value_type type;
116  }; // end iterator_value
117 
118 
119  template<typename Iterator>
121  {
122  typedef typename bolt::cl::iterator_traits<Iterator>::pointer type;
123  }; // end iterator_pointer
124 
125 
126  template<typename Iterator>
128  {
129  typedef typename bolt::cl::iterator_traits<Iterator>::reference type;
130  }; // end iterator_reference
131 
132 
133  template<typename Iterator>
135  {
136  typedef typename bolt::cl::iterator_traits<Iterator>::difference_type type;
137  }; // end iterator_difference
138 
139 //This was causing a resolving sissue. For iterator traversal
140  template<typename Iterator>
142  {
143  typedef typename bolt::cl::iterator_traits<Iterator>::iterator_category type;
144  }; // end iterator_category
145 
146  template<typename Iterator>
148  {
149  typedef typename Iterator::memory_system type;
150  }; // end iterator_category
151 
168 
171 
172 }
173 };
174 
175 #endif