简体   繁体   English

为什么我收到错误“参数包'F'必须位于模板参数列表的末尾”

[英]Why am I getting the error “parameter pack 'F' must be at the end of the template parameter list”

I have code that uses a variadic template and I'm trying to understand where to put the ellipsis. 我有使用可变参数模板的代码,我试图了解省略号的放置位置。 In the below code I put them, like the error says, at the end of the template parameter list. 在下面的代码中,我把它们放在模板参数列表的末尾 ,就像错误所说的那样。 But I still get errors. 但我仍然会遇到错误。 What am I doing wrong? 我究竟做错了什么?

template <typename T> struct S {

    void operator << (const T &) {}

};

template <template <typename, typename...> class ... F, typename T = int>
struct N : S<F<T>> ... {};

prog.cpp:10:82: error: parameter pack 'F' must be at the end of the template parameter list

You have another parameter, T , at the end of the list after F . F之后的列表末尾有另一个参数T As the error message says, the variadic pack must come at the end. 正如错误消息所示,可变参数包必须在最后。 Unfortunately, that makes it awkward to have both variadic and defaulted parameters in the same template. 不幸的是,这使得在同一模板中同时具有可变参数和默认参数变得尴尬。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 参数包必须位于参数列表的末尾...何时以及为何? - Parameter pack must be at the end of the parameter list… When and why? 功能模板参数包不在参数列表的末尾 - Function template parameter pack not at the end of the parameter list 为什么模板参数包必须放在最后? - Why must the template parameter pack be last? variadiac模板出错:“参数包必须扩展” - Error with variadiac template: “parameter pack must be expanded” 实例化模板时是否必须显式显示参数包中的类型? - Must I explicitly show the types in the parameter pack when instantiate a template? 在O(1)中访问模板参数包的背面 - Getting access to the back of a template parameter pack in O(1) 不知道为什么我收到关于std :: size_t不包含参数包的编译错误 - Not sure why I'm getting compilation error about std::size_t not containing a parameter pack c ++:为什么在给出模板函数的所有类型参数时出现错误,但是在省略参数时可以? - c++: why am I getting an error when giving all type parameters of a template function, but OK when omitting a parameter? 为什么即使我在运行时实例化模板参数,但我得到预期的 output 而不是错误,即。 我们不能在运行时扩展模板? - Why even i am instantiating template parameter at runtime but i am getting expected output instead of error ie. we cannot expand template at runtime? 为什么我收到错误“非模板&#39;f&#39;用作模板” - Why am I getting the error “non-template 'f' used as template”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM