带有非类型模板的模板类参数成员函数

blu*_*kin 3 c++ templates template-specialization

我试图定义一个模板类的特化,其中包含一个非类型模板参数成员函数.我收到以下错误:

error: too few template-parameter-lists

Here's a sample class that describes the problem in brief,
// file.h
template <typename T>
class ClassA {
  T Setup();
  template <int K> static void Execute();
};

//file.cc
void ClassA<int>::Execute<2>() { //Do stuff    }
Run Code Online (Sandbox Code Playgroud)

我相信这更像是一个语法问题,而不是一个设计问题,任何线索?谢谢

Dar*_*con 5

即使您完全专门化模板,您仍然需要template<>:

template<> template<> void ClassA<int>::Execute<2>() { //Do stuff    }
Run Code Online (Sandbox Code Playgroud)