Unfortunately i have lost the link and the source for this article, but I do remember that it was about metaprogramming and templates in C++; when talking about the limitations around the template approach, this article was speaking about the fact that what is passed to a template it’s not a generic type, but only types with a related address ( or addressable, I don’t remember the exact words ) can be passed as arguments to a template.
Can someone clarify this relation between addresses, types and templates ?
A type can be identified with an address ?
EDIT
for example at this link, in the last part of the linked FAQ, the template system is described like something that takes an address rather than a generic type.
I don’t know about the original article you read, but the FAQ you linked to in the edit does not talk about a connection between types and addresses.
It talks about one specific kind of template parameters, the non-type parameters. There are three kinds of template parameters: type, non-type and template. So this is specifically about the second kind.
An example of a non-type parameter is
Idin the definition below:Iddoes not represent a type, but a non-type, i.e. an actual value. In this particular example, that value happens to be of a a pointer type, and it represents the address of a string.The idea is that you can use this to instantiate the template using a string as distinguisher:
Unfortunately, it does not work like this – and that is what the FAQ article is about. It explains that for a non-type template parameter, you must use a constant expression, and in this particular case, you must use an identifier of an object with external linkage, not just a literal. So the only way you can do it is this:
That is what the FAQ article explains.
However, again, this is a very special case, because it applies to non-type parameters of an address type only. Note that the connection to addresses is given because the non-type parameter is explicitly specified as a parameter of pointer type
const char *.Most usual templates arguably use either a type-parameter or a non-type parameter of an integral, enum, or user-defined type. None of those has anything to do with memory addresses. There is no implicit connection between using templates and using memory addresses.