Thrust
discard_iterator.h
Go to the documentation of this file.
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 
22 #pragma once
23 
24 #include <thrust/detail/config.h>
25 #include <thrust/iterator/detail/discard_iterator_base.h>
27 
28 THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
29 
30 THRUST_NAMESPACE_BEGIN
31 
92 template<typename System = use_default>
94  : public detail::discard_iterator_base<System>::type
95 {
98  friend class thrust::iterator_core_access;
99  typedef typename detail::discard_iterator_base<System>::type super_t;
100  typedef typename detail::discard_iterator_base<System>::incrementable incrementable;
101  typedef typename detail::discard_iterator_base<System>::base_iterator base_iterator;
102 
103  public:
104  typedef typename super_t::reference reference;
105  typedef typename super_t::value_type value_type;
106 
114  __host__ __device__
116  : super_t(rhs.base()) {}
117 
118 #if THRUST_CPP_DIALECT >= 2011
119  discard_iterator & operator=(const discard_iterator &) = default;
120 #endif
121 
129  __host__ __device__
130  discard_iterator(incrementable const &i = incrementable())
131  : super_t(base_iterator(i)) {}
132 
136  private: // Core iterator interface
137  __host__ __device__
138  reference dereference() const
139  {
140  return m_element;
141  }
142 
143  mutable value_type m_element;
144 
147 }; // end constant_iterator
148 
149 
159 inline __host__ __device__
161 {
162  return discard_iterator<>(i);
163 } // end make_discard_iterator()
164 
171 THRUST_NAMESPACE_END
172 
173 THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
174 
Definition: discard_iterator.h:93
thrust::reference< T, thrust::system::cpp::tag > reference
Definition: pointer.h:98
Definition: iterator_facade.h:60
__host__ __device__ discard_iterator make_discard_iterator(discard_iterator<>::difference_type i=discard_iterator<>::difference_type(0))
Definition: discard_iterator.h:160
A class which exposes a public interface for iterators.