OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / thrust / iterator / detail / normal_iterator.h
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 normal_iterator.h
19  *  \brief Defines the interface to an iterator class
20  *         which adapts a pointer type.
21  */
22
23 #pragma once
24
25 #include <thrust/iterator/iterator_adaptor.h>
26 #include <thrust/iterator/detail/is_trivial_iterator.h>
27 #include <thrust/detail/type_traits.h>
28
29 namespace thrust
30 {
31 namespace detail
32 {
33
34
35 template<typename Pointer>
36   class normal_iterator
37     : public iterator_adaptor<
38         normal_iterator<Pointer>,
39         Pointer
40       >
41 {
42   typedef iterator_adaptor<normal_iterator<Pointer>, Pointer> super_t;
43
44   public:
45     __host__ __device__
46     normal_iterator() {}
47
48     __host__ __device__
49     normal_iterator(Pointer p)
50       : super_t(p) {}
51     
52     template<typename OtherPointer>
53     __host__ __device__
54     normal_iterator(const normal_iterator<OtherPointer> &other,
55                     typename thrust::detail::enable_if_convertible<
56                       OtherPointer,
57                       Pointer
58                     >::type * = 0)
59       : super_t(other.base()) {}
60
61 }; // end normal_iterator
62
63
64 template<typename Pointer>
65   inline __host__ __device__ normal_iterator<Pointer> make_normal_iterator(Pointer ptr)
66 {
67   return normal_iterator<Pointer>(ptr);
68 }
69
70
71 template<typename T> struct is_trivial_iterator< normal_iterator<T> > : public true_type {};
72
73
74 } // end detail
75 } // end thrust
76