I think it will be very difficult for you to find a clearer expression of what the cited paragraphs say. I think they explain the problem very well.
If you still need help understanding this idea, first try to understand three key words: pattern , parameter, and argument . Here is my definition:
The template parameter is part of the template definition, while the template argument is what is passed to the template to create the template to generate a particular type.
A template is a function that can be parameterized. In your example, Dozen is a template:
template <typename T> class Dozen { ... };
where T is the Dozen parameter. Soon T is a template parameter.
Perhaps a simple analogy will help. Think of a pattern (here it is a Dozen ) as a molding of a sculpture that can be filled with liquid material, which will be installed inside the molded, taking its shape and eventually producing the sculpture. Now the parameter T is similar to a liquid material (rubber, metal, glass, etc.), which will give the character a sculpture. So you can use the same actor to make a series of similar sculptures.
Thus, the hollow cavity in the listing is a parameter T , a placeholder where you put the template arguments, where you fill the template.
So, this is roughly the idea of parameterization in metaprogramming.
Moving to template argument and example with comments:
// T states parameter of Dozen template template <typename T> class Dozen { // the T is argument used to instantiate concrete type from another template ArrayInClass<T,12> contents; };
Here you can recall the function calling another function and the forwarding parameter:
void foo(int a) { bar(a); }
foo does not use itself, but passes it as an argument to bar . Similarly, Dozen redirects its own template parameter T as an argument to the ArrayInClass template to create a specific type of this ArrayInClass .
Finally, T is a compile-time expression. This means that it gives value at compile time. (Expressions are functions of a programming language that give meaning). The value of an expression is a type ( T ) or a numeric constant ( 12 ).
ArrayInClass<T,12> also a compile-time expression that gives an instance of the ArrayInClass template that creates the particular type. Soon, a compilation type expression can be used to build another compilation time expression - it produces a different (complex) value.
In metaprogramming, it’s nice not to think of value as a number or a string. Type is also a value here.