<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2448.0">
<TITLE>RE: [LC++]Template functions and linking</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>&gt; One solution would be to put the implementation of doit in the</FONT>
<BR><FONT SIZE=2>&gt; header</FONT>
<BR><FONT SIZE=2>&gt; and make it inline.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Is there a better way?</FONT>
</P>

<P><FONT SIZE=2>Wait for the export keyword to be implemented ;)</FONT>
</P>

<P><FONT SIZE=2>What I do, which is slightly better, but only a variation on</FONT>
<BR><FONT SIZE=2>this, is to have a separate object file, where I instanciate</FONT>
<BR><FONT SIZE=2>these templates.</FONT>
<BR><FONT SIZE=2>eg, if I have the template foo, which I know I use with int,</FONT>
<BR><FONT SIZE=2>vector&lt;float&gt; and bool, I will create a file called, say,</FONT>
<BR><FONT SIZE=2>foo_instances:</FONT>
</P>

<P><FONT SIZE=2>#include &quot;foo.h&quot;</FONT>
<BR><FONT SIZE=2>#include &quot;foo.cpp&quot;</FONT>
</P>

<P><FONT SIZE=2>template class foo&lt;int&gt;;</FONT>
<BR><FONT SIZE=2>template class foo&lt;vector&lt;float&gt; &gt;;</FONT>
<BR><FONT SIZE=2>template class foo&lt;bool&gt;;</FONT>
</P>

<P><FONT SIZE=2>This is the only file that has access to the foo.cpp file,</FONT>
<BR><FONT SIZE=2>so it's a bit cleaner (though not much at all).</FONT>
</P>

<P><FONT SIZE=2>HTH</FONT>
</P>

<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Vincent Penquerc'h </FONT>
</P>

</BODY>
</HTML>