【发布时间】:2020-05-13 09:05:19
【问题描述】:
我想专门为可变参数创建一个类模板:
template <typename... Ts>
struct TypeList
{
};
template <typename T>
class Foo
{
};
//Is next "specialization" even possible?
template <typename... Ts>
class Foo<TypeList<Ts...>>
{
};
Foo<TypeList<int, int>> i1{}; // OK
Foo<int, int> i2{}; // NOK: error: wrong number of template arguments (2, should be 1)
我希望Foo 的用户可以在提供TypeList 或明确的类型列表之间进行选择。
【问题讨论】:
标签: c++ templates variadic-templates template-specialization