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