I’m writing some macros which declare template types and I’m a bit stumped for terminology. To illustrate, take the following example:
// template class declaration
template <typename A, typename B> // what is this called?
class A;
My question is: What is the name of the line above class A
?
1
That is simply part of the class declaration.
When you declare a type, you essentially say “this is a type.” Compared to the definition which provides the contents of the type: its data members and member functions (although those functions may themselves be declarations, with the definitions separate).
That the declaration you provided involves a template does not change this fact, nor does the fact that they are on separate lines in the file. The newline is irrelevant here: the important thing is what occurs from the beginning of the statement to its end (the semicolon).
4
As far as I’m aware, there doesn’t seem to be an official name for it.
In the C++ standard, the grammar for a template declaration is:
template-declaration:
"template" "<" template-parameter-list ">" declaration
so it doesn’t actually designate a name for the template<...>
part.