🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Scott Kohn Mon, 06 Apr 1992 15:47
templates in g++
#38
Author: Scott Kohn
Date: Mon, 06 Apr 1992 15:47
38 lines
1303 bytes
Sorry if this is a really stupid question, but here it goes:

 - Is there a way of getting one globally linkable instantiation
   of a template class?

Consider the following:

--- file foo.c ---

#include "array.h"
...
Array<int> a;
...
a.print();

--- file bar.c ---

#include "array.h"
...
Array<int> a;
...
a.print();

---------------

Now, both of the print member functions could potentially
share the same code.  However, the current g++ 2.0 implementation
generates local code only.  That is, g++ generates print() code in
foo.o and also generates print() code in bar.o -- even though the
code is identical (both are for an int template).

I'm writing a large template class and I would really like to avoid
this type of unnecessary code duplication.  Any suggestions?

Thanks...

-- Scott Kohn
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads