![](/img/trans.png)
[英]Explicit specialization - template-id does not match any template declaration
[英]Explicitly instantiating variadic constructor: template-id does not match any template declaration
我正在尝试显式实例化可变参数构造函数。 这个打印所有参数的最小示例会导致我在使用GCC 5.3的64位Win 7上的MinGW-w64上看到相同的错误。
struct stf {
template<typename... Args> stf(Args&&... args){
using expand_type = int[];
expand_type{(print(args), 0)... };
}
};
//error on next line:
//template-id 'stf<char*, char*>' for 'stf::stf(char*, char*)'
//does not match any template declaration
template stf::stf<char*,char*>(char*,char*);
让我们暂时忽略参数包:
template<typename Arg> stf(Arg &&args)
弹出测验:与上面的模板匹配的实例。 是吗:
template<char *> stf(char *);
要么
template<char *> stf(char *&&);
?
如果在模板类型出现在模板的任何地方都用char *
代替,显然您会得到第二个版本作为正确答案。
因此,正确的模板实例化必须是:
template stf::stf<char*,char*>(char* &&,char* &&);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.