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?


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).

| improve this answer | |
  • So then what is the name you would give to the difference between template <typename X> class A; and class A;? There's no name for it? – quant Oct 3 '14 at 1:12
  • 1
    The first is a template class, the second is not. If there is a name for it, it is not something I am familiar with or can locate with a web search. – user22815 Oct 3 '14 at 1:15
  • Wouldn't the template< blah, blah > be called the "template argument list"? – glampert Oct 3 '14 at 4:35
  • That makes sense, but I was not able to find an "official" name nor did Rufflewind in the other answer. – user22815 Oct 3 '14 at 14:38

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" "<" template-parameter-list ">" declaration

so it doesn't actually designate a name for the template<...> part.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.