C++ templates
Jacek Wojdel
wojdel at chrysler.kbs.twi.tudelft.nl
Mon Nov 20 15:26:01 GMT 2000
>
> hmm, why would you need to do this last part? that's wack. if you want a
> my_class w/ type int... when you needed that object (say, in some function),
> you would say "my_class<int> nameOfObject;" there is no need to do what you
> have here. I have never seen anything like you've done here, and I use
> templates all the time.
>
> I swear that's all you haev to do! I do it all the time.. No crazy stuff,
> just the ANSI Standard way of doing it -- No "instatiations"... that's why
> they're classes.. you declare a new instance when you need one where you need
> one.
>
> -Ben
>
I know, this thread is already quite long, but... I just like to be right :)
First of all explicit instantiation of template classes is a "wack"; that's
true. There is however a problem with some linkers (yeah, that's linker's issue
not compiler's) that make this "wack" handy from time to time. Without it:
Undefined first referenced
symbol in file
my_class<int>::my_class(void) main.o
ld: fatal: Symbol referencing errors. No output written to p
collect2: ld returned 1 exit status
That's the output you'll get on my Solaris box equipped with gcc 2.95.2 and ld:
Software Generation Utilities - Solaris-ELF (4.0).
As far as I understood this, most of linkers on *nix machines still do
single-pass linkage and that means problems for template classes. I think that
Strostrup once said that he was very strict about template syntax in c++ just
in order to force system developers to introduce more efficient multiple-pass
linkers. Seemingly he didn't really succeed.
Regards,
Jacek
--
+-------------------------------------+
|from: J.C.Wojdel |
| J.C.Wojdel at cs.tudelft.nl |
+-------------------------------------+
-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«
More information about the KDevelop
mailing list