简体   繁体   English

不允许使用多个模板参数列表

[英]multiple template parameter lists are not allowed

What is the issue here? 这是什么问题?

struct fbe {
    char *fbtName;
    template<typename T, typename... vT> 
    T(*funcptr)(T, vT... );
};

And what is the difference that made it compile when writing like this? 在这样写的时候编译的区别是什么?

template<typename T, typename... vT>
struct fbe {
    char *fbtName;
    T(*funcptr)(T, vT... );
};

I am very new to using template functions. 我是使用模板功能的新手。

The difference is that in the second case you can use the template parameters to create a set of different structs, all having a single function pointer member. 不同之处在于,在第二种情况下,您可以使用模板参数创建一组不同的结构,所有结构都具有单个函数指针成员。

In the first case, you would have a single struct type with an infinite number of function pointer members. 在第一种情况下,您将拥有一个具有无限数量的函数指针成员的结构类型。 You cannot have that, if nothing else because all objects of the same struct type must have the same size. 你不能拥有它,如果没有别的,因为同一结构类型的所有对象必须具有相同的大小。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM