🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer.misc
Article #299

Re: (Q) Templates: separate compilation with emx/gcc and OS/2

#299
From: Steven Eker
Date: Tue, 22 Mar 1994 15:44
27 lines
2291 bytes
In article <1994Mar18.094731.18956@ensmp.fr>, zhou@cri.ensmp.fr (Lei ZHOU) writes:
|> 
|> Solution for small application is to create just one file in which all the
|> instantiations are generated. This file along includes the template text files.
|> All other program files include the template header file.
|> 

I have a related problem. I am building a container class which I want
to instantiate over many diffferent element types. I write a single
(typeless) implementation and then have a class template interface which
has a bunch of inline function for doing pointer conversion so that
container class appears to be strongly typed to the user.

Now gcc compiles each instantiation of my template by creating a bunch of
local functions for each compilation unit rather than just inlining
my inline functions.

This has two obvious inefficencies: (1) I get an extra layer of function
calls between the user code and the container function. This is especially
painful where the container function was itself an inline doing a single
pointer manipulation. (2) I get code duplication in each compilation unit.

Creating a single file to hold template instantiations is a solution to (2)
but only for smallish applications. Of course the place where you really want to
use C++'s abtraction and type checking mechanisms is large apps...

Steven
Technical Details
Message-ID: <2mn3ou$9np@bambam.cs.city.ac.uk>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!darwin.sura.net!howland.reston.ans.net!pipex!doc.ic.ac.uk!cs.city.ac.uk!snark.cs.city.ac.uk!steve
References: <COATES.94Mar18001802@kelvin.physics.uq.oz.au> <1994Mar18.094731.18956@ensmp.fr>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,fc0e323eac88ae3b
X-Google-Attributes: gid109fba,public
X-Google-Thread: 11307a,fc0e323eac88ae3b
X-Google-Attributes: gid11307a,public
X-Google-Thread: 10ba33,fc0e323eac88ae3b
X-Google-Attributes: gid10ba33,public
X-Google-ArrivalTime: 1994-03-22 07:44:30 PST
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!darwin.sura.net!howland.reston.ans.net!pipex!doc.ic.ac.uk!cs.city.ac.uk!snark.cs.city.ac.uk!steve
From: steve@snark.cs.city.ac.uk (Steven Eker)
Newsgroups: comp.os.os2.programmer.misc,comp.lang.c++,gnu.g++.help
Subject: Re: (Q) Templates: separate compilation with emx/gcc and OS/2
Date: 22 Mar 1994 15:44:30 GMT
Organization: citycs
Lines: 27
Distribution: world
Message-ID: <2mn3ou$9np@bambam.cs.city.ac.uk>
References: <COATES.94Mar18001802@kelvin.physics.uq.oz.au> <1994Mar18.094731.18956@ensmp.fr>
NNTP-Posting-Host: snark.cs.city.ac.uk