From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_05,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,faf964ea4531e6af X-Google-Attributes: gid103376,public X-Google-Thread: 1025b4,43ae7f61992b3213 X-Google-Attributes: gid1025b4,public From: philh@vision25.demon.co.uk (Phil Hunt) Subject: Re: GPL and "free" software Date: 1999/05/02 Message-ID: <925653268snz@vision25.demon.co.uk>#1/1 X-Deja-AN: 473264939 X-Mail2News-Path: news.demon.net!vision25.demon.co.uk References: <3729D0F6.3DF2CCED@doc.ic.ac.uk> <925572182snz@vision25.demon.co.uk> <372C1824.1417502F@doc.ic.ac.uk> X-Trace: mail2news.demon.co.uk 925675791 mail2news:19881 mail2news mail2news.demon.co.uk Organization: here Reply-To: philh@vision25.demon.co.uk Newsgroups: comp.lang.ada,gnu.misc.discuss X-Complaints-To: abuse@demon.net Date: 1999-05-02T00:00:00+00:00 List-Id: In article <372C1824.1417502F@doc.ic.ac.uk> epa98@doc.ic.ac.uk "Ed Avis" writes: > Phil Hunt wrote: > >>Can't you write a template class in C++, and put > >>it in a dynamically linked library? > > > >I would be surprised if this is the case. However instantiations of > >templates can be put in a DLL or .so. > > What do you mean by 'instantiations of templates'? > > Surely if I write a class like this (pseudocode, I don't know Ada and > my C++ is rusty): > > class List > let T be any class > method add(T) > method get_first_item : returns T > method count_items : returns Int > > then there will only one copy of the executable code in the object > file. If the program instantiates a List of Int, then the code for > List is called and passed pointers (or references) to Ints. If the > program wants a List of Char, then the same object code can be used, > being passed pointers to Chars. > > Or have I got it horribly wrong? I think you've got it horribly wrong (there might be C++ compilers that work like that, but I imagine they are very rare, produce slow code and are horrible to implement). What C++ does is constructs code for the template with T changed to int, compiles it, and produces code for the template with T changed to char, and compiles that as well. -- Phil Hunt....philh@vision25.demon.co.uk