dimanche 2 août 2015

How to correctly read the template partial specialization?

Suppose the following declaration:

template <typename T> struct MyTemplate;

The following definition of the partial specialization seems to use the same letter T to refer to different types.

template <typename T> struct MyTemplate<T*> {};

For example, let's take a concrete instantiation:

MyTemplate<int *> c;

Now, T in template <typename T> is int *. However, T in MyTemplate<T*> is int!

How is the definition of the partial specialization read correctly?

Aucun commentaire:

Enregistrer un commentaire