lundi 24 septembre 2018

What is template<> template

Sometimes I see class specialization code like this:

template <>
template < typename T >
class Foo : Foo2<T>
{
...
}

For classes like this:

template < typename T > class Foo

template < typename T > class Foo2

I know what this code means, but my question is: what is the use of “template <>” in the class specialization given that the same thing can be done without it:

template <typename T> Foo : Foo2<T> {}

Is there any case, not limited to class specialization, where this syntax is necessary? (template followed by another template, not template template parameters)

Aucun commentaire:

Enregistrer un commentaire