I'm looking to template a CUDA kernel. Neither Google, not SO were particularly forthcoming. Within this kernel, I would like to have a typedef that is dependent on the typename. I tried the following (assuming/hoping) it would work similarly to C++ but it didn't.
#include <type_traits> // for std::conditional. Not sure if it's necessary
#include <cuda_runtime.h>
#include <cuComplex.h>
template <typename fType>
__global__ void DummyKernel() {
typedef std::conditional<sizeof(fType) == sizeof(double), cuDoubleComplex, cuFloatComplex>::type cfType;
}
This produces the error
nontype "std::conditional<_Test, _Ty1, _Ty2>::type [with _Test=<expression>, _Ty1=cuDoubleComplex, _Ty2=cuFloatComplex]" is not a type name
Is there a way to do what I want? I'm using CUDA 5.5 and VS2012.