For example I have a code as below with two parameter packs
template<class... Ts, int... Is>
struct B
{
};
int main()
{
B<int, double, 0, 1> b; // compile error here
return 0;
}
Any way to get is right?
That is not allowed. You can do this, however:
template<typename ...> struct typelist {};
template<typename TypeList, int... Is>
struct B; //primary template. Only declaration!
template<typename ... Ts, int ... Is>
struct B<typelist<Ts...>, Is...> //partial specialization
{
//here you know Ts... and Is... Use them!
};
int main()
{
B<typelist<int, double>, 0, 1> b;
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With