To give a complete example, let’s say I have a template class that I now use to generate a type definition:
template <typename T>
struct A {};
using X = // I'm not asking about this
A<int>; // I want to know what this is
What is the name of A<int>
? My initial thoughts were that it was a generic specialisation of A
, because I recall reading that somewhere in reference to the standard, but I can’t find it now.
The answer should make reference to the standard or, if that is not possible, cite an authoritative source that sets some sort of precedent for how it is named.
I know these kinds of questions are borderline but I don’t know of any other place to ask them and I’ve done my best to address the points raised in this meta discussion about questions on naming.
5
It’s just an alias: it takes A<T>
, instantiate it with T=int
and calls it X
Declare X a;
and a
will be an A<int>
.
The documentation is as cppreference
Here are some references.
About A it is a “template instantiation”: the generic type A is compiled using int
in the place of T
.
It is like vector<int>
respect to vector<double>
starting from vector<T>
4
Scott Meyers’ Effective Modern C++ mentions “function templates (i.e., templates that generate functions) and template functions (i.e., the functions generated from function templates).”
A
can be called a struct template, and A<int>
can be called a template struct.