Reputation: 18168
I have this code:
template<char ...T>
class base
{
std::array<uint8_t, ID_SIZE> m_ID = { Ts... };
}
template<char ...T>
class derived: public base<T>
{
// this class doesn;t need to know anything about T
}
when I compile this code, I am getting this error:
'T': parameter pack must be expanded in this context
What is this error and how i can fix it?
Upvotes: 3
Views: 65
Reputation: 7591
Multiple template parameters (type or non-type) cannot be passed as packs but have to be unpacked each time:
template<char ...T>
class base { }
template<char ...T>
class derived: public base<T...> // unpack
{
}
Inside of base<>
the parameters will then be re-packed in the context of T.
Upvotes: 2
Reputation: 249163
T
is not one type, it is the name of a "parameter pack."
base<T>
is nonsensical, because base
requires a list of types, not a pack of types. base<T...>
will unpack the types and work as you expect.
Upvotes: 2