コンパイラがここで文句を言うのはなぜですか?
enum jit_ptx_type {f32=0,f64=1,u16=2,u32=3,u64=4,s16=5,s32=6,s64=7,u8=8,b16=9,b32=10,b64=11,pred=12 };
//
// MATCHING C TYPES TO PTX TYPES
//
template<class T> struct jit_type {};
template<> struct jit_type<float> { enum { value = jit_ptx_type::f32 }; };
template<> struct jit_type<double> { enum { value = jit_ptx_type::f64 }; };
template<> struct jit_type<int> { enum { value = jit_ptx_type::s32 }; };
template<> struct jit_type<bool> { enum { value = jit_ptx_type::pred }; };
コードの後半:
some_func( float val ) {
jit_ptx_type type = jit_type<float>::value; // compiler complains here
}
コンパイラ メッセージ:
error: cannot convert ‘jit_type<float>::<anonymous enum>’ to ‘jit_ptx_type’ in assignment
それは奇妙です!これらの行を別の小さなサンプル ファイルに入れると、機能します。