Drop Cast

group NVCV_CPP_CUDATOOLS_DROPCAST

Functions

template<int N, typename T, class = Require<HasEnoughComponents<T, N>>> __host__ __device__ auto DropCast (T v)

Metafunction to drop components of a compound value.

The template parameter N defines the number of components to cast the CUDA compound type T passed as function argument v. This is done by dropping the last components after N from v. For instance, an uint3 can have its z component dropped by passing it as function argument to DropCast and the number 2 as template argument (see example below). The type T is not needed as it is inferred from the argument v. It is a requirement of the DropCast function that the type T has at least N components.

uint2 dstIdx = DropCast<2>(blockIdx * blockDim + threadIdx);
Template Parameters:

N – Number of components to return.

Parameters:

v[in] Value to drop components from.

Returns:

The compound value with N components dropping the last, extra components.