3

Using MSVC++ 2010 (NVCC (CUDA) compiler), defining a nested templated class member of a non-templated parent class outside its declaration block:

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) {}

yields:

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)'

why?

Update: appears to be an NVCC bug. http://ideone.com/rc7R32 works, but not with NVCC. Anyone from Nvidia around to comment?

mchen
  • 9,808
  • 17
  • 72
  • 125

0 Answers0