Article View: gnu.g++.help
Article #38templates in g++
From: Scott Kohn
Date: Mon, 06 Apr 1992 15:47
Date: Mon, 06 Apr 1992 15:47
38 lines
1303 bytes
1303 bytes
Sorry if this is a really stupid question, but here it goes: - Is there a way of getting one globally linkable instantiation of a template class? Consider the following: --- file foo.c --- #include "array.h" ... Array<int> a; ... a.print(); --- file bar.c --- #include "array.h" ... Array<int> a; ... a.print(); --------------- Now, both of the print member functions could potentially share the same code. However, the current g++ 2.0 implementation generates local code only. That is, g++ generates print() code in foo.o and also generates print() code in bar.o -- even though the code is identical (both are for an int template). I'm writing a large template class and I would really like to avoid this type of unnecessary code duplication. Any suggestions? Thanks... -- Scott Kohn
Technical Details
Message-ID:
<31377@sdcc12.ucsd.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!network.ucsd.edu!sdcc12!cs!skohnShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!network.ucsd.edu!sdcc12!cs!skohn From: skohn@cs.ucsd.edu (Scott Kohn) Newsgroups: gnu.g++.help Subject: templates in g++ Keywords: code duplication Message-ID: <31377@sdcc12.ucsd.edu> Date: 6 Apr 92 15:47:08 GMT Sender: news@sdcc12.ucsd.edu Followup-To: gnu.g++.help Distribution: usa Organization: UC-San Diego CSE Department Lines: 38 Nntp-Posting-Host: picard.ucsd.edu