Re: Templates in C++

bill@amber.ssd.hcsc.com (Bill Leonard)
Thu, 25 May 1995 21:17:52 GMT

          From comp.compilers

Related articles
[2 earlier articles]
Re: Templates in C++ jsgray@ix.netcom.com (1995-05-12)
Re: Templates in C++ shepherd@schubert.sbi.com (1995-05-12)
Re: Templates in C++ norman@flaubert.bellcore.com (1995-05-14)
Re: Templates in C++ davidm@flora.Rational.com (1995-05-16)
Re: Templates in C++ jgmorris@cs.cmu.edu (Greg Morrisett) (1995-05-17)
Re: Templates in C++ jplevyak@violet-femmes.cs.uiuc.edu (1995-05-17)
Re: Templates in C++ bill@amber.ssd.hcsc.com (1995-05-25)
Re: Templates in C++ kanze@gabi-soft.fr (1995-05-29)
Re: Templates in C++ mac@coos.dartmouth.edu (1995-06-23)
Re: Templates in C++ shankar@sgihub.corp.sgi.com (1995-06-25)
Re: Templates in C++ bill@amber.ssd.hcsc.com (1995-06-30)
Re: Templates in C++ collberg@cs.auckland.ac.nz (1995-07-12)
| List of all articles for this month |
Newsgroups: comp.compilers
From: bill@amber.ssd.hcsc.com (Bill Leonard)
Keywords: C++, performance
Organization: Harris Computer Systems, Ft. Lauderdale FL
References: 95-05-081 95-05-092
Date: Thu, 25 May 1995 21:17:52 GMT
Status: RO

jsgray@ix.netcom.com (Jan Gray) writes:
> Even without a program database, the redundant instantiation problem
> is simple if you can make minor extensions to your linker and object
> module format.
> ...
> Even if every object contributes the instantiation of
> "list<int>::add()" or whatever, the linker only keeps one copy per
> binary or dynamic library.


Although this is a relatively simple "solution", it is pretty odious. The
intermediate object modules can needlessly take up many megabytes of disk
space. Compiling all those redundant instantiations can take hours of CPU
time.


IMHO, the goal of code reuse (like that via templates) is not only to
reduce the effort of coding, testing, and maintaining the code, but also
the time it takes to build your application. This "solution" defeats that
goal.


And what does the linker do if the multiple versions of a template
instantiation don't match (because the template changed but not all modules
that use it were recompiled)? Sounds like a possible source of hours of
head-scratching.


A program database, even a rudimentary one, seems to me a much better
solution, because you don't generate the redundant instantiations in the
first place.


> A more common problem with templates is you tend to see many
> instantiations of containers of similar types, e.g. list<int>,


Seems like, if you have a program database, you could apply similar
technology to this problem as that used in Ada to share generic
instantiations. Same problem, essentially.


--
Bill Leonard
Harris Computer Systems Corporation
2101 W. Cypress Creek Road
Fort Lauderdale, FL 33309
Bill.Leonard@mail.hcsc.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.