Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何将模板参数包扩展到一系列模板参数?_C++_Templates_C++17 - Fatal编程技术网

C++ 如何将模板参数包扩展到一系列模板参数?

C++ 如何将模板参数包扩展到一系列模板参数?,c++,templates,c++17,C++,Templates,C++17,我有一个简单的模板类: template<typename T> class property { // ... }; template<typename... factory_args> class type_t { // … 理想情况下,模板参数推断也会起作用,因此我也可以这样称呼它: auto some_other_type = type_t(first, second); 如何编写类型\u t构造函数?这在C++17中可行吗?类似这样: te

我有一个简单的模板类:

template<typename T>
class property
{
    // ...
};
template<typename... factory_args>
class type_t
{
    // …
理想情况下,模板参数推断也会起作用,因此我也可以这样称呼它:

auto some_other_type = type_t(first, second);
如何编写
类型\u t
构造函数?这在C++17中可行吗?

类似这样:

template<typename... factory_args>
class type_t
{
public:
    type_t(property<factory_args>&... args);
};
模板
类类型
{
公众:
类型(属性和参数);
};
类模板参数推断在这里也做了正确的事情。如果你有:

property<int> i;
property<void*> v;
type_t x(i, v); // ok, x is a type_t<int, void*>
属性i;
财产v;
类型_t x(i,v);//好的,x是一种类型
类型(属性和参数)
?还是需要多个命名参数?
template<typename... factory_args>
class type_t
{
public:
    type_t(property<factory_args>&... args);
};
property<int> i;
property<void*> v;
type_t x(i, v); // ok, x is a type_t<int, void*>