[英]how to define a C++ method outside the declaration for a variadic templated class specialized to no parameters?
I have a variadic templated class that I want to specialize to take no parameters and then I want to define methods outside the class declaration. 我有一个可变的模板类,我想专门没有参数,然后我想在类声明之外定义方法。
But the following gives 但以下给出
error: template-id ‘foobar<>’ for ‘foobar<>::foobar()’ does not
match any template declaration
What am I doing wrong? 我究竟做错了什么?
template <typename ...> class foobar;
template <>
class foobar <>
{
foobar();
};
//does not work!?
template <>
foobar<>::foobar() {};
The constructor isn't a template, since it's a non-template member of a full specialisation, so it doesn't need template
in its declaration: 构造函数不是模板,因为它是完全特化的非模板成员,因此它的声明中不需要template
:
// does work
foobar<>::foobar() {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.