Article View: alt.linux
Article #1088Re: Templates
From: Arthur Rabatin
Date: Thu, 22 Apr 1999 00:00
Date: Thu, 22 Apr 1999 00:00
44 lines
2731 bytes
2731 bytes
Andrew Eiler wrote: > > Or include the cc file at the bottom header file. The only issue you run into Although even Stroustrup uses this as example, this is very bad practice indeed and one must be surprised to see that as a possible solution in Stroustrup's book at all. Including the source file is no different from writing code into the header but exposes implementation details of other code. As noted in another message, instantiating the template in the .cc file template basic_class < int > et c. allows the implementation to reside in cc. The .h file can then provide a typedef basic_class<int> int_class for it's users. The advantage of that is that each member function of the template class gets actually compile for the type provided, which it would not unless instatiated and used somewhere else in the code. That reduces development time. The disadvantage is of course that adding new types requires modification of that source file; but that might be a minor problem unless you're writing a new template library. Eventually, the compiler should (will? might?) support the export keyword which allows the template function implementation to be kept in the .cc file but made available to other compilation units as template (uninstatiated). Regards Arthur /* Rabatin Investment Technology Ltd http://www.rabatin.com */
Technical Details
Message-ID:
<371EE5D8.665FB913@rabatin.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<ShVO2.260$G4.285045@news.abs.net> <370C598E.C8C64F66@te.net.ua> <7ei7vb$nad@news3.euro.net> <3714F74F.49173BD0@cdott.com> <37173C8E.3E223388@lehigh.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5392,eaa6e2f181a1fe60 X-Google-Attributes: gidf5392,public X-Google-Thread: 10c696,eaa6e2f181a1fe60 X-Google-Attributes: gid10c696,public X-Google-Thread: f8c9b,eaa6e2f181a1fe60 X-Google-Attributes: gidf8c9b,public X-Google-Thread: fc89c,eaa6e2f181a1fe60 X-Google-Attributes: gidfc89c,public X-Google-Thread: faa64,eaa6e2f181a1fe60 X-Google-Attributes: gidfaa64,public X-Google-Thread: 109fba,eaa6e2f181a1fe60 X-Google-Attributes: gid109fba,public X-Google-Thread: 100c5f,eaa6e2f181a1fe60 X-Google-Attributes: gid100c5f,public X-Google-Thread: 10ba33,eaa6e2f181a1fe60 X-Google-Attributes: gid10ba33,public From: Arthur Rabatin <ar@rabatin.com> Subject: Re: Templates Date: 1999/04/22 Message-ID: <371EE5D8.665FB913@rabatin.com> X-Deja-AN: 469483804 Content-Transfer-Encoding: 7bit References: <ShVO2.260$G4.285045@news.abs.net> <370C598E.C8C64F66@te.net.ua> <7ei7vb$nad@news3.euro.net> <3714F74F.49173BD0@cdott.com> <37173C8E.3E223388@lehigh.edu> Content-Type: text/plain; charset=us-ascii Organization: rabatin.com Mime-Version: 1.0 Reply-To: info@rabatin.com Newsgroups: alt.linux,alt.os.linux,comp.lang.c++,comp.os.linux.development.apps,comp.os.linux.development.system,comp.unix.programmer,comp.unix.questions,gnu.g++.help,gnu.gcc.help