Bolt  1.1
C++ template library with support for OpenCL
iterator_traits.h
Go to the documentation of this file.
1 /***************************************************************************
2 * Copyright 2012 - 2013 Advanced Micro Devices, Inc.
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_AMP_ITERATOR_TRAITS_H )
20 #define BOLT_AMP_ITERATOR_TRAITS_H
21 
28 namespace bolt {
29 namespace amp {
30 
31  template< typename iterator >
33  {
34  typedef typename iterator::iterator_category iterator_category;
35  typedef typename iterator::value_type value_type;
36  typedef typename iterator::difference_type difference_type;
37  typedef typename iterator::pointer pointer;
38  typedef typename iterator::reference reference;
39  };
40 
41  template< class T >
42  struct iterator_traits< T* >
43  {
44  typedef typename std::random_access_iterator_tag iterator_category;
45  typedef T value_type;
46  // difference_type set to int for OpenCL backend
47  typedef int difference_type;
48  typedef T* pointer;
49  typedef T& reference;
50  };
51 
52  template< class T >
53  struct iterator_traits< const T* >
54  {
55  typedef typename std::random_access_iterator_tag iterator_category;
56  typedef T value_type;
57  typedef int difference_type;
58  typedef const T* pointer;
59  typedef const T& reference;
60  };
61 
62 }
63 };
64 
65 #endif