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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1025b4,43ae7f61992b3213 X-Google-Attributes: gid1025b4,public X-Google-Thread: 103376,faf964ea4531e6af X-Google-Attributes: gid103376,public From: Ole-Hjalmar Kristensen Subject: Re: GPL and "free" software Date: 1999/05/02 Message-ID: #1/1 X-Deja-AN: 473268412 X-NNTP-Posting-Host: fwall.clustra.com Sender: ohk@maestro.clustra.com References: <3729D0F6.3DF2CCED@doc.ic.ac.uk> <925572182snz@vision25.demon.co.uk> <372C1824.1417502F@doc.ic.ac.uk> Newsgroups: comp.lang.ada,gnu.misc.discuss X-Complaints-To: abuse@telia.no Date: 1999-05-02T00:00:00+00:00 List-Id: 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? > > -- > Ed Avis > Advertise here! epa98@doc.ic.ac.uk In principle, you're right that it could be done this way. However, the majority of compilers seem to create a separate instance for each T, just as a macro processor would have done. Olw-Hj. Kristensen -- E pluribus Unix