This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The future C++ template model in gcc


Florian Schintke <schintke@zib.de> writes:

| > The question is how to you determine the set of "all necessary
| > instantiations"?
| 
| If you do it generic, you don't need to know this, because the generic
| implementation function for any.

How?

| > | My idea is to not instantiate the templates,
| > | but to provide a generic template implementation that works 
| > | for all template arguments. 
| > 
| > How, given a template, do you construct "a generic template
| > implementation that works for all template arguments"? 
| 
| Yes, that is my question. Is this possible? Where are the problems?

No, it is not possible for the most practical templates.
Instantiating a template requires a context which varies from one
point of instantiation to another.  Template instantiation also
requires a second phase of semantics analysis.

| With a template you get functions that get parameters of different
| sizes depending on the instantiation.

But the point is that a template is a not a function.
The analogy "template <-> function" is useful to explain some high-level
abstract concepts, but it breaks down when it comes to implement
things the way they have to behave according to C++ definition.

| to handle this generic you can introduce the information
| of the parameter size additionally.

It is not just a question of size, you also have to meet alignment
requirements, semantics restrictions which the compiler has to
enforce. 

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]