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
T
defines the base type (regular C type) to cast all components of the CUDA compound typeU
passed as function argumentu
to the typeT
. The static cast return type has the base typeT
and 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 typeU
is not needed as it is inferred from the argument \u. It is a requirement of the StaticCast function that the typeT
is of regular C type and the typeU
is 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
.