![](/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.