Reputation: 3743
I want to specialize a class template for variadic parameters:
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)
I want that users of Foo
can choose between providing a TypeList
or an explicit list of types.
Upvotes: 0
Views: 46
Reputation: 218278
What you can do, to allow both syntaxs:
template <typename ... Ts>
class Foo : Foo<TypeList<Ts...>>
{
};
// Specialization
template <typename ... Ts>
class Foo<TypeList<Ts...>>
{
// ...
};
Upvotes: 2