[LC++]Template functions and linking
Vincent Penquerc'h
Vincent.Penquerch at artworks.co.uk
Mon Jul 8 19:14:50 UTC 2002
> One solution would be to put the implementation of doit in the
> header
> and make it inline.
>
> Is there a better way?
Wait for the export keyword to be implemented ;)
What I do, which is slightly better, but only a variation on
this, is to have a separate object file, where I instanciate
these templates.
eg, if I have the template foo, which I know I use with int,
vector<float> and bool, I will create a file called, say,
foo_instances:
#include "foo.h"
#include "foo.cpp"
template class foo<int>;
template class foo<vector<float> >;
template class foo<bool>;
This is the only file that has access to the foo.cpp file,
so it's a bit cleaner (though not much at all).
HTH
--
Vincent Penquerc'h
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux.org.au/pipermail/tuxcpprogramming/attachments/20020708/5ea0ad9c/attachment.htm
More information about the tuxCPProgramming
mailing list