About template class grammar

74 Views Asked by At

I want to ask something about the template class. I know the basics like:

template<typename X, typename Y>
class tmp{
...
}

However, in the starter file of my programming assignment, I saw a new format as:

template<typename X, typename... Y>
class tmp<std::tuple<Y...>,X>{
...
}

Here, I know "..." is the parameter pack, but why there is another "< >" after the name of the class??

1

There are 1 best solutions below

0
On

This :

template<typename X, typename... Y>
class tmp<std::tuple<Y...>,X>{
...
}

is a notation to say:

We have a template with parameter X and a parameter pack Y. The class tmp is a template class that use the parameter pack Y in a tuple variable, and X as a simple template variable.

However this is a specialization of the template.