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.