Static Cast
- group NVCV_CPP_CUDATOOLS_STATICCAST
Functions
- template<typename T, typename U, class = Require<HasTypeTraits<T, U> && !IsCompound<T>>> __host__ __device__ auto StaticCast (U u)
Metafunction to static cast all values of a compound to a target type.
The template parameter
Tdefines the base type (regular C type) to cast all components of the CUDA compound typeUpassed as function argumentuto the typeT. The static cast return type has the base typeTand the number of components as the compound typeU. For instance, an uint3 can be casted to int3 by passing it as function argument of StaticCast and the type int as template argument (see example below). The typeUis not needed as it is inferred from the argument \u. It is a requirement of the StaticCast function that the typeTis of regular C type and the typeUis of CUDA compound type.int3 idx = StaticCast<int>(blockIdx * blockDim + threadIdx);
- Template Parameters:
T – Type to do static cast on each component of
u.- Parameters:
u – [in] Compound value to static cast each of its components to target type
T.- Returns:
The compound value with all components static casted to type
T.