user2191818 user2191818 - 1 month ago 5x
C++ Question

Define template class itself to a type

I am learning template knowledge and find some template usage like

template<typename T> struct myclass
typedef myclass type;

From my understanding, I can only use "myclass" with T specified. Like

myclass<int> member;

Now it defines "myclass" to "type" without specifing the T, so I would like to know in which case "type" will be used.

An example will be really appreciated.


Inside of the body of myclass<T>, the identifier myclass is a synonym for myclass<T>, so the line is equivalent to:

typedef myclass<T> type;