A random-access input wrapper for transforming dereferenced values.
More...
|
|
typedef TransformInputIterator | self_type |
| | My own type.
|
| |
|
typedef OffsetT | difference_type |
| | Type to express the result of subtracting one iterator from another.
|
| |
|
typedef ValueType | value_type |
| | The type of the element the iterator can point to.
|
| |
|
typedef ValueType * | pointer |
| | The type of a pointer to an element the iterator can point to.
|
| |
|
typedef ValueType | reference |
| | The type of a reference to an element the iterator can point to.
|
| |
|
typedef std::random_access_iterator_tag | iterator_category |
| | The iterator category.
|
| |
|
|
ConversionOp | conversion_op |
| |
|
InputIteratorT | input_itr |
| |
template<typename ValueType, typename ConversionOp, typename InputIteratorT, typename OffsetT = ptrdiff_t>
class cub::TransformInputIterator< ValueType, ConversionOp, InputIteratorT, OffsetT >
A random-access input wrapper for transforming dereferenced values.
- Overview
- TransformInputIteratorTwraps a unary conversion functor of type
ConversionOp and a random-access input iterator of type InputIteratorT, using the former to produce references of type ValueType from the latter.
- Can be used with any data type.
- Can be constructed, manipulated, and exchanged within and between host and device functions. Wrapped host memory can only be dereferenced on the host, and wrapped device memory can only be dereferenced on the device.
- Compatible with Thrust API v1.7 or newer.
- Snippet
- The code snippet below illustrates the use of
TransformInputIteratorTto dereference an array of integers, tripling the values and converting them to doubles.
#include <cub/cub.cuh>
struct TripleDoubler
{
__host__ __device__ __forceinline__
double operator()(const int &a) const {
return double(a * 3);
}
};
int *d_in;
TripleDoubler conversion_op;
printf("%f\n", itr[0]);
printf("%f\n", itr[1]);
printf("%f\n", itr[6]);
- Template Parameters
-
| ValueType | The value type of this iterator |
| ConversionOp | Unary functor type for mapping objects of type InputType to type ValueType. Must have member ValueType operator()(const InputType &datum). |
| InputIteratorT | The type of the wrapped input iterator |
| OffsetT | The difference type of this iterator (Default: ptrdiff_t) |
Definition at line 117 of file transform_input_iterator.cuh.
◆ TransformInputIterator()
template<typename ValueType , typename ConversionOp , typename InputIteratorT , typename OffsetT = ptrdiff_t>
Constructor.
- Parameters
-
| input_itr | Input iterator to wrap |
| conversion_op | Conversion functor to wrap |
Definition at line 148 of file transform_input_iterator.cuh.
The documentation for this class was generated from the following file: