public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Template Question
@ 2003-03-27 14:16 Eric Lemings
  0 siblings, 0 replies; only message in thread
From: Eric Lemings @ 2003-03-27 14:16 UTC (permalink / raw)
  To: gcc-help

Hi,

Using g++, can templates not be compiled separately from files that use them
and linked like normal object files?  Or do the template source files have
to be included like header files in the source files that use them?  For
example,

::::::::::::::
Test01.h
::::::::::::::

template <class T>
void foo (const T& t);

::::::::::::::
Test01.cpp
::::::::::::::

#include "Test01.h"

template <class T>
void foo (const T& t) {
  // do something with t
}

::::::::::::::
Main.cpp
::::::::::::::

#include "Test01.h"

int main (void) {
  foo<long> (42);
  return (0);
}

Can g++ compile and link these files just as if foo() were a plain ol'
function?  The GCC documentation on this topic appears to be obsolete.

Thanks,
Eric.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-27 14:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-27 14:16 Template Question Eric Lemings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).