![](/img/trans.png)
[英]c++ member function template specialization on class non-type template parameter
[英]template class with Non-type template Parameter member function
我试图定义一个模板类的特化,其中包含一个非类型模板参数成员函数。 我收到以下错误:
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 }
我相信这更像是一个语法问题,而不是一个设计问题,任何线索? 谢谢
即使您完全专门化模板,您仍然需要template<>
:
template<> template<> void ClassA<int>::Execute<2>() { //Do stuff }
您忘了告诉编译器您正在专门化模板类的模板方法:
template <>
template <>
void ClassA<int>::Execute<2>()
{
//Do stuff
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.