使用 MSVC++ 2010(NVCC (CUDA) 编译器),在其声明块之外定义非模板父类的嵌套模板类成员:
class cls {
public:
template <typename V> class nest {
public:
template <typename W> void bar(W x);
};
};
template <typename V>
template <typename W>
void cls::nest<V>::bar(W x) {}
产量:
error C2244: 'bar' : unable to match function definition to an existing declaration
1> definition
1> 'void cls::nest<V>::bar(W)'
1> existing declarations
1> 'void cls::nest<V>::bar(W)'
为什么?
更新:似乎是 NVCC 错误。http://ideone.com/rc7R32有效,但不适用于 NVCC。Nvidia周围的任何人都可以发表评论吗?